diff --git a/src/lib/config/config_data.cc b/src/lib/config/config_data.cc index ebe51cc5a2a11385dd799810980aff454f208fbf..fb5dd75f4e03f668d34c3748e3dc81e859f04042 100644 --- a/src/lib/config/config_data.cc +++ b/src/lib/config/config_data.cc @@ -235,7 +235,7 @@ ConfigData::getItemList(const std::string& identifier, bool recurse) const { ConstElementPtr ConfigData::getFullConfig() const { ElementPtr result = Element::createMap(); - ConstElementPtr items = getItemList("", true); + ConstElementPtr items = getItemList("", false); BOOST_FOREACH(ConstElementPtr item, items->listValue()) { result->set(item->stringValue(), getValue(item->stringValue())); } diff --git a/src/lib/config/config_data.h b/src/lib/config/config_data.h index 1be7c7a4bb7a9f4cc30319a16f65c01f5144bfd0..e40600d728dab9ee7032d4df352d282f6c7f4c55 100644 --- a/src/lib/config/config_data.h +++ b/src/lib/config/config_data.h @@ -110,11 +110,11 @@ public: isc::data::ConstElementPtr getItemList(const std::string& identifier = "", bool recurse = false) const; - /// Returns all current configuration settings (both non-default and default). + /// Returns a map of the top-level configuration items, as currently + /// set or their defaults + /// /// \return An ElementPtr pointing to a MapElement containing - /// string->value elements, where the string is the - /// full identifier of the configuration option and the - /// value is an ElementPtr with the value. + /// the top-level configuration items isc::data::ConstElementPtr getFullConfig() const; private: @@ -126,6 +126,6 @@ private: } #endif -// Local Variables: +// Local Variables: // mode: c++ -// End: +// End: diff --git a/src/lib/config/tests/config_data_unittests.cc b/src/lib/config/tests/config_data_unittests.cc index 26a3fc69115be5b58a70b5534480f34474b9c36c..4b83e5c899a3eaa4db960d4d2b8b3f9a0a2cb112 100644 --- a/src/lib/config/tests/config_data_unittests.cc +++ b/src/lib/config/tests/config_data_unittests.cc @@ -118,7 +118,7 @@ TEST(ConfigData, getLocalConfig) { ModuleSpec spec2 = moduleSpecFromFile(std::string(TEST_DATA_PATH) + "/spec2.spec"); ConfigData cd = ConfigData(spec2); EXPECT_EQ("{ }", cd.getLocalConfig()->str()); - + ElementPtr my_config = Element::fromJSON("{ \"item1\": 2 }"); cd.setLocalConfig(my_config); EXPECT_EQ("{ \"item1\": 2 }", cd.getLocalConfig()->str()); @@ -141,12 +141,15 @@ TEST(ConfigData, getFullConfig) { ModuleSpec spec2 = moduleSpecFromFile(std::string(TEST_DATA_PATH) + "/spec2.spec"); ConfigData cd = ConfigData(spec2); - EXPECT_EQ("{ \"item1\": 1, \"item2\": 1.1, \"item3\": true, \"item4\": \"test\", \"item5\": [ \"a\", \"b\" ], \"item6/value1\": \"default\", \"item6/value2\": None }", cd.getFullConfig()->str()); + EXPECT_EQ("{ \"item1\": 1, \"item2\": 1.1, \"item3\": true, \"item4\": \"test\", \"item5\": [ \"a\", \"b\" ], \"item6\": { } }", cd.getFullConfig()->str()); ElementPtr my_config = Element::fromJSON("{ \"item1\": 2 }"); cd.setLocalConfig(my_config); - EXPECT_EQ("{ \"item1\": 2, \"item2\": 1.1, \"item3\": true, \"item4\": \"test\", \"item5\": [ \"a\", \"b\" ], \"item6/value1\": \"default\", \"item6/value2\": None }", cd.getFullConfig()->str()); + EXPECT_EQ("{ \"item1\": 2, \"item2\": 1.1, \"item3\": true, \"item4\": \"test\", \"item5\": [ \"a\", \"b\" ], \"item6\": { } }", cd.getFullConfig()->str()); ElementPtr my_config2 = Element::fromJSON("{ \"item6\": { \"value1\": \"a\" } }"); cd.setLocalConfig(my_config2); - EXPECT_EQ("{ \"item1\": 1, \"item2\": 1.1, \"item3\": true, \"item4\": \"test\", \"item5\": [ \"a\", \"b\" ], \"item6/value1\": \"a\", \"item6/value2\": None }", cd.getFullConfig()->str()); + EXPECT_EQ("{ \"item1\": 1, \"item2\": 1.1, \"item3\": true, \"item4\": \"test\", \"item5\": [ \"a\", \"b\" ], \"item6\": { \"value1\": \"a\" } }", cd.getFullConfig()->str()); + ElementPtr my_config3 = Element::fromJSON("{ \"item6\": { \"value2\": 123 } }"); + cd.setLocalConfig(my_config3); + EXPECT_EQ("{ \"item1\": 1, \"item2\": 1.1, \"item3\": true, \"item4\": \"test\", \"item5\": [ \"a\", \"b\" ], \"item6\": { \"value2\": 123 } }", cd.getFullConfig()->str()); }