Browse Source

rename createFromString() to fromJSON()

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac172@2113 e5f2f494-b856-4b98-b285-d166d9295462
Jelte Jansen 15 years ago
parent
commit
b763a8e027

+ 1 - 1
src/bin/auth/tests/auth_srv_unittest.cc

@@ -236,7 +236,7 @@ updateConfig(AuthSrv* server, const char* const dbfile,
              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"));
 

+ 12 - 12
src/lib/cc/data.cc

@@ -261,7 +261,7 @@ Element::createMap() {
 
 
 //
-// helper functions for createFromString factory
+// helper functions for fromJSON factory
 //
 namespace {
 bool
@@ -477,7 +477,7 @@ from_stringstream_list(std::istream &in, const std::string& file, int& line, int
     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 @@ from_stringstream_map(std::istream &in, const std::string& file, int& line,
             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 @@ from_stringstream_map(std::istream &in, const std::string& file, int& line,
 }
 
 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);
+    return fromJSON(in, "<istream>", line, pos);
 }
 
 ElementPtr
-Element::createFromString(std::istream& in, const std::string& file_name) throw(ParseError)
+Element::fromJSON(std::istream& in, const std::string& file_name) throw(ParseError)
 {
     int line = 1, pos = 1;
-    return createFromString(in, file_name, line, pos);
+    return fromJSON(in, file_name, line, pos);
 }
 
 ElementPtr
-Element::createFromString(std::istream &in, const std::string& file, int& line, int& pos) throw(ParseError)
+Element::fromJSON(std::istream &in, const std::string& file, int& line, int& pos) throw(ParseError)
 {
     char c = 0;
     ElementPtr element;
@@ -602,10 +602,10 @@ Element::createFromString(std::istream &in, const std::string& file, int& line,
 }
 
 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 @@ Element::fromWire(const std::string& s) {
     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 @@ Element::fromWire(std::stringstream& in, int length) {
     //}
     //length -= 4;
     int line = 0, pos = 0;
-    return createFromString(in, "<wire>", line, pos);
+    return fromJSON(in, "<wire>", line, pos);
 }
 
 void

+ 26 - 9
src/lib/cc/data.h

@@ -75,7 +75,7 @@ private:
 ///
 /// 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 @@ public:
     virtual bool getValue(std::vector<ElementPtr>& t);
     virtual bool getValue(std::map<std::string, ElementPtr>& t);
     //@}
+
     ///
     /// \name Exception-safe setters.
     ///
@@ -193,21 +194,26 @@ public:
     /// 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 @@ public:
     /// \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,6 +252,7 @@ public:
     /// 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.
@@ -249,6 +260,7 @@ public:
     virtual bool find(const std::string& identifier, ElementPtr& t);
     //@}
 
+
     /// \name Factory functions
     
     // TODO: should we move all factory functions to a different class
@@ -276,10 +288,12 @@ public:
 
     /// \brief Creates an empty ListElement type ElementPtr.
     static ElementPtr createList();
+
     /// \brief Creates an empty MapElement type ElementPtr.
     static ElementPtr createMap();
     //@}
 
+
     /// \name Compound factory functions
 
     /// \brief These functions will parse the given string (JSON)
@@ -287,18 +301,21 @@ public:
     /// 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);
+    static ElementPtr fromJSON(const std::string& in);
 
-    /// Creates an Element from the given input stream
+    /// 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 @@ public:
     /// \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 @@ public:
     /// 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 @@ public:
 
     /// 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.

+ 45 - 45
src/lib/cc/data_unittests.cc

@@ -65,14 +65,14 @@ TEST(Element, from_and_to_str) {
     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 @@ TEST(Element, from_and_to_str) {
     
     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 @@ TEST(Element, from_and_to_str) {
     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, create_and_value_throws) {
 
 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 @@ const string long_maptag("0123456789abcdef1123456789abcdef2123456789abcdef"
 
 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 @@ TEST(Element, MapElement) {
                        "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 @@ TEST(Element, MapElement) {
 
     // 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 @@ TEST(Element, to_and_from_wire) {
     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 @@ TEST(Element, removeIdentical) {
     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 ] }");
+    c = Element::fromJSON("{ \"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 ] }");
+    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 ] }");
+    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::createFromString("{ \"a\": { \"b\": \"c\" } }");
+    a = Element::fromJSON("{ \"a\": { \"b\": \"c\" } }");
     b = Element::createMap();
-    c = Element::createFromString("{ \"a\": { \"b\": \"c\" } }");
+    c = Element::fromJSON("{ \"a\": { \"b\": \"c\" } }");
     removeIdentical(a, b);
     EXPECT_TRUE(a == c);
 
-    a = Element::createFromString("{ \"a\": { \"b\": \"c\" } }");
-    b = Element::createFromString("{ \"a\": { \"b\": \"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 @@ TEST(Element, merge)
     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);
 

+ 1 - 1
src/lib/cc/session.cc

@@ -314,7 +314,7 @@ Session::establish(const char* socket_file) {
     // 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;

+ 6 - 6
src/lib/config/ccsession.cc

@@ -56,7 +56,7 @@ namespace config {
 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 @@ createAnswer(const int rcode, const ElementPtr arg)
     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 @@ createAnswer(const int rcode, const ElementPtr arg)
 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 @@ ModuleCCSession::init(
         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 @@ ModuleCCSession::addRemoteConfig(const std::string& spec_file_name)
     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;
     

+ 2 - 2
src/lib/config/module_spec.cc

@@ -242,7 +242,7 @@ moduleSpecFromFile(const std::string& file_name, const bool check)
         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 @@ moduleSpecFromFile(const std::string& file_name, const bool check)
 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 {

+ 1 - 1
src/lib/config/tests/ccsession_unittests.cc

@@ -37,7 +37,7 @@ std::string ccspecfile(const std::string name) {
 static ElementPtr
 el(const std::string& str)
 {
-    return Element::createFromString(str);
+    return Element::fromJSON(str);
 }
 
 // upon creation of a ModuleCCSession, the class

+ 6 - 6
src/lib/config/tests/config_data_unittests.cc

@@ -87,8 +87,8 @@ TEST(ConfigData, setLocalConfig) {
     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 @@ TEST(ConfigData, getLocalConfig) {
     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 @@ TEST(ConfigData, getFullConfig) {
     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());
 }

+ 2 - 2
src/lib/config/tests/module_spec_unittests.cc

@@ -139,7 +139,7 @@ data_test(ModuleSpec dd, const std::string& data_file_name)
     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 @@ data_test_with_errors(ModuleSpec dd, const std::string& data_file_name, ElementP
     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);

+ 1 - 1
src/lib/datasrc/tests/datasrc_unittest.cc

@@ -49,7 +49,7 @@ using namespace isc::datasrc;
 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 {

+ 6 - 6
src/lib/datasrc/tests/sqlite3_unittest.cc

@@ -43,22 +43,22 @@ using namespace isc::datasrc;
 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 "