tests: register instead of install DummyStrategy
refs #3868
Change-Id: I5e44582625be51ef874e2a92e4bb7cc22d5b607b
diff --git a/tests/daemon/fw/forwarder.t.cpp b/tests/daemon/fw/forwarder.t.cpp
index 11ef06b..37cb5f9 100644
--- a/tests/daemon/fw/forwarder.t.cpp
+++ b/tests/daemon/fw/forwarder.t.cpp
@@ -26,7 +26,7 @@
#include "fw/forwarder.hpp"
#include "tests/daemon/face/dummy-face.hpp"
#include "dummy-strategy.hpp"
-#include "install-strategy.hpp"
+#include "choose-strategy.hpp"
#include <ndn-cxx/lp/tags.hpp>
#include "tests/test-common.hpp"
@@ -256,32 +256,32 @@
forwarder.addFace(face1);
forwarder.addFace(face2);
- DummyStrategy& strategyP = choose<DummyStrategy>(forwarder, "ndn:/", "ndn:/strategyP");
- DummyStrategy& strategyQ = choose<DummyStrategy>(forwarder, "ndn:/B", "ndn:/strategyQ");
+ DummyStrategy& strategyA = choose<DummyStrategy>(forwarder, "ndn:/", DummyStrategy::getStrategyName());
+ DummyStrategy& strategyB = choose<DummyStrategy>(forwarder, "ndn:/B", DummyStrategy::getStrategyName());
shared_ptr<Interest> interest1 = makeInterest("ndn:/A/1");
- strategyP.afterReceiveInterest_count = 0;
- strategyP.interestOutFace = face2;
+ strategyA.afterReceiveInterest_count = 0;
+ strategyA.interestOutFace = face2;
forwarder.startProcessInterest(*face1, *interest1);
- BOOST_CHECK_EQUAL(strategyP.afterReceiveInterest_count, 1);
+ BOOST_CHECK_EQUAL(strategyA.afterReceiveInterest_count, 1);
shared_ptr<Interest> interest2 = makeInterest("ndn:/B/2");
- strategyQ.afterReceiveInterest_count = 0;
- strategyQ.interestOutFace = face2;
+ strategyB.afterReceiveInterest_count = 0;
+ strategyB.interestOutFace = face2;
forwarder.startProcessInterest(*face1, *interest2);
- BOOST_CHECK_EQUAL(strategyQ.afterReceiveInterest_count, 1);
+ BOOST_CHECK_EQUAL(strategyB.afterReceiveInterest_count, 1);
this->advanceClocks(time::milliseconds(1), time::milliseconds(5));
shared_ptr<Data> data1 = makeData("ndn:/A/1/a");
- strategyP.beforeSatisfyInterest_count = 0;
+ strategyA.beforeSatisfyInterest_count = 0;
forwarder.startProcessData(*face2, *data1);
- BOOST_CHECK_EQUAL(strategyP.beforeSatisfyInterest_count, 1);
+ BOOST_CHECK_EQUAL(strategyA.beforeSatisfyInterest_count, 1);
shared_ptr<Data> data2 = makeData("ndn:/B/2/b");
- strategyQ.beforeSatisfyInterest_count = 0;
+ strategyB.beforeSatisfyInterest_count = 0;
forwarder.startProcessData(*face2, *data2);
- BOOST_CHECK_EQUAL(strategyQ.beforeSatisfyInterest_count, 1);
+ BOOST_CHECK_EQUAL(strategyB.beforeSatisfyInterest_count, 1);
shared_ptr<Interest> interest3 = makeInterest("ndn:/A/3");
interest3->setInterestLifetime(time::milliseconds(30));
@@ -290,11 +290,11 @@
interest4->setInterestLifetime(time::milliseconds(5000));
forwarder.startProcessInterest(*face1, *interest4);
- strategyP.beforeExpirePendingInterest_count = 0;
- strategyQ.beforeExpirePendingInterest_count = 0;
+ strategyA.beforeExpirePendingInterest_count = 0;
+ strategyB.beforeExpirePendingInterest_count = 0;
this->advanceClocks(time::milliseconds(10), time::milliseconds(100));
- BOOST_CHECK_EQUAL(strategyP.beforeExpirePendingInterest_count, 1);
- BOOST_CHECK_EQUAL(strategyQ.beforeExpirePendingInterest_count, 0);
+ BOOST_CHECK_EQUAL(strategyA.beforeExpirePendingInterest_count, 1);
+ BOOST_CHECK_EQUAL(strategyB.beforeExpirePendingInterest_count, 0);
}
BOOST_AUTO_TEST_CASE(IncomingData)
@@ -345,8 +345,8 @@
forwarder.addFace(face2);
forwarder.addFace(face3);
- DummyStrategy& strategyP = choose<DummyStrategy>(forwarder, "ndn:/", "ndn:/strategyP");
- DummyStrategy& strategyQ = choose<DummyStrategy>(forwarder, "ndn:/B", "ndn:/strategyQ");
+ DummyStrategy& strategyA = choose<DummyStrategy>(forwarder, "ndn:/", DummyStrategy::getStrategyName());
+ DummyStrategy& strategyB = choose<DummyStrategy>(forwarder, "ndn:/B", DummyStrategy::getStrategyName());
Pit& pit = forwarder.getPit();
@@ -359,18 +359,18 @@
pit2->insertOrUpdateOutRecord(*face1, *interest2);
lp::Nack nack1 = makeNack("/A/AYJqayrzF", 562, lp::NackReason::CONGESTION);
- strategyP.afterReceiveNack_count = 0;
- strategyQ.afterReceiveNack_count = 0;
+ strategyA.afterReceiveNack_count = 0;
+ strategyB.afterReceiveNack_count = 0;
forwarder.onIncomingNack(*face1, nack1);
- BOOST_CHECK_EQUAL(strategyP.afterReceiveNack_count, 1);
- BOOST_CHECK_EQUAL(strategyQ.afterReceiveNack_count, 0);
+ BOOST_CHECK_EQUAL(strategyA.afterReceiveNack_count, 1);
+ BOOST_CHECK_EQUAL(strategyB.afterReceiveNack_count, 0);
lp::Nack nack2 = makeNack("/B/EVyP73ru", 221, lp::NackReason::CONGESTION);
- strategyP.afterReceiveNack_count = 0;
- strategyQ.afterReceiveNack_count = 0;
+ strategyA.afterReceiveNack_count = 0;
+ strategyB.afterReceiveNack_count = 0;
forwarder.onIncomingNack(*face1, nack2);
- BOOST_CHECK_EQUAL(strategyP.afterReceiveNack_count, 0);
- BOOST_CHECK_EQUAL(strategyQ.afterReceiveNack_count, 1);
+ BOOST_CHECK_EQUAL(strategyA.afterReceiveNack_count, 0);
+ BOOST_CHECK_EQUAL(strategyB.afterReceiveNack_count, 1);
// record Nack on PIT out-record
pit::OutRecordCollection::iterator outRecord1 = pit1->getOutRecord(*face1);
@@ -380,11 +380,11 @@
// drop if no PIT entry
lp::Nack nack3 = makeNack("/yEcw5HhdM", 243, lp::NackReason::CONGESTION);
- strategyP.afterReceiveNack_count = 0;
- strategyQ.afterReceiveNack_count = 0;
+ strategyA.afterReceiveNack_count = 0;
+ strategyB.afterReceiveNack_count = 0;
forwarder.onIncomingNack(*face1, nack3);
- BOOST_CHECK_EQUAL(strategyP.afterReceiveNack_count, 0);
- BOOST_CHECK_EQUAL(strategyQ.afterReceiveNack_count, 0);
+ BOOST_CHECK_EQUAL(strategyA.afterReceiveNack_count, 0);
+ BOOST_CHECK_EQUAL(strategyB.afterReceiveNack_count, 0);
// drop if no out-record
shared_ptr<Interest> interest4 = makeInterest("/Etab4KpY", 157);
@@ -392,27 +392,27 @@
pit4->insertOrUpdateOutRecord(*face1, *interest4);
lp::Nack nack4a = makeNack("/Etab4KpY", 157, lp::NackReason::CONGESTION);
- strategyP.afterReceiveNack_count = 0;
- strategyQ.afterReceiveNack_count = 0;
+ strategyA.afterReceiveNack_count = 0;
+ strategyB.afterReceiveNack_count = 0;
forwarder.onIncomingNack(*face2, nack4a);
- BOOST_CHECK_EQUAL(strategyP.afterReceiveNack_count, 0);
- BOOST_CHECK_EQUAL(strategyQ.afterReceiveNack_count, 0);
+ BOOST_CHECK_EQUAL(strategyA.afterReceiveNack_count, 0);
+ BOOST_CHECK_EQUAL(strategyB.afterReceiveNack_count, 0);
// drop if Nonce does not match out-record
lp::Nack nack4b = makeNack("/Etab4KpY", 294, lp::NackReason::CONGESTION);
- strategyP.afterReceiveNack_count = 0;
- strategyQ.afterReceiveNack_count = 0;
+ strategyA.afterReceiveNack_count = 0;
+ strategyB.afterReceiveNack_count = 0;
forwarder.onIncomingNack(*face1, nack4b);
- BOOST_CHECK_EQUAL(strategyP.afterReceiveNack_count, 0);
- BOOST_CHECK_EQUAL(strategyQ.afterReceiveNack_count, 0);
+ BOOST_CHECK_EQUAL(strategyA.afterReceiveNack_count, 0);
+ BOOST_CHECK_EQUAL(strategyB.afterReceiveNack_count, 0);
// drop if inFace is multi-access
pit4->insertOrUpdateOutRecord(*face3, *interest4);
- strategyP.afterReceiveNack_count = 0;
- strategyQ.afterReceiveNack_count = 0;
+ strategyA.afterReceiveNack_count = 0;
+ strategyB.afterReceiveNack_count = 0;
forwarder.onIncomingNack(*face3, nack4a);
- BOOST_CHECK_EQUAL(strategyP.afterReceiveNack_count, 0);
- BOOST_CHECK_EQUAL(strategyQ.afterReceiveNack_count, 0);
+ BOOST_CHECK_EQUAL(strategyA.afterReceiveNack_count, 0);
+ BOOST_CHECK_EQUAL(strategyB.afterReceiveNack_count, 0);
}
BOOST_AUTO_TEST_CASE(OutgoingNack)