Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
bed3c88c
Commit
bed3c88c
authored
Jan 10, 2013
by
Jelte Jansen
Browse files
[master] Merge branch 'trac2619_merge'
parents
0c40d70c
2d95931b
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/lib/config/config_data.cc
View file @
bed3c88c
...
...
@@ -235,7 +235,7 @@ ConfigData::getItemList(const std::string& identifier, bool recurse) const {
ConstElementPtr
ConfigData
::
getFullConfig
()
const
{
ElementPtr
result
=
Element
::
createMap
();
ConstElementPtr
items
=
getItemList
(
""
,
tru
e
);
ConstElementPtr
items
=
getItemList
(
""
,
fals
e
);
BOOST_FOREACH
(
ConstElementPtr
item
,
items
->
listValue
())
{
result
->
set
(
item
->
stringValue
(),
getValue
(
item
->
stringValue
()));
}
...
...
src/lib/config/config_data.h
View file @
bed3c88c
...
...
@@ -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:
src/lib/config/tests/config_data_unittests.cc
View file @
bed3c88c
...
...
@@ -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
());
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment