class AbstractSynchronizationObjectGenerator
{
-public:
+ public:
virtual ~AbstractSynchronizationObjectGenerator() {}
virtual DPL::DB::SqlConnection::SynchronizationObject *Create() = 0;
};
-class NaiveSynchronizationObjectGenerator
- : public AbstractSynchronizationObjectGenerator
+class NaiveSynchronizationObjectGenerator :
+ public AbstractSynchronizationObjectGenerator
{
-public:
+ public:
virtual DPL::DB::SqlConnection::SynchronizationObject *Create()
{
return new DPL::DB::NaiveSynchronizationObject();
void MassiveReadWriteTest(AbstractSynchronizationObjectGenerator *generator);
-class StressGenerator
- : public DPL::Thread
+class StressGenerator :
+ public DPL::Thread
{
-private:
+ private:
size_t m_prefix;
std::string m_dbFileName;
AbstractSynchronizationObjectGenerator *m_generator;
-protected:
+ protected:
virtual int ThreadEntry()
{
DPL::DB::SqlConnection connection(
connection.PrepareDataCommand(
"SELECT COUNT(*) FROM test WHERE value=?");
- for (size_t i = 0; i < 10; ++i)
- {
+ for (size_t i = 0; i < 10; ++i) {
std::ostringstream valueStream;
valueStream << "value_";
return 0;
}
-public:
+ public:
StressGenerator(size_t prefix,
const std::string &dbFileName,
- AbstractSynchronizationObjectGenerator *generator)
- : m_prefix(prefix),
- m_dbFileName(dbFileName),
- m_generator(generator)
- {
- }
+ AbstractSynchronizationObjectGenerator *generator) :
+ m_prefix(prefix),
+ m_dbFileName(dbFileName),
+ m_generator(generator)
+ {}
};
typedef std::shared_ptr<DPL::Thread> ThreadPtr;
const size_t STRESS_GENERATOR_COUNT = 5;
ThreadPtr stressGenerators[STRESS_GENERATOR_COUNT];
- for (size_t i = 0; i < STRESS_GENERATOR_COUNT; ++i)
- {
+ for (size_t i = 0; i < STRESS_GENERATOR_COUNT; ++i) {
stressGenerators[i].reset(
new StressGenerator(i, PATH_DB, generator));
stressGenerators[i]->Run();
}
- for (size_t i = 0; i < STRESS_GENERATOR_COUNT; ++i)
+ for (size_t i = 0; i < STRESS_GENERATOR_COUNT; ++i) {
stressGenerators[i]->Quit();
+ }
connection.ExecCommand("DROP TABLE test;");
}
MassiveReadWriteTest(&m_generator);
}
-
-
-
-
-
RUNNER_TEST(SqlConnection_Not_Connected_Lucene)
{
Try {
- DPL::DB::SqlConnection connection("/notexisitingdirectiory/foo",
- DPL::DB::SqlConnection::Flag::UseLucene,
- DPL::DB::SqlConnection::Flag::RW);
+ DPL::DB::SqlConnection connection(
+ "/notexisitingdirectiory/foo",
+ DPL::DB::SqlConnection::Flag::
+ UseLucene,
+ DPL::DB::SqlConnection::Flag::RW);
RUNNER_ASSERT_MSG(false,
"connection should throw on accessing "
"nonexistent file as a database");
}
- Catch (DPL::DB::SqlConnection::Exception::ConnectionBroken)
+ Catch(DPL::DB::SqlConnection::Exception::ConnectionBroken)
{
RUNNER_ASSERT(true);
- }
- catch (DPL::Exception)
- {
+ } catch (DPL::Exception) {
RUNNER_ASSERT_MSG(false, "Wrong exception found");
}
}
"connection should throw on accessing "
"nonexistent file as a database");
}
- Catch (DPL::DB::SqlConnection::Exception::ConnectionBroken)
+ Catch(DPL::DB::SqlConnection::Exception::ConnectionBroken)
{
RUNNER_ASSERT(true);
- }
- catch (DPL::Exception)
- {
+ } catch (DPL::Exception) {
RUNNER_ASSERT_MSG(false, "Wrong exception found");
}
}
RUNNER_ASSERT_MSG(false,
"Null pointer should not be accepted");
}
- Catch (DPL::DB::SqlConnection::Exception::SyntaxError)
+ Catch(DPL::DB::SqlConnection::Exception::SyntaxError)
{
RUNNER_ASSERT(true);
- }
- catch (DPL::Exception)
- {
+ } catch (DPL::Exception) {
RUNNER_ASSERT_MSG(false, "Wrong exception found");
}
-
}
RUNNER_TEST(SqlConnection_Bad_Query)
connection.ExecCommand("Some stupid string");
RUNNER_ASSERT_MSG(false, "This string should not be accepted");
}
- Catch (DPL::DB::SqlConnection::Exception::SyntaxError)
+ Catch(DPL::DB::SqlConnection::Exception::SyntaxError)
{
RUNNER_ASSERT(true);
- }
- catch (DPL::Exception)
- {
+ } catch (DPL::Exception) {
RUNNER_ASSERT_MSG(false, "Wrong exception found");
}
}