[svn] commit: r2113 - in /branches/trac172/src: bin/auth/tests/ lib/cc/ lib/config/ lib/config/tests/ lib/datasrc/tests/
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Jun 15 13:02:26 UTC 2010
Author: jelte
Date: Tue Jun 15 13:02:26 2010
New Revision: 2113
Log:
rename createFromString() to fromJSON()
Modified:
branches/trac172/src/bin/auth/tests/auth_srv_unittest.cc
branches/trac172/src/lib/cc/data.cc
branches/trac172/src/lib/cc/data.h
branches/trac172/src/lib/cc/data_unittests.cc
branches/trac172/src/lib/cc/session.cc
branches/trac172/src/lib/config/ccsession.cc
branches/trac172/src/lib/config/module_spec.cc
branches/trac172/src/lib/config/tests/ccsession_unittests.cc
branches/trac172/src/lib/config/tests/config_data_unittests.cc
branches/trac172/src/lib/config/tests/module_spec_unittests.cc
branches/trac172/src/lib/datasrc/tests/datasrc_unittest.cc
branches/trac172/src/lib/datasrc/tests/sqlite3_unittest.cc
Modified: branches/trac172/src/bin/auth/tests/auth_srv_unittest.cc
==============================================================================
--- branches/trac172/src/bin/auth/tests/auth_srv_unittest.cc (original)
+++ branches/trac172/src/bin/auth/tests/auth_srv_unittest.cc Tue Jun 15 13:02:26 2010
@@ -236,7 +236,7 @@
const bool expect_success)
{
const ElementPtr config_answer =
- server->updateConfig(Element::createFromString(dbfile));
+ server->updateConfig(Element::fromJSON(dbfile));
EXPECT_EQ(Element::map, config_answer->getType());
EXPECT_TRUE(config_answer->contains("result"));
Modified: branches/trac172/src/lib/cc/data.cc
==============================================================================
--- branches/trac172/src/lib/cc/data.cc (original)
+++ branches/trac172/src/lib/cc/data.cc Tue Jun 15 13:02:26 2010
@@ -261,7 +261,7 @@
//
-// helper functions for createFromString factory
+// helper functions for fromJSON factory
//
namespace {
bool
@@ -477,7 +477,7 @@
skip_chars(in, " \t\n", line, pos);
while (c != EOF && c != ']') {
if (in.peek() != ']') {
- cur_list_element = Element::createFromString(in, file, line, pos);
+ cur_list_element = Element::fromJSON(in, file, line, pos);
list->add(cur_list_element);
skip_to(in, file, line, pos, ",]", " \t\n");
}
@@ -511,7 +511,7 @@
in.get();
pos++;
- ElementPtr value = Element::createFromString(in, file, line, pos);
+ ElementPtr value = Element::fromJSON(in, file, line, pos);
map->set(key, value);
skip_to(in, file, line, pos, ",}", " \t\n");
@@ -524,20 +524,20 @@
}
ElementPtr
-Element::createFromString(std::istream& in) throw(ParseError) {
+Element::fromJSON(std::istream& in) throw(ParseError) {
int line = 1, pos = 1;
- return createFromString(in, "<istream>", line, pos);
-}
-
-ElementPtr
-Element::createFromString(std::istream& in, const std::string& file_name) throw(ParseError)
+ return fromJSON(in, "<istream>", line, pos);
+}
+
+ElementPtr
+Element::fromJSON(std::istream& in, const std::string& file_name) throw(ParseError)
{
int line = 1, pos = 1;
- return createFromString(in, file_name, line, pos);
-}
-
-ElementPtr
-Element::createFromString(std::istream &in, const std::string& file, int& line, int& pos) throw(ParseError)
+ return fromJSON(in, file_name, line, pos);
+}
+
+ElementPtr
+Element::fromJSON(std::istream &in, const std::string& file, int& line, int& pos) throw(ParseError)
{
char c = 0;
ElementPtr element;
@@ -602,10 +602,10 @@
}
ElementPtr
-Element::createFromString(const std::string &in) {
+Element::fromJSON(const std::string &in) {
std::stringstream ss;
ss << in;
- return createFromString(ss, "<string>");
+ return fromJSON(ss, "<string>");
}
// to JSON format
@@ -712,7 +712,7 @@
std::stringstream ss;
ss << s;
int line = 0, pos = 0;
- return createFromString(ss, "<wire>", line, pos);
+ return fromJSON(ss, "<wire>", line, pos);
}
ElementPtr
@@ -728,7 +728,7 @@
//}
//length -= 4;
int line = 0, pos = 0;
- return createFromString(in, "<wire>", line, pos);
+ return fromJSON(in, "<wire>", line, pos);
}
void
Modified: branches/trac172/src/lib/cc/data.h
==============================================================================
--- branches/trac172/src/lib/cc/data.h (original)
+++ branches/trac172/src/lib/cc/data.h Tue Jun 15 13:02:26 2010
@@ -75,7 +75,7 @@
///
/// Elements should in calling functions usually be referenced through
/// an \c ElementPtr, which can be created using the factory functions
-/// \c Element::create() and \c Element::createFromString()
+/// \c Element::create() and \c Element::fromJSON()
///
/// Notes to developers: Element is a base class, implemented by a
/// specific subclass for each type (IntElement, BoolElement, etc).
@@ -164,6 +164,7 @@
virtual bool getValue(std::vector<ElementPtr>& t);
virtual bool getValue(std::map<std::string, ElementPtr>& t);
//@}
+
///
/// \name Exception-safe setters.
///
@@ -193,21 +194,26 @@
/// of bounds, this function throws an std::out_of_range exception.
/// \param i The position of the ElementPtr to return
virtual ElementPtr get(const int i);
+
/// Sets the ElementPtr at the given index. If the index is out
/// of bounds, this function throws an std::out_of_range exception.
/// \param i The position of the ElementPtr to set
/// \param element The ElementPtr to set at the position
virtual void set(const size_t i, ElementPtr element);
+
/// Adds an ElementPtr to the list
/// \param element The ElementPtr to add
virtual void add(ElementPtr element);
+
/// Removes the element at the given position. If the index is out
/// of nothing happens.
/// \param i The index of the element to remove.
virtual void remove(const int i);
+
/// Returns the number of elements in the list.
virtual size_t size();
//@}
+
/// \name MapElement functions
///
@@ -218,16 +224,20 @@
/// \param name The key of the Element to return
/// \return The ElementPtr at the given key
virtual ElementPtr get(const std::string& name);
+
/// Sets the ElementPtr at the given key
/// \param name The key of the Element to set
virtual void set(const std::string& name, ElementPtr element);
+
/// Remove the ElementPtr at the given key
/// \param name The key of the Element to remove
virtual void remove(const std::string& name);
+
/// Checks if there is data at the given key
/// \param name The key of the Element to remove
/// \return true if there is data at the key, false if not.
virtual bool contains(const std::string& name);
+
/// Recursively finds any data at the given identifier. The
/// identifier is a /-separated list of names of nested maps, with
/// the last name being the leaf that is returned.
@@ -242,12 +252,14 @@
/// null ElementPtr if it is not found, which can be checked with
/// Element::is_null(ElementPtr e).
virtual ElementPtr find(const std::string& identifier);
+
/// See \c Element::find()
/// \param identifier The identifier of the element to find
/// \param t Reference to store the resulting ElementPtr, if found.
/// \return true if the element was found, false if not.
virtual bool find(const std::string& identifier, ElementPtr& t);
//@}
+
/// \name Factory functions
@@ -276,9 +288,11 @@
/// \brief Creates an empty ListElement type ElementPtr.
static ElementPtr createList();
+
/// \brief Creates an empty MapElement type ElementPtr.
static ElementPtr createMap();
//@}
+
/// \name Compound factory functions
@@ -287,18 +301,21 @@
/// error, an exception of the type isc::data::ParseError is thrown.
//@{
- /// Creates an Element from the given string
+ /// Creates an Element from the given JSON string
/// \param in The string to parse the element from
/// \return An ElementPtr that contains the element(s) specified
/// in the given string.
- static ElementPtr createFromString(const std::string& in);
-
- /// Creates an Element from the given input stream
+ static ElementPtr fromJSON(const std::string& in);
+
+ /// Creates an Element from the given input stream containing JSON
+ /// formatted data.
+ ///
/// \param in The string to parse the element from
/// \return An ElementPtr that contains the element(s) specified
/// in the given input stream.
- static ElementPtr createFromString(std::istream& in) throw(ParseError);
- static ElementPtr createFromString(std::istream& in, const std::string& file_name) throw(ParseError);
+ static ElementPtr fromJSON(std::istream& in) throw(ParseError);
+ static ElementPtr fromJSON(std::istream& in, const std::string& file_name) throw(ParseError);
+
/// Creates an Element from the given input stream, where we keep
/// track of the location in the stream for error reporting.
///
@@ -310,7 +327,7 @@
/// \return An ElementPtr that contains the element(s) specified
/// in the given input stream.
// make this one private?
- static ElementPtr createFromString(std::istream& in, const std::string& file, int& line, int &pos) throw(ParseError);
+ static ElementPtr fromJSON(std::istream& in, const std::string& file, int& line, int &pos) throw(ParseError);
//@}
/// \name Wire format factory functions
@@ -323,7 +340,7 @@
/// Creates an Element from the wire format in the given
/// stringstream of the given length.
/// Since the wire format is JSON, thise is the same as
- /// createFromString, and could be removed.
+ /// fromJSON, and could be removed.
///
/// \param in The input stringstream.
/// \param length The length of the wireformat data in the stream
@@ -332,7 +349,7 @@
/// Creates an Element from the wire format in the given string
/// Since the wire format is JSON, thise is the same as
- /// createFromString, and could be removed.
+ /// fromJSON, and could be removed.
///
/// \param s The input string
/// \return ElementPtr with the data that is parsed.
Modified: branches/trac172/src/lib/cc/data_unittests.cc
==============================================================================
--- branches/trac172/src/lib/cc/data_unittests.cc (original)
+++ branches/trac172/src/lib/cc/data_unittests.cc Tue Jun 15 13:02:26 2010
@@ -65,14 +65,14 @@
BOOST_FOREACH(std::string s, sv) {
// also test << operator, which uses Element::str()
std::ostringstream stream;
- el = Element::createFromString(s);
+ el = Element::fromJSON(s);
stream << el;
EXPECT_EQ(stream.str(), s);
}
// some parse errors
try {
- Element::createFromString("{1}");
+ Element::fromJSON("{1}");
} catch (isc::data::ParseError pe) {
std::string s = std::string(pe.what());
EXPECT_EQ(s, "String expected in <string>:1:3");
@@ -80,7 +80,7 @@
sv.clear();
sv.push_back("{1}");
- //ElementPtr ep = Element::createFromString("\"aaa\nbbb\"err");
+ //ElementPtr ep = Element::fromJSON("\"aaa\nbbb\"err");
//std::cout << ep << std::endl;
sv.push_back("\n\nTru");
sv.push_back("{ \n \"aaa\nbbb\"err:");
@@ -89,19 +89,19 @@
sv.push_back("");
BOOST_FOREACH(std::string s, sv) {
- EXPECT_THROW(el = Element::createFromString(s), isc::data::ParseError);
+ EXPECT_THROW(el = Element::fromJSON(s), isc::data::ParseError);
}
// some json specific format tests, here the str() output is
// different from the string input
- EXPECT_EQ("100", Element::createFromString("1e2")->str());
- EXPECT_EQ("0.01", Element::createFromString("1e-2")->str());
- EXPECT_EQ("1.2", Element::createFromString("1.2")->str());
- EXPECT_EQ("1", Element::createFromString("1.0")->str());
- EXPECT_EQ("120", Element::createFromString("1.2e2")->str());
- EXPECT_EQ("100", Element::createFromString("1.0e2")->str());
- EXPECT_EQ("0.01", Element::createFromString("1.0e-2")->str());
- EXPECT_EQ("0.012", Element::createFromString("1.2e-2")->str());
+ EXPECT_EQ("100", Element::fromJSON("1e2")->str());
+ EXPECT_EQ("0.01", Element::fromJSON("1e-2")->str());
+ EXPECT_EQ("1.2", Element::fromJSON("1.2")->str());
+ EXPECT_EQ("1", Element::fromJSON("1.0")->str());
+ EXPECT_EQ("120", Element::fromJSON("1.2e2")->str());
+ EXPECT_EQ("100", Element::fromJSON("1.0e2")->str());
+ EXPECT_EQ("0.01", Element::fromJSON("1.0e-2")->str());
+ EXPECT_EQ("0.012", Element::fromJSON("1.2e-2")->str());
}
TEST(Element, create_and_value_throws) {
@@ -155,12 +155,12 @@
TEST(Element, ListElement) {
// this function checks the specific functions for ListElements
- ElementPtr el = Element::createFromString("[ 1, \"bar\", 3 ]");
+ ElementPtr el = Element::fromJSON("[ 1, \"bar\", 3 ]");
EXPECT_EQ(el->get(0)->intValue(), 1);
EXPECT_EQ(el->get(1)->stringValue(), "bar");
EXPECT_EQ(el->get(2)->intValue(), 3);
- el->set(0, Element::createFromString("\"foo\""));
+ el->set(0, Element::fromJSON("\"foo\""));
EXPECT_EQ(el->get(0)->stringValue(), "foo");
el->add(Element::create(47806));
@@ -188,7 +188,7 @@
TEST(Element, MapElement) {
// this function checks the specific functions for ListElements
- ElementPtr el = Element::createFromString("{ \"name\": \"foo\", \"value1\": \"bar\", \"value2\": { \"number\": 42 } }");
+ ElementPtr el = Element::fromJSON("{ \"name\": \"foo\", \"value1\": \"bar\", \"value2\": { \"number\": 42 } }");
ElementPtr el2;
EXPECT_EQ(el->get("name")->stringValue(), "foo");
@@ -220,7 +220,7 @@
"f123456789abcde");
EXPECT_EQ(255, long_maptag.length()); // check prerequisite
- el = Element::createFromString("{ \"" + long_maptag + "\": \"bar\"}");
+ el = Element::fromJSON("{ \"" + long_maptag + "\": \"bar\"}");
EXPECT_EQ("bar", el->find(long_maptag)->stringValue());
el = Element::createMap();
@@ -229,7 +229,7 @@
// A one-byte longer tag should trigger an exception.
long_maptag.push_back('f');
- EXPECT_THROW(Element::createFromString("{ \"" + long_maptag +
+ EXPECT_THROW(Element::fromJSON("{ \"" + long_maptag +
"\": \"bar\"}"),
ParseError);
@@ -246,14 +246,14 @@
EXPECT_EQ("false", Element::create(false)->toWire());
EXPECT_EQ("null", Element::create()->toWire());
EXPECT_EQ("\"a string\"", Element::create("a string")->toWire());
- EXPECT_EQ("[ \"a\", \"list\" ]", Element::createFromString("[ \"a\", \"list\" ]")->toWire());
- EXPECT_EQ("{ \"a\": \"map\" }", Element::createFromString("{ \"a\": \"map\" }")->toWire());
+ EXPECT_EQ("[ \"a\", \"list\" ]", Element::fromJSON("[ \"a\", \"list\" ]")->toWire());
+ EXPECT_EQ("{ \"a\": \"map\" }", Element::fromJSON("{ \"a\": \"map\" }")->toWire());
EXPECT_EQ("1", Element::fromWire("1")->str());
}
ElementPtr efs(const std::string& str) {
- return Element::createFromString(str);
+ return Element::fromJSON(str);
}
TEST(Element, equals) {
@@ -314,45 +314,45 @@
removeIdentical(a, b);
EXPECT_TRUE(a == c);
- a = Element::createFromString("{ \"a\": 1 }");
- b = Element::createFromString("{ \"a\": 1 }");
+ a = Element::fromJSON("{ \"a\": 1 }");
+ b = Element::fromJSON("{ \"a\": 1 }");
c = Element::createMap();
removeIdentical(a, b);
EXPECT_TRUE(a == c);
- a = Element::createFromString("{ \"a\": 1, \"b\": [ 1, 2 ] }");
+ a = Element::fromJSON("{ \"a\": 1, \"b\": [ 1, 2 ] }");
b = Element::createMap();
- c = Element::createFromString("{ \"a\": 1, \"b\": [ 1, 2 ] }");
- removeIdentical(a, b);
- EXPECT_TRUE(a == c);
-
- a = Element::createFromString("{ \"a\": 1, \"b\": [ 1, 2 ] }");
- b = Element::createFromString("{ \"a\": 1, \"b\": [ 1, 2 ] }");
+ c = Element::fromJSON("{ \"a\": 1, \"b\": [ 1, 2 ] }");
+ removeIdentical(a, b);
+ EXPECT_TRUE(a == c);
+
+ a = Element::fromJSON("{ \"a\": 1, \"b\": [ 1, 2 ] }");
+ b = Element::fromJSON("{ \"a\": 1, \"b\": [ 1, 2 ] }");
c = Element::createMap();
removeIdentical(a, b);
EXPECT_TRUE(a == c);
- a = Element::createFromString("{ \"a\": 1, \"b\": [ 1, 2 ] }");
- b = Element::createFromString("{ \"a\": 1, \"b\": [ 1, 3 ] }");
- c = Element::createFromString("{ \"b\": [ 1, 2 ] }");
- removeIdentical(a, b);
- EXPECT_TRUE(a == c);
-
- a = Element::createFromString("{ \"a\": { \"b\": \"c\" } }");
+ a = Element::fromJSON("{ \"a\": 1, \"b\": [ 1, 2 ] }");
+ b = Element::fromJSON("{ \"a\": 1, \"b\": [ 1, 3 ] }");
+ c = Element::fromJSON("{ \"b\": [ 1, 2 ] }");
+ removeIdentical(a, b);
+ EXPECT_TRUE(a == c);
+
+ a = Element::fromJSON("{ \"a\": { \"b\": \"c\" } }");
b = Element::createMap();
- c = Element::createFromString("{ \"a\": { \"b\": \"c\" } }");
- removeIdentical(a, b);
- EXPECT_TRUE(a == c);
-
- a = Element::createFromString("{ \"a\": { \"b\": \"c\" } }");
- b = Element::createFromString("{ \"a\": { \"b\": \"c\" } }");
+ c = Element::fromJSON("{ \"a\": { \"b\": \"c\" } }");
+ removeIdentical(a, b);
+ EXPECT_TRUE(a == c);
+
+ a = Element::fromJSON("{ \"a\": { \"b\": \"c\" } }");
+ b = Element::fromJSON("{ \"a\": { \"b\": \"c\" } }");
c = Element::createMap();
removeIdentical(a, b);
EXPECT_TRUE(a == c);
- a = Element::createFromString("{ \"a\": { \"b\": \"c\" } }");
- b = Element::createFromString("{ \"a\": { \"b\": \"d\" } }");
- c = Element::createFromString("{ \"a\": { \"b\": \"c\" } }");
+ a = Element::fromJSON("{ \"a\": { \"b\": \"c\" } }");
+ b = Element::fromJSON("{ \"a\": { \"b\": \"d\" } }");
+ c = Element::fromJSON("{ \"a\": { \"b\": \"c\" } }");
removeIdentical(a, b);
EXPECT_TRUE(a == c);
}
@@ -365,25 +365,25 @@
merge(a, b);
EXPECT_TRUE(a == c);
- a = Element::createFromString("1");
+ a = Element::fromJSON("1");
b = Element::createMap();
EXPECT_THROW(merge(a, b), TypeError);
a = Element::createMap();
- b = Element::createFromString("{ \"a\": 1 }");
- c = Element::createFromString("{ \"a\": 1 }");
+ b = Element::fromJSON("{ \"a\": 1 }");
+ c = Element::fromJSON("{ \"a\": 1 }");
merge(a, b);
EXPECT_TRUE(a == c);
- a = Element::createFromString("{ \"a\": 1 }");
- b = Element::createFromString("{ \"a\": 2 }");
- c = Element::createFromString("{ \"a\": 2 }");
+ a = Element::fromJSON("{ \"a\": 1 }");
+ b = Element::fromJSON("{ \"a\": 2 }");
+ c = Element::fromJSON("{ \"a\": 2 }");
merge(a, b);
EXPECT_TRUE(a == c);
- a = Element::createFromString("{ \"a\": { \"b\": \"c\" } }");
- b = Element::createFromString("{ \"a\": { \"b\": \"d\" } }");
- c = Element::createFromString("{ \"a\": { \"b\": \"d\" } }");
+ a = Element::fromJSON("{ \"a\": { \"b\": \"c\" } }");
+ b = Element::fromJSON("{ \"a\": { \"b\": \"d\" } }");
+ c = Element::fromJSON("{ \"a\": { \"b\": \"d\" } }");
merge(a, b);
EXPECT_TRUE(a == c);
Modified: branches/trac172/src/lib/cc/session.cc
==============================================================================
--- branches/trac172/src/lib/cc/session.cc (original)
+++ branches/trac172/src/lib/cc/session.cc Tue Jun 15 13:02:26 2010
@@ -314,7 +314,7 @@
// send a request for our local name, and wait for a response
//
ElementPtr get_lname_msg =
- Element::createFromString("{ \"type\": \"getlname\" }");
+ Element::fromJSON("{ \"type\": \"getlname\" }");
sendmsg(get_lname_msg);
ElementPtr routing, msg;
Modified: branches/trac172/src/lib/config/ccsession.cc
==============================================================================
--- branches/trac172/src/lib/config/ccsession.cc (original)
+++ branches/trac172/src/lib/config/ccsession.cc Tue Jun 15 13:02:26 2010
@@ -56,7 +56,7 @@
ElementPtr
createAnswer()
{
- ElementPtr answer = Element::createFromString("{\"result\": [] }");
+ ElementPtr answer = Element::fromJSON("{\"result\": [] }");
ElementPtr answer_content = answer->get("result");
answer_content->add(Element::create(0));
return answer;
@@ -68,7 +68,7 @@
if (rcode != 0 && (!arg || arg->getType() != Element::string)) {
isc_throw(CCSessionError, "Bad or no argument for rcode != 0");
}
- ElementPtr answer = Element::createFromString("{\"result\": [] }");
+ ElementPtr answer = Element::fromJSON("{\"result\": [] }");
ElementPtr answer_content = answer->get("result");
answer_content->add(Element::create(rcode));
answer_content->add(arg);
@@ -78,7 +78,7 @@
ElementPtr
createAnswer(const int rcode, const std::string& arg)
{
- ElementPtr answer = Element::createFromString("{\"result\": [] }");
+ ElementPtr answer = Element::fromJSON("{\"result\": [] }");
ElementPtr answer_content = answer->get("result");
answer_content->add(Element::create(rcode));
answer_content->add(Element::create(arg));
@@ -252,10 +252,10 @@
std::cerr << "[" << module_name_ << "] Error in specification: " << answer << std::endl;
}
- setLocalConfig(Element::createFromString("{}"));
+ setLocalConfig(Element::fromJSON("{}"));
// get any stored configuration from the manager
if (config_handler_) {
- ElementPtr cmd = Element::createFromString("{ \"command\": [\"get_config\", {\"module_name\":\"" + module_name_ + "\"} ] }");
+ ElementPtr cmd = Element::fromJSON("{ \"command\": [\"get_config\", {\"module_name\":\"" + module_name_ + "\"} ] }");
seq = session_.group_sendmsg(cmd, "ConfigManager");
session_.group_recvmsg(env, answer, false, seq);
ElementPtr new_config = parseAnswer(rcode, answer);
@@ -363,7 +363,7 @@
session_.subscribe(module_name);
// Get the current configuration values for that module
- ElementPtr cmd = Element::createFromString("{ \"command\": [\"get_config\", {\"module_name\":\"" + module_name + "\"} ] }");
+ ElementPtr cmd = Element::fromJSON("{ \"command\": [\"get_config\", {\"module_name\":\"" + module_name + "\"} ] }");
ElementPtr env, answer;
int rcode;
Modified: branches/trac172/src/lib/config/module_spec.cc
==============================================================================
--- branches/trac172/src/lib/config/module_spec.cc (original)
+++ branches/trac172/src/lib/config/module_spec.cc Tue Jun 15 13:02:26 2010
@@ -242,7 +242,7 @@
throw ModuleSpecError(errs.str());
}
- ElementPtr module_spec_element = Element::createFromString(file, file_name);
+ ElementPtr module_spec_element = Element::fromJSON(file, file_name);
if (module_spec_element->contains("module_spec")) {
return ModuleSpec(module_spec_element->get("module_spec"), check);
} else {
@@ -253,7 +253,7 @@
ModuleSpec
moduleSpecFromFile(std::ifstream& in, const bool check)
throw(ParseError, ModuleSpecError) {
- ElementPtr module_spec_element = Element::createFromString(in);
+ ElementPtr module_spec_element = Element::fromJSON(in);
if (module_spec_element->contains("module_spec")) {
return ModuleSpec(module_spec_element->get("module_spec"), check);
} else {
Modified: branches/trac172/src/lib/config/tests/ccsession_unittests.cc
==============================================================================
--- branches/trac172/src/lib/config/tests/ccsession_unittests.cc (original)
+++ branches/trac172/src/lib/config/tests/ccsession_unittests.cc Tue Jun 15 13:02:26 2010
@@ -37,7 +37,7 @@
static ElementPtr
el(const std::string& str)
{
- return Element::createFromString(str);
+ return Element::fromJSON(str);
}
// upon creation of a ModuleCCSession, the class
Modified: branches/trac172/src/lib/config/tests/config_data_unittests.cc
==============================================================================
--- branches/trac172/src/lib/config/tests/config_data_unittests.cc (original)
+++ branches/trac172/src/lib/config/tests/config_data_unittests.cc Tue Jun 15 13:02:26 2010
@@ -87,8 +87,8 @@
ConfigData cd = ConfigData(spec2);
bool is_default;
- ElementPtr my_config = Element::createFromString("{ \"item1\": 2 }");
- ElementPtr my_config2 = Element::createFromString("{ \"item6\": { \"value1\": \"a\" } }");
+ ElementPtr my_config = Element::fromJSON("{ \"item1\": 2 }");
+ ElementPtr my_config2 = Element::fromJSON("{ \"item6\": { \"value1\": \"a\" } }");
EXPECT_EQ("{ }", cd.getValue("item6")->str());
@@ -108,11 +108,11 @@
ConfigData cd = ConfigData(spec2);
EXPECT_EQ("{ }", cd.getLocalConfig()->str());
- ElementPtr my_config = Element::createFromString("{ \"item1\": 2 }");
+ ElementPtr my_config = Element::fromJSON("{ \"item1\": 2 }");
cd.setLocalConfig(my_config);
EXPECT_EQ("{ \"item1\": 2 }", cd.getLocalConfig()->str());
- ElementPtr my_config2 = Element::createFromString("{ \"item6\": { \"value1\": \"a\" } }");
+ ElementPtr my_config2 = Element::fromJSON("{ \"item6\": { \"value1\": \"a\" } }");
cd.setLocalConfig(my_config2);
EXPECT_EQ("{ \"item6\": { \"value1\": \"a\" } }", cd.getLocalConfig()->str());
}
@@ -131,10 +131,10 @@
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());
- ElementPtr my_config = Element::createFromString("{ \"item1\": 2 }");
+ 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());
- ElementPtr my_config2 = Element::createFromString("{ \"item6\": { \"value1\": \"a\" } }");
+ 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());
}
Modified: branches/trac172/src/lib/config/tests/module_spec_unittests.cc
==============================================================================
--- branches/trac172/src/lib/config/tests/module_spec_unittests.cc (original)
+++ branches/trac172/src/lib/config/tests/module_spec_unittests.cc Tue Jun 15 13:02:26 2010
@@ -139,7 +139,7 @@
std::ifstream data_file;
data_file.open(specfile(data_file_name).c_str());
- ElementPtr data = Element::createFromString(data_file, data_file_name);
+ ElementPtr data = Element::fromJSON(data_file, data_file_name);
data_file.close();
return dd.validate_config(data);
@@ -151,7 +151,7 @@
std::ifstream data_file;
data_file.open(specfile(data_file_name).c_str());
- ElementPtr data = Element::createFromString(data_file, data_file_name);
+ ElementPtr data = Element::fromJSON(data_file, data_file_name);
data_file.close();
return dd.validate_config(data, true, errors);
Modified: branches/trac172/src/lib/datasrc/tests/datasrc_unittest.cc
==============================================================================
--- branches/trac172/src/lib/datasrc/tests/datasrc_unittest.cc (original)
+++ branches/trac172/src/lib/datasrc/tests/datasrc_unittest.cc Tue Jun 15 13:02:26 2010
@@ -49,7 +49,7 @@
using namespace isc::data;
namespace {
-const ElementPtr SQLITE_DBFILE_EXAMPLE = Element::createFromString(
+const ElementPtr SQLITE_DBFILE_EXAMPLE = Element::fromJSON(
"{ \"database_file\": \"" TEST_DATA_DIR "/example.org.sqlite3\"}");
class DataSrcTest : public ::testing::Test {
Modified: branches/trac172/src/lib/datasrc/tests/sqlite3_unittest.cc
==============================================================================
--- branches/trac172/src/lib/datasrc/tests/sqlite3_unittest.cc (original)
+++ branches/trac172/src/lib/datasrc/tests/sqlite3_unittest.cc Tue Jun 15 13:02:26 2010
@@ -43,22 +43,22 @@
using namespace isc::data;
namespace {
-ElementPtr SQLITE_DBFILE_EXAMPLE = Element::createFromString(
+ElementPtr SQLITE_DBFILE_EXAMPLE = Element::fromJSON(
"{ \"database_file\": \"" TEST_DATA_DIR "/test.sqlite3\"}");
-ElementPtr SQLITE_DBFILE_EXAMPLE2 = Element::createFromString(
+ElementPtr SQLITE_DBFILE_EXAMPLE2 = Element::fromJSON(
"{ \"database_file\": \"" TEST_DATA_DIR "/example2.com.sqlite3\"}");
-ElementPtr SQLITE_DBFILE_EXAMPLE_ROOT = Element::createFromString(
+ElementPtr SQLITE_DBFILE_EXAMPLE_ROOT = Element::fromJSON(
"{ \"database_file\": \"" TEST_DATA_DIR "/test-root.sqlite3\"}");
-ElementPtr SQLITE_DBFILE_BROKENDB = Element::createFromString(
+ElementPtr SQLITE_DBFILE_BROKENDB = Element::fromJSON(
"{ \"database_file\": \"" TEST_DATA_DIR "/brokendb.sqlite3\"}");
-ElementPtr SQLITE_DBFILE_MEMORY = Element::createFromString(
+ElementPtr SQLITE_DBFILE_MEMORY = Element::fromJSON(
"{ \"database_file\": \":memory:\"}");
// The following file must be non existent and must be non"creatable";
// the sqlite3 library will try to create a new DB file if it doesn't exist,
// so to test a failure case the create operation should also fail.
// The "nodir", a non existent directory, is inserted for this purpose.
-ElementPtr SQLITE_DBFILE_NOTEXIST = Element::createFromString(
+ElementPtr SQLITE_DBFILE_NOTEXIST = Element::fromJSON(
"{ \"database_file\": \"" TEST_DATA_DIR "/nodir/notexist\"}");
const string sigdata_common(" 20100322084538 20100220084538 "
More information about the bind10-changes
mailing list