src: configuration file parsing
used boost::property_tree::info_parser for parsing nlsr's configuration file and
changed configuration command style to info command style. Removed tokenizer from
nlsr
Refs: #1542
Change-Id: If017ddd7eef5caa59b33940bfc27a71aa4de266b
diff --git a/tests/test-conf-file-processor.cpp b/tests/test-conf-file-processor.cpp
index 8ec3a4e..576b87f 100644
--- a/tests/test-conf-file-processor.cpp
+++ b/tests/test-conf-file-processor.cpp
@@ -2,7 +2,7 @@
* Copyright (C) 2014 Regents of the University of Memphis.
* See COPYING for copyright and distribution information.
*/
-
+#include <fstream>
#include "conf-file-processor.hpp"
#include "nlsr.hpp"
#include <boost/test/unit_test.hpp>
@@ -18,16 +18,47 @@
Nlsr nlsr1;
const std::string CONFIG =
- "network ndn\n"
- "site-name memphis.edu\n"
- "router-name cs/macbook\n\n"
- "ndnneighbor /ndn/memphis.edu/cs/maia 7\n"
- "link-cost /ndn/memphis.edu/cs/maia 30\n"
- "ndnneighbor /ndn/memphis.edu/cs/pollux 10\n"
- "link-cost /ndn/memphis.edu/cs/pollux 25\n\n"
- "ndnname /ndn/memphis.edu/cs/macbook/name1\n"
- "ndnname /ndn/memphis.edu/cs/macbook/name2\n\n\n"
- ;
+ "general\n"
+ "{\n"
+ " network /ndn/\n"
+ " site /memphis.edu/\n"
+ " router /cs/pollux/\n"
+ " lsa-refresh-time 1800\n"
+ " log-level INFO\n"
+ "}\n\n"
+ "neighbors\n"
+ "{\n"
+ " hello-retries 3\n"
+ " hello-time-out 1\n"
+ " hello-interval 60\n\n"
+ " neighbor\n"
+ " {\n"
+ " name /ndn/memphis.edu/cs/castor\n"
+ " face-id 15\n"
+ " link-cost 20\n"
+ " }\n\n"
+ " neighbor\n"
+ " {\n"
+ " name /ndn/memphis.edu/cs/mira\n"
+ " face-id 17\n"
+ " link-cost 30\n"
+ " }\n"
+ "}\n\n"
+ "hyperbolic\n"
+ "{\n"
+ "state off\n"
+ "radius 123.456\n"
+ "angle 1.45\n"
+ "}\n\n"
+ "fib\n"
+ "{\n"
+ " max-faces-per-prefix 3\n"
+ "}\n\n"
+ "advertising\n"
+ "{\n"
+ "prefix /ndn/edu/memphis/cs/netlab\n"
+ "prefix /ndn/edu/memphis/sports/basketball\n"
+ "}\n";
std::ofstream config;
config.open("unit-test-nlsr.conf");
@@ -40,12 +71,12 @@
cfp1.processConfFile();
- BOOST_CHECK(nlsr1.getAdjacencyList().isNeighbor("/ndn/memphis.edu/cs/maia"));
+ BOOST_CHECK(nlsr1.getAdjacencyList().isNeighbor("/ndn/memphis.edu/cs/mira"));
BOOST_CHECK_EQUAL(
- nlsr1.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/maia").getName(),
- "/ndn/memphis.edu/cs/maia");
+ nlsr1.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/mira").getName(),
+ "/ndn/memphis.edu/cs/mira");
BOOST_CHECK_EQUAL(
- nlsr1.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/maia").getLinkCost(),
+ nlsr1.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/mira").getLinkCost(),
30);
BOOST_CHECK_EQUAL(nlsr1.getNamePrefixList().getSize(), 2);
diff --git a/tests/test-conf-parameter.cpp b/tests/test-conf-parameter.cpp
index 95ae19e..d9a38f9 100644
--- a/tests/test-conf-parameter.cpp
+++ b/tests/test-conf-parameter.cpp
@@ -28,8 +28,6 @@
cp1.setNetwork(NETWORK);
- cp1.setRootKeyPrefix("adminRootKey");
-
cp1.setInterestRetryNumber(2);
cp1.setInterestResendTime(1000);
@@ -40,29 +38,12 @@
cp1.setMaxFacesPerPrefix(50);
- cp1.setLogDir("log");
-
- cp1.setCertDir("cert");
-
- cp1.setSeqFileDir("ssfd");
-
- cp1.setDetailedLogging(1);
-
- cp1.setDebugging(1);
-
- cp1.setIsHyperbolicCalc(1);
+ cp1.setHyperbolicState(1);
cp1.setCorR(2.5);
cp1.setCorTheta(102.5);
- cp1.setTunnelType(2);
-
- const string a = "csp";
- cp1.setChronosyncSyncPrefix(a);
-
- cp1.setChronosyncLsaPrefix("cla");
-
cp1.setInfoInterestInterval(3);
BOOST_CHECK_EQUAL(cp1.getRouterName(), "router1");
@@ -75,8 +56,6 @@
BOOST_CHECK_EQUAL(cp1.getRouterPrefix(), "/ATT/memphis/router1");
- BOOST_CHECK_EQUAL(cp1.getRootKeyPrefix(), "adminRootKey");
-
BOOST_CHECK_EQUAL(cp1.getInterestRetryNumber(), (uint32_t)2);
BOOST_CHECK_EQUAL(cp1.getInterestResendTime(), 1000);
@@ -87,26 +66,10 @@
BOOST_CHECK_EQUAL(cp1.getMaxFacesPerPrefix(), 50);
- BOOST_CHECK_EQUAL(cp1.getLogDir(), "log");
-
- BOOST_CHECK_EQUAL(cp1.getCertDir(), "cert");
-
- BOOST_CHECK_EQUAL(cp1.getSeqFileDir(), "ssfd");
-
- BOOST_CHECK_EQUAL(cp1.getDetailedLogging(), 1);
-
- BOOST_CHECK_EQUAL(cp1.getDebugging(), 1);
-
- BOOST_CHECK_EQUAL(cp1.getIsHyperbolicCalc(), 1);
+ BOOST_CHECK_EQUAL(cp1.getHyperbolicState(), 1);
BOOST_CHECK_CLOSE(cp1.getCorTheta(), 102.5, 0.0001);
- BOOST_CHECK_EQUAL(cp1.getTunnelType(), 2);
-
- BOOST_CHECK_EQUAL(cp1.getChronosyncSyncPrefix(), "csp");
-
- BOOST_CHECK_EQUAL(cp1.getChronosyncLsaPrefix(), "cla");
-
BOOST_CHECK_EQUAL(cp1.getInfoInterestInterval(), 3);
}
diff --git a/tests/test-lsdb.cpp b/tests/test-lsdb.cpp
index 022efa7..a72c55e 100644
--- a/tests/test-lsdb.cpp
+++ b/tests/test-lsdb.cpp
@@ -28,7 +28,7 @@
npl1.insert(s1);
npl1.insert(s2);
-//For NameLsa lsType is 1.
+//For NameLsa lsType is name.
//12 is seqNo, randomly generated.
//1800 is the default life time.
NameLsa nlsa1("router1", std::string("name"), 12, 1800, npl1);
diff --git a/tests/test-nexthop.cpp b/tests/test-nexthop.cpp
index 0cdf23c..fb6a8fb 100644
--- a/tests/test-nexthop.cpp
+++ b/tests/test-nexthop.cpp
@@ -16,11 +16,11 @@
{
NextHop np1;
- np1.setConnectingFace(1);
+ np1.setConnectingFaceUri("udp://test/uri");
np1.setRouteCost(10.5);
- BOOST_CHECK_EQUAL(np1.getConnectingFace(), (uint32_t)1);
+ BOOST_CHECK_EQUAL(np1.getConnectingFaceUri(), "udp://test/uri");
BOOST_CHECK_CLOSE(np1.getRouteCost(), 10.5, 0.0001);
}
diff --git a/tests/test-tokenizer.cpp b/tests/test-tokenizer.cpp
deleted file mode 100644
index b3a8234..0000000
--- a/tests/test-tokenizer.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright (C) 2014 Regents of the University of Memphis.
- * See COPYING for copyright and distribution information.
- */
-
-#include "utility/tokenizer.hpp"
-#include <boost/test/unit_test.hpp>
-
-namespace nlsr {
-
-namespace test {
-
-BOOST_AUTO_TEST_SUITE(TestTokenizer)
-
-BOOST_AUTO_TEST_CASE(TokenizerBasic)
-{
- Tokenizer token1("/ndn/memphis.edu/cs", "/");
- Tokenizer token2("/ndn/memphis.edu/cs", "/");
-
- Tokenizer token3("/test/hello");
-
- BOOST_CHECK(token1.getFirstToken() == token2.getFirstToken());
-
- BOOST_CHECK_EQUAL(token1.getRestOfLine(), token2.getRestOfLine());
-
- BOOST_CHECK(token1.getFirstToken() != token3.getFirstToken());
-
- BOOST_CHECK(token1.getRestOfLine() != token3.getRestOfLine());
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-} //namespace test
-} //namespace nlsr