src: decouple classes from Nlsr object
refs: #1952, #2803, #3960, #4288
Change-Id: Ibe3ac3820f11e8107ee4b13e510d53c27467a6cb
diff --git a/tests/test-conf-file-processor.cpp b/tests/test-conf-file-processor.cpp
index c8bbb2f..9cff6f9 100644
--- a/tests/test-conf-file-processor.cpp
+++ b/tests/test-conf-file-processor.cpp
@@ -21,7 +21,6 @@
#include "conf-file-processor.hpp"
#include "test-common.hpp"
-#include "nlsr.hpp"
#include <fstream>
@@ -109,6 +108,8 @@
" prefix /ndn/edu/memphis/sports/basketball\n"
"}\n";
+// NEED TO TEST SECURITY SECTION SUCH AS LOADING CERTIFICATE
+
const std::string CONFIG_LINK_STATE = SECTION_GENERAL + SECTION_NEIGHBORS +
SECTION_HYPERBOLIC_OFF + SECTION_FIB + SECTION_ADVERTISING;
@@ -124,8 +125,7 @@
public:
ConfFileProcessorFixture()
: face(m_ioService, m_keyChain)
- , nlsr(m_ioService, m_scheduler, face, m_keyChain)
- , CONFIG_FILE("unit-test-nlsr.conf")
+ , conf(face, "unit-test-nlsr.conf")
{
}
@@ -142,7 +142,7 @@
config << confString;
config.close();
- ConfFileProcessor processor(nlsr, CONFIG_FILE);
+ ConfFileProcessor processor(conf);
return processor.processConfFile();
}
@@ -154,10 +154,7 @@
public:
ndn::util::DummyClientFace face;
- Nlsr nlsr;
-
-private:
- const std::string CONFIG_FILE;
+ ConfParameter conf;
};
BOOST_FIXTURE_TEST_SUITE(TestConfFileProcessor, ConfFileProcessorFixture)
@@ -165,7 +162,6 @@
BOOST_AUTO_TEST_CASE(LinkState)
{
processConfigurationString(CONFIG_LINK_STATE);
- ConfParameter& conf = nlsr.getConfParameter();
conf.buildRouterPrefix();
// General
@@ -173,7 +169,7 @@
BOOST_CHECK_EQUAL(conf.getSiteName(), "/memphis.edu/");
BOOST_CHECK_EQUAL(conf.getRouterName(), "/cs/pollux/");
BOOST_CHECK_EQUAL(conf.getRouterPrefix(), "/ndn/memphis.edu/cs/pollux/");
- BOOST_CHECK_EQUAL(conf.getChronosyncPrefix(), ndn::Name("/localhop/ndn/nlsr/sync").appendVersion(ConfParameter::SYNC_VERSION));
+ BOOST_CHECK_EQUAL(conf.getSyncPrefix(), ndn::Name("/localhop/ndn/nlsr/sync").appendVersion(ConfParameter::SYNC_VERSION));
BOOST_CHECK_EQUAL(conf.getLsaPrefix(), "/localhop/ndn/nlsr/LSA");
BOOST_CHECK_EQUAL(conf.getLsaRefreshTime(), 1800);
BOOST_CHECK_EQUAL(conf.getSyncProtocol(), SYNC_PROTOCOL_PSYNC);
@@ -190,16 +186,16 @@
BOOST_CHECK_EQUAL(conf.getAdjLsaBuildInterval(), 3);
BOOST_CHECK_EQUAL(conf.getFirstHelloInterval(), 6);
- BOOST_CHECK(nlsr.getAdjacencyList().isNeighbor("/ndn/memphis.edu/cs/mira"));
- BOOST_CHECK(nlsr.getAdjacencyList().isNeighbor("/ndn/memphis.edu/cs/castor"));
- BOOST_CHECK(!nlsr.getAdjacencyList().isNeighbor("/ndn/memphis.edu/cs/fail"));
+ BOOST_CHECK(conf.getAdjacencyList().isNeighbor("/ndn/memphis.edu/cs/mira"));
+ BOOST_CHECK(conf.getAdjacencyList().isNeighbor("/ndn/memphis.edu/cs/castor"));
+ BOOST_CHECK(!conf.getAdjacencyList().isNeighbor("/ndn/memphis.edu/cs/fail"));
- Adjacent mira = nlsr.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/mira");
+ Adjacent mira = conf.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/mira");
BOOST_CHECK_EQUAL(mira.getName(), "/ndn/memphis.edu/cs/mira");
BOOST_CHECK_EQUAL(mira.getLinkCost(), 30);
BOOST_CHECK_EQUAL(mira.getFaceUri().toString(), "udp4://10.0.0.2:6363");
- Adjacent castor = nlsr.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/castor");
+ Adjacent castor = conf.getAdjacencyList().getAdjacent("/ndn/memphis.edu/cs/castor");
BOOST_CHECK_EQUAL(castor.getName(), "/ndn/memphis.edu/cs/castor");
BOOST_CHECK_EQUAL(castor.getLinkCost(), 20);
BOOST_CHECK_EQUAL(castor.getFaceUri().toString(), "udp4://10.0.0.1:6363");
@@ -212,7 +208,7 @@
BOOST_CHECK_EQUAL(conf.getRoutingCalcInterval(), 9);
// Advertising
- BOOST_CHECK_EQUAL(nlsr.getNamePrefixList().size(), 2);
+ BOOST_CHECK_EQUAL(conf.getNamePrefixList().size(), 2);
}
BOOST_AUTO_TEST_CASE(MalformedUri)
@@ -240,7 +236,6 @@
{
processConfigurationString(CONFIG_HYPERBOLIC);
- ConfParameter& conf = nlsr.getConfParameter();
BOOST_CHECK_EQUAL(conf.getHyperbolicState(), 1);
BOOST_CHECK_EQUAL(conf.getCorR(), 123.456);
std::vector<double> angles;
@@ -252,7 +247,6 @@
{
processConfigurationString(CONFIG_HYPERBOLIC_ANGLES);
- ConfParameter& conf = nlsr.getConfParameter();
BOOST_CHECK_EQUAL(conf.getHyperbolicState(), 1);
BOOST_CHECK_EQUAL(conf.getCorR(), 123.456);
std::vector<double> angles;
@@ -271,8 +265,6 @@
BOOST_CHECK_EQUAL(processConfigurationString(config), true);
- ConfParameter& conf = nlsr.getConfParameter();
-
BOOST_CHECK_EQUAL(conf.getLsaRefreshTime(), static_cast<uint32_t>(LSA_REFRESH_TIME_DEFAULT));
BOOST_CHECK_EQUAL(conf.getLsaInterestLifetime(),
static_cast<ndn::time::seconds>(LSA_INTEREST_LIFETIME_DEFAULT));
@@ -291,8 +283,6 @@
BOOST_CHECK_EQUAL(processConfigurationString(config), true);
- ConfParameter& conf = nlsr.getConfParameter();
-
BOOST_CHECK_EQUAL(conf.getInterestRetryNumber(), static_cast<uint32_t>(HELLO_RETRIES_DEFAULT));
BOOST_CHECK_EQUAL(conf.getInterestResendTime(), static_cast<uint32_t>(HELLO_TIMEOUT_DEFAULT));
BOOST_CHECK_EQUAL(conf.getInfoInterestInterval(), static_cast<uint32_t>(HELLO_INTERVAL_DEFAULT));
@@ -311,8 +301,6 @@
BOOST_CHECK_EQUAL(processConfigurationString(config), true);
- ConfParameter& conf = nlsr.getConfParameter();
-
BOOST_CHECK_EQUAL(conf.getMaxFacesPerPrefix(),
static_cast<uint32_t>(MAX_FACES_PER_PREFIX_DEFAULT));
BOOST_CHECK_EQUAL(conf.getRoutingCalcInterval(),
@@ -327,8 +315,6 @@
BOOST_CHECK_EQUAL(processConfigurationString(config), true);
- ConfParameter& conf = nlsr.getConfParameter();
-
BOOST_CHECK_EQUAL(conf.getHyperbolicState(), static_cast<int32_t>(HYPERBOLIC_STATE_DEFAULT));
}
@@ -391,8 +377,7 @@
BOOST_CHECK(processConfigurationString(SECTION_SECURITY));
// Certificate should now be in the CertificateStore
- security::CertificateStore& certStore = nlsr.getCertificateStore();
- BOOST_CHECK(certStore.find(identity.getDefaultKey().getName()) != nullptr);
+ BOOST_CHECK(conf.getCertStore().find(identity.getDefaultKey().getName()) != nullptr);
}
BOOST_AUTO_TEST_CASE(PrefixUpdateValidatorOptional) // Bug #2814