#include "session/SessionFactory.hpp" #include "session/SessionManagerProperties.hpp" #include "common/SystemProperties.hpp" #include "common/init.hpp" #include "session/Session.hpp" #include "session/StatsManager.hpp" #include "session/TestEnvironment.hpp" #include "common/Test.hpp" #include #include #include using namespace std; static std::string TEST_SE = ""; extern int tkScenario; void doWork() { if (!tkScenario) init("./etc/toolkit2.conf"); else scenario(tkScenario,"./etc/toolkit2.conf"); { TestEnvironment props; auto_ptr sess(SessionFactory::newInstance(&props)); sess->open(); sess->close(); } { TestEnvironment props; auto_ptr sess(SessionFactory::newInstance(&props)); sess->open(); sess->writeXML(TEST_SE); sess->read(); sess->close(); } { TestEnvironment props; auto_ptr sess(SessionFactory::newInstance(&props)); sess->open(); StatsManager* sm(sess->getStatsManager()); sm->incResultCounter(1000); ASSERT_EQ(sm->getResultCodeCount(1000), 1); sess->close(); } { TestEnvironment props; auto_ptr sess(SessionFactory::newInstance(&props)); sess->open(); StatsViewer* sv(sess->getStatsManager()); ASSERT_EQ(sv->getCommandCount(), 1); ASSERT_EQ(sv->getCommandCount(StandardCommandType::LOGIN()), 1); ASSERT_EQ(sv->getCommandCount(StandardCommandType::LOGOUT()), 0); sess->close(); } { TestEnvironment props; auto_ptr sess(SessionFactory::newInstance(&props)); sess->open(); StatsManager* sm(sess->getStatsManager()); ASSERT_EQ(sm->getResultCodeCount(1000), 0); sess->close(); } } int main(int argc, char* argv[]) { if (argc > 1) tkScenario = atoi(argv[1]); TEST_run(doWork); return TEST_errorCount(); }