Commit bed3c88c authored by Jelte Jansen's avatar Jelte Jansen
Browse files

[master] Merge branch 'trac2619_merge'

parents 0c40d70c 2d95931b
......@@ -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()));
}
......
......@@ -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:
......@@ -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());
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment