src: decouple classes from Nlsr object
refs: #1952, #2803, #3960, #4288
Change-Id: Ibe3ac3820f11e8107ee4b13e510d53c27467a6cb
diff --git a/tests/test-link-state-calculator.cpp b/tests/test-link-state-calculator.cpp
index c6fafd0..7ca4fb9 100644
--- a/tests/test-link-state-calculator.cpp
+++ b/tests/test-link-state-calculator.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2018, The University of Memphis,
+ * Copyright (c) 2014-2019, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -42,9 +42,11 @@
public:
LinkStateCalculatorFixture()
: face(m_ioService, m_keyChain)
- , nlsr(m_ioService, m_scheduler, face, m_keyChain)
- , routingTable(nlsr.getRoutingTable())
- , lsdb(nlsr.getLsdb())
+ , conf(face)
+ , confProcessor(conf)
+ , nlsr(face, m_keyChain, conf)
+ , routingTable(nlsr.m_routingTable)
+ , lsdb(nlsr.m_lsdb)
{
setUpTopology();
}
@@ -52,12 +54,6 @@
// Triangle topology with routers A, B, C connected
void setUpTopology()
{
- ConfParameter& conf = nlsr.getConfParameter();
- conf.setNetwork("/ndn");
- conf.setSiteName("/router");
- conf.setRouterName("/a");
- conf.buildRouterPrefix();
-
Adjacent a(ROUTER_A_NAME, ndn::FaceUri(ROUTER_A_FACE), 0, Adjacent::STATUS_ACTIVE, 0, 0);
Adjacent b(ROUTER_B_NAME, ndn::FaceUri(ROUTER_B_FACE), 0, Adjacent::STATUS_ACTIVE, 0, 0);
Adjacent c(ROUTER_C_NAME, ndn::FaceUri(ROUTER_C_FACE), 0, Adjacent::STATUS_ACTIVE, 0, 0);
@@ -66,7 +62,7 @@
b.setLinkCost(LINK_AB_COST);
c.setLinkCost(LINK_AC_COST);
- AdjacencyList& adjacencyListA = nlsr.getAdjacencyList();
+ AdjacencyList& adjacencyListA = conf.getAdjacencyList();
adjacencyListA.insert(b);
adjacencyListA.insert(c);
@@ -100,6 +96,8 @@
public:
ndn::util::DummyClientFace face;
+ ConfParameter conf;
+ DummyConfFileProcessor confProcessor;
Nlsr nlsr;
Map map;
@@ -119,9 +117,9 @@
static const double LINK_BC_COST;
};
-const ndn::Name LinkStateCalculatorFixture::ROUTER_A_NAME = "/ndn/router/a";
-const ndn::Name LinkStateCalculatorFixture::ROUTER_B_NAME = "/ndn/router/b";
-const ndn::Name LinkStateCalculatorFixture::ROUTER_C_NAME = "/ndn/router/c";
+const ndn::Name LinkStateCalculatorFixture::ROUTER_A_NAME = "/ndn/site/%C1.Router/this-router";
+const ndn::Name LinkStateCalculatorFixture::ROUTER_B_NAME = "/ndn/site/%C1.Router/b";
+const ndn::Name LinkStateCalculatorFixture::ROUTER_C_NAME = "/ndn/site/%C1.Router/c";
const std::string LinkStateCalculatorFixture::ROUTER_A_FACE = "udp4://10.0.0.1";
const std::string LinkStateCalculatorFixture::ROUTER_B_FACE = "udp4://10.0.0.2";
@@ -136,7 +134,7 @@
BOOST_AUTO_TEST_CASE(Basic)
{
LinkStateRoutingTableCalculator calculator(map.getMapSize());
- calculator.calculatePath(map, routingTable, nlsr);
+ calculator.calculatePath(map, routingTable, conf, lsdb.getAdjLsdb());
RoutingTableEntry* entryB = routingTable.findRoutingTableEntry(ROUTER_B_NAME);
BOOST_REQUIRE(entryB != nullptr);
@@ -174,18 +172,18 @@
{
// Asymmetric link cost between B and C
ndn::Name key = ndn::Name(ROUTER_B_NAME).append(std::to_string(Lsa::Type::ADJACENCY));
- AdjLsa* lsa = nlsr.getLsdb().findAdjLsa(key);
+ AdjLsa* lsa = nlsr.m_lsdb.findAdjLsa(key);
BOOST_REQUIRE(lsa != nullptr);
auto c = lsa->getAdl().findAdjacent(ROUTER_C_NAME);
- BOOST_REQUIRE(c != nlsr.getAdjacencyList().end());
+ BOOST_REQUIRE(c != conf.getAdjacencyList().end());
double higherLinkCost = LINK_BC_COST + 1;
c->setLinkCost(higherLinkCost);
// Calculation should consider the link between B and C as having cost = higherLinkCost
LinkStateRoutingTableCalculator calculator(map.getMapSize());
- calculator.calculatePath(map, routingTable, nlsr);
+ calculator.calculatePath(map, routingTable, conf, lsdb.getAdjLsdb());
RoutingTableEntry* entryB = routingTable.findRoutingTableEntry(ROUTER_B_NAME);
BOOST_REQUIRE(entryB != nullptr);
@@ -223,17 +221,17 @@
{
// Asymmetric link cost between B and C
ndn::Name key = ndn::Name(ROUTER_B_NAME).append(std::to_string(Lsa::Type::ADJACENCY));
- AdjLsa* lsa = nlsr.getLsdb().findAdjLsa(key);
+ AdjLsa* lsa = nlsr.m_lsdb.findAdjLsa(key);
BOOST_REQUIRE(lsa != nullptr);
auto c = lsa->getAdl().findAdjacent(ROUTER_C_NAME);
- BOOST_REQUIRE(c != nlsr.getAdjacencyList().end());
+ BOOST_REQUIRE(c != conf.getAdjacencyList().end());
c->setLinkCost(0);
// Calculation should consider the link between B and C as down
LinkStateRoutingTableCalculator calculator(map.getMapSize());
- calculator.calculatePath(map, routingTable, nlsr);
+ calculator.calculatePath(map, routingTable, conf, lsdb.getAdjLsdb());
// Router A should be able to get to B through B but not through C
RoutingTableEntry* entryB = routingTable.findRoutingTableEntry(ROUTER_B_NAME);