From: Marcin Siodelski Date: Tue, 16 Sep 2014 11:12:23 +0000 (+0200) Subject: [master] Merge branch 'trac3534' X-Git-Tag: trac3595_base~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4ecee3c0c97fe417b050317356f9093ba3771a15;p=thirdparty%2Fkea.git [master] Merge branch 'trac3534' Conflicts: src/lib/dhcpsrv/tests/daemon_unittest.cc --- 4ecee3c0c97fe417b050317356f9093ba3771a15 diff --cc src/lib/dhcpsrv/tests/daemon_unittest.cc index 23469d4c40,8f01746f7e..bd9c3a37f3 --- a/src/lib/dhcpsrv/tests/daemon_unittest.cc +++ b/src/lib/dhcpsrv/tests/daemon_unittest.cc @@@ -13,9 -13,8 +13,10 @@@ // PERFORMANCE OF THIS SOFTWARE. #include + #include +#include + #include #include #include #include @@@ -67,10 -49,11 +68,11 @@@ TEST_F(DaemonTest, constructor) // Checks that configureLogger method is behaving properly. // More dedicated tests are availablef for LogConfigParser class. // See logger_unittest.cc -TEST(DaemonTest, parsingConsoleOutput) { +TEST_F(DaemonTest, parsingConsoleOutput) { + CfgMgr::instance().setVerbose(false); // Storage - parsed configuration will be stored here - ConfigurationPtr storage(new Configuration()); + SrvConfigPtr storage(new SrvConfig()); const char* config_txt = "{ \"loggers\": [" @@@ -89,18 -72,23 +91,18 @@@ // Spawn a daemon and tell it to configure logger Daemon x; - EXPECT_NO_THROW(x.configureLogger(config, storage, false)); + EXPECT_NO_THROW(x.configureLogger(config, storage)); - // configureLogger will modify the logging options of the log4cplus logger. - // We need to reset the logger settings so as the following tests are - // not affected by this modification. - isc::log::resetUnitTestRootLogger(); - // The parsed configuration should be processed by the daemon and // stored in configuration storage. - ASSERT_EQ(1, storage->logging_info_.size()); + ASSERT_EQ(1, storage->getLoggingInfo().size()); - EXPECT_EQ("kea", storage->logging_info_[0].name_); - EXPECT_EQ(99, storage->logging_info_[0].debuglevel_); - EXPECT_EQ(isc::log::DEBUG, storage->logging_info_[0].severity_); + EXPECT_EQ("kea", storage->getLoggingInfo()[0].name_); + EXPECT_EQ(99, storage->getLoggingInfo()[0].debuglevel_); + EXPECT_EQ(isc::log::DEBUG, storage->getLoggingInfo()[0].severity_); - ASSERT_EQ(1, storage->logging_info_[0].destinations_.size()); - EXPECT_EQ("stdout" , storage->logging_info_[0].destinations_[0].output_); + ASSERT_EQ(1, storage->getLoggingInfo()[0].destinations_.size()); + EXPECT_EQ("stdout" , storage->getLoggingInfo()[0].destinations_[0].output_); } diff --cc src/lib/dhcpsrv/tests/logging_unittest.cc index 2ae38d6b2f,3ea946e69a..9310bba8cc --- a/src/lib/dhcpsrv/tests/logging_unittest.cc +++ b/src/lib/dhcpsrv/tests/logging_unittest.cc @@@ -25,34 -24,13 +25,34 @@@ using namespace isc::data namespace { +/// @brief Logging Test Fixture Class +/// +/// Trivial class that ensures that the logging is reset to its defaults after +/// each test. Strictly speaking this only resets the testing root logger (which +/// has the name "kea") but as the only other logger mentioned here ("wombat") +/// is not used elsewhere, that is sufficient. + +class LoggingTest : public ::testing::Test { + public: + /// @brief Constructor + LoggingTest() {} + + /// @brief Destructor + /// + /// Reset root logger back to defaults. + ~LoggingTest() { + isc::log::resetUnitTestRootLogger(); + } +}; + + // Checks that contructor is able to process specified storage properly -TEST(LoggingTest, constructor) { +TEST_F(LoggingTest, constructor) { - ConfigurationPtr null_ptr; + SrvConfigPtr null_ptr; EXPECT_THROW(LogConfigParser parser(null_ptr), BadValue); - ConfigurationPtr nonnull(new Configuration()); + SrvConfigPtr nonnull(new SrvConfig()); EXPECT_NO_THROW(LogConfigParser parser(nonnull)); }