// PERFORMANCE OF THIS SOFTWARE.
#include <config.h>
+
#include <exceptions/exceptions.h>
+#include <cc/data.h>
+ #include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/daemon.h>
#include <dhcpsrv/logging.h>
#include <log/logger_unittest_support.h>
// 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\": ["
// 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_);
}
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));
}