tests: register instead of install DummyStrategy

refs #3868

Change-Id: I5e44582625be51ef874e2a92e4bb7cc22d5b607b
diff --git a/tests/daemon/table/measurements-accessor.t.cpp b/tests/daemon/table/measurements-accessor.t.cpp
index 292c5a6..86a005a 100644
--- a/tests/daemon/table/measurements-accessor.t.cpp
+++ b/tests/daemon/table/measurements-accessor.t.cpp
@@ -28,7 +28,7 @@
 
 #include "tests/test-common.hpp"
 #include "../fw/dummy-strategy.hpp"
-#include "../fw/install-strategy.hpp"
+#include "../fw/choose-strategy.hpp"
 
 namespace nfd {
 namespace measurements {
@@ -39,17 +39,17 @@
 class MeasurementsAccessorTestStrategy : public DummyStrategy
 {
 public:
+  static void
+  registerAs(const Name& strategyName)
+  {
+    registerAsImpl<MeasurementsAccessorTestStrategy>(strategyName);
+  }
+
   MeasurementsAccessorTestStrategy(Forwarder& forwarder, const Name& name)
     : DummyStrategy(forwarder, name)
   {
   }
 
-  virtual
-  ~MeasurementsAccessorTestStrategy()
-  {
-  }
-
-public: // accessors
   MeasurementsAccessor&
   getMeasurementsAccessor()
   {
@@ -61,25 +61,30 @@
 {
 protected:
   MeasurementsAccessorFixture()
-    : strategy1(install<MeasurementsAccessorTestStrategy>(forwarder, "ndn:/strategy1"))
-    , strategy2(install<MeasurementsAccessorTestStrategy>(forwarder, "ndn:/strategy2"))
-    , measurements(forwarder.getMeasurements())
-    , accessor1(strategy1.getMeasurementsAccessor())
-    , accessor2(strategy2.getMeasurementsAccessor())
+    : measurements(forwarder.getMeasurements())
   {
-    StrategyChoice& strategyChoice = forwarder.getStrategyChoice();
-    strategyChoice.insert("/"   , strategy1.getName());
-    strategyChoice.insert("/A"  , strategy2.getName());
-    strategyChoice.insert("/A/B", strategy1.getName());
+    const Name strategyP("/measurements-accessor-test-strategy-P/%FD%01");
+    const Name strategyQ("/measurements-accessor-test-strategy-Q/%FD%01");
+    MeasurementsAccessorTestStrategy::registerAs(strategyP);
+    MeasurementsAccessorTestStrategy::registerAs(strategyQ);
+
+    accessor1 = &choose<MeasurementsAccessorTestStrategy>(forwarder, "/", strategyP)
+                  .getMeasurementsAccessor();
+    accessor2 = &choose<MeasurementsAccessorTestStrategy>(forwarder, "/A", strategyQ)
+                  .getMeasurementsAccessor();
+    accessor3 = &choose<MeasurementsAccessorTestStrategy>(forwarder, "/A/B", strategyP)
+                  .getMeasurementsAccessor();
+
+    // Despite accessor1 and accessor3 are associated with the same strategy name,
+    // they are different strategy instances and thus cannot access each other's measurements.
   }
 
 protected:
   Forwarder forwarder;
-  MeasurementsAccessorTestStrategy& strategy1;
-  MeasurementsAccessorTestStrategy& strategy2;
   Measurements& measurements;
-  MeasurementsAccessor& accessor1;
-  MeasurementsAccessor& accessor2;
+  MeasurementsAccessor* accessor1;
+  MeasurementsAccessor* accessor2;
+  MeasurementsAccessor* accessor3;
 };
 
 BOOST_AUTO_TEST_SUITE(Table)
@@ -87,33 +92,37 @@
 
 BOOST_AUTO_TEST_CASE(Get)
 {
-  BOOST_CHECK(accessor1.get("/"     ) != nullptr);
-  BOOST_CHECK(accessor1.get("/A"    ) == nullptr);
-  BOOST_CHECK(accessor1.get("/A/B"  ) != nullptr);
-  BOOST_CHECK(accessor1.get("/A/B/C") != nullptr);
-  BOOST_CHECK(accessor1.get("/A/D"  ) == nullptr);
+  BOOST_CHECK(accessor1->get("/"     ) != nullptr);
+  BOOST_CHECK(accessor1->get("/A"    ) == nullptr);
+  BOOST_CHECK(accessor1->get("/A/B"  ) == nullptr);
+  BOOST_CHECK(accessor1->get("/A/B/C") == nullptr);
+  BOOST_CHECK(accessor1->get("/A/D"  ) == nullptr);
 
-  BOOST_CHECK(accessor2.get("/"     ) == nullptr);
-  BOOST_CHECK(accessor2.get("/A"    ) != nullptr);
-  BOOST_CHECK(accessor2.get("/A/B"  ) == nullptr);
-  BOOST_CHECK(accessor2.get("/A/B/C") == nullptr);
-  BOOST_CHECK(accessor2.get("/A/D"  ) != nullptr);
+  BOOST_CHECK(accessor2->get("/"     ) == nullptr);
+  BOOST_CHECK(accessor2->get("/A"    ) != nullptr);
+  BOOST_CHECK(accessor2->get("/A/B"  ) == nullptr);
+  BOOST_CHECK(accessor2->get("/A/B/C") == nullptr);
+  BOOST_CHECK(accessor2->get("/A/D"  ) != nullptr);
+
+  BOOST_CHECK(accessor3->get("/"     ) == nullptr);
+  BOOST_CHECK(accessor3->get("/A"    ) == nullptr);
+  BOOST_CHECK(accessor3->get("/A/B"  ) != nullptr);
+  BOOST_CHECK(accessor3->get("/A/B/C") != nullptr);
+  BOOST_CHECK(accessor3->get("/A/D"  ) == nullptr);
 }
 
 BOOST_AUTO_TEST_CASE(GetParent)
 {
   Entry& entryRoot = measurements.get("/");
-  BOOST_CHECK(accessor1.getParent(entryRoot) == nullptr);
-  BOOST_CHECK(accessor2.getParent(entryRoot) == nullptr);
+  BOOST_CHECK(accessor1->getParent(entryRoot) == nullptr);
+  BOOST_CHECK(accessor2->getParent(entryRoot) == nullptr);
 
-  Entry& entryABC = measurements.get("/A/B/C");
-  BOOST_CHECK(accessor1.getParent(entryABC) != nullptr);
-  BOOST_CHECK(accessor2.getParent(entryABC) == nullptr);
-
-  Entry& entryAB = measurements.get("/A/B");
-  BOOST_CHECK(accessor1.getParent(entryAB) == nullptr);
-  // whether accessor2.getParent(entryAB) can return an Entry is undefined,
-  // because strategy2 shouldn't obtain entryAB in the first place
+  Entry& entryA = measurements.get("/A");
+  BOOST_CHECK(accessor2->getParent(entryA) == nullptr);
+  Entry& entryAD = measurements.get("/A/D");
+  BOOST_CHECK(accessor2->getParent(entryAD) != nullptr);
+  // whether accessor1 and accessor3 can getParent(entryA) and getParent(entryAD) is undefined,
+  // because they shouldn't have obtained those entries in the first place
 }
 
 BOOST_AUTO_TEST_CASE(FindLongestPrefixMatch)
@@ -122,12 +131,12 @@
   shared_ptr<pit::Entry> pitEntry = forwarder.getPit().insert(*interest).first;
 
   measurements.get("/");
-  BOOST_CHECK(accessor1.findLongestPrefixMatch("/A/B") != nullptr);
-  BOOST_CHECK(accessor1.findLongestPrefixMatch(*pitEntry) != nullptr);
+  BOOST_CHECK(accessor1->findLongestPrefixMatch("/A/B") != nullptr);
+  BOOST_CHECK(accessor1->findLongestPrefixMatch(*pitEntry) != nullptr);
 
   measurements.get("/A");
-  BOOST_CHECK(accessor1.findLongestPrefixMatch("/A/B") == nullptr);
-  BOOST_CHECK(accessor1.findLongestPrefixMatch(*pitEntry) == nullptr);
+  BOOST_CHECK(accessor1->findLongestPrefixMatch("/A/B") == nullptr);
+  BOOST_CHECK(accessor1->findLongestPrefixMatch(*pitEntry) == nullptr);
 }
 
 BOOST_AUTO_TEST_CASE(FindExactMatch)
@@ -138,21 +147,29 @@
   measurements.get("/A/B/C");
   measurements.get("/A/D");
 
-  BOOST_CHECK(accessor1.findExactMatch("/"     ) != nullptr);
-  BOOST_CHECK(accessor1.findExactMatch("/A"    ) == nullptr);
-  BOOST_CHECK(accessor1.findExactMatch("/A/B"  ) != nullptr);
-  BOOST_CHECK(accessor1.findExactMatch("/A/B/C") != nullptr);
-  BOOST_CHECK(accessor1.findExactMatch("/A/D"  ) == nullptr);
-  BOOST_CHECK(accessor1.findExactMatch("/A/E"  ) == nullptr);
-  BOOST_CHECK(accessor1.findExactMatch("/F"    ) == nullptr);
+  BOOST_CHECK(accessor1->findExactMatch("/"     ) != nullptr);
+  BOOST_CHECK(accessor1->findExactMatch("/A"    ) == nullptr);
+  BOOST_CHECK(accessor1->findExactMatch("/A/B"  ) == nullptr);
+  BOOST_CHECK(accessor1->findExactMatch("/A/B/C") == nullptr);
+  BOOST_CHECK(accessor1->findExactMatch("/A/D"  ) == nullptr);
+  BOOST_CHECK(accessor1->findExactMatch("/A/E"  ) == nullptr);
+  BOOST_CHECK(accessor1->findExactMatch("/F"    ) == nullptr);
 
-  BOOST_CHECK(accessor2.findExactMatch("/"     ) == nullptr);
-  BOOST_CHECK(accessor2.findExactMatch("/A"    ) != nullptr);
-  BOOST_CHECK(accessor2.findExactMatch("/A/B"  ) == nullptr);
-  BOOST_CHECK(accessor2.findExactMatch("/A/B/C") == nullptr);
-  BOOST_CHECK(accessor2.findExactMatch("/A/D"  ) != nullptr);
-  BOOST_CHECK(accessor2.findExactMatch("/A/E"  ) == nullptr);
-  BOOST_CHECK(accessor2.findExactMatch("/F"    ) == nullptr);
+  BOOST_CHECK(accessor2->findExactMatch("/"     ) == nullptr);
+  BOOST_CHECK(accessor2->findExactMatch("/A"    ) != nullptr);
+  BOOST_CHECK(accessor2->findExactMatch("/A/B"  ) == nullptr);
+  BOOST_CHECK(accessor2->findExactMatch("/A/B/C") == nullptr);
+  BOOST_CHECK(accessor2->findExactMatch("/A/D"  ) != nullptr);
+  BOOST_CHECK(accessor2->findExactMatch("/A/E"  ) == nullptr);
+  BOOST_CHECK(accessor2->findExactMatch("/F"    ) == nullptr);
+
+  BOOST_CHECK(accessor3->findExactMatch("/"     ) == nullptr);
+  BOOST_CHECK(accessor3->findExactMatch("/A"    ) == nullptr);
+  BOOST_CHECK(accessor3->findExactMatch("/A/B"  ) != nullptr);
+  BOOST_CHECK(accessor3->findExactMatch("/A/B/C") != nullptr);
+  BOOST_CHECK(accessor3->findExactMatch("/A/D"  ) == nullptr);
+  BOOST_CHECK(accessor3->findExactMatch("/A/E"  ) == nullptr);
+  BOOST_CHECK(accessor3->findExactMatch("/F"    ) == nullptr);
 }
 
 BOOST_AUTO_TEST_SUITE_END() // TestMeasurementsAccessor
diff --git a/tests/daemon/table/strategy-choice.t.cpp b/tests/daemon/table/strategy-choice.t.cpp
index a9042a9..fae7b49 100644
--- a/tests/daemon/table/strategy-choice.t.cpp
+++ b/tests/daemon/table/strategy-choice.t.cpp
@@ -27,7 +27,6 @@
 
 #include "tests/test-common.hpp"
 #include "../fw/dummy-strategy.hpp"
-#include "../fw/install-strategy.hpp"
 
 namespace nfd {
 namespace tests {
@@ -37,7 +36,11 @@
 protected:
   StrategyChoiceFixture()
     : sc(forwarder.getStrategyChoice())
+    , strategyNameP("/strategy-choice-P/%FD%00")
+    , strategyNameQ("/strategy-choice-Q/%FD%00")
   {
+    DummyStrategy::registerAs(strategyNameP);
+    DummyStrategy::registerAs(strategyNameQ);
   }
 
   Name
@@ -51,9 +54,19 @@
     return foundName;
   }
 
+  template<typename Q>
+  Name
+  findInstanceName(const Q& query)
+  {
+    return sc.findEffectiveStrategy(query).getInstanceName();
+  }
+
 protected:
   Forwarder forwarder;
   StrategyChoice& sc;
+
+  const Name strategyNameP;
+  const Name strategyNameQ;
 };
 
 BOOST_AUTO_TEST_SUITE(Table)
@@ -63,111 +76,97 @@
 
 BOOST_AUTO_TEST_CASE(Parameters)
 {
-  const Name strategyName("/strategy-choice-test-parameters/%FD%01");
-  DummyStrategy::registerAs(strategyName);
-
   // no parameters
-  BOOST_CHECK_EQUAL(this->insertAndGet("/A", strategyName), strategyName);
+  BOOST_CHECK_EQUAL(this->insertAndGet("/A", strategyNameP), strategyNameP);
 
   // one parameter
-  Name oneParamName = Name(strategyName).append("param");
+  Name oneParamName = Name(strategyNameP).append("param");
   BOOST_CHECK_EQUAL(this->insertAndGet("/B", oneParamName), oneParamName);
 
   // two parameters
-  Name twoParamName = Name(strategyName).append("x").append("y");
+  Name twoParamName = Name(strategyNameP).append("x").append("y");
   BOOST_CHECK_EQUAL(this->insertAndGet("/C", twoParamName), twoParamName);
 
   // parameter without version is disallowed
-  Name oneParamUnversioned = strategyName.getPrefix(-1).append("param");
+  Name oneParamUnversioned = strategyNameP.getPrefix(-1).append("param");
   BOOST_CHECK_EQUAL(sc.insert("/D", oneParamUnversioned), false);
 }
 
 BOOST_AUTO_TEST_CASE(Get)
 {
-  Name nameP("ndn:/strategy/P");
-  install<DummyStrategy>(forwarder, nameP);
-
-  BOOST_CHECK(sc.insert("ndn:/", nameP));
+  BOOST_CHECK(sc.insert("/", strategyNameP));
   // { '/'=>P }
 
-  auto getRoot = sc.get("ndn:/");
+  auto getRoot = sc.get("/");
   BOOST_CHECK_EQUAL(getRoot.first, true);
-  BOOST_CHECK_EQUAL(getRoot.second, nameP);
+  BOOST_CHECK_EQUAL(getRoot.second, strategyNameP);
 
-  auto getA = sc.get("ndn:/A");
+  auto getA = sc.get("/A");
   BOOST_CHECK_EQUAL(getA.first, false);
 }
 
 BOOST_AUTO_TEST_CASE(FindEffectiveStrategy)
 {
-  Name nameP("ndn:/strategy/P");
-  Name nameQ("ndn:/strategy/Q");
-  Name nameZ("ndn:/strategy/Z");
-  install<DummyStrategy>(forwarder, nameP);
-  install<DummyStrategy>(forwarder, nameQ);
+  const Name strategyNameZ("/strategy-choice-Z/%FD%00"); // unregistered strategyName
 
-  BOOST_CHECK(sc.insert("ndn:/", nameP));
+  BOOST_CHECK(sc.insert("/", strategyNameP));
   // { '/'=>P }
 
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/")   .getName(), nameP);
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/A")  .getName(), nameP);
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/A/B").getName(), nameP);
+  BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP);
+  BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameP);
+  BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP);
 
-  BOOST_CHECK(sc.insert("ndn:/A/B", nameP));
+  BOOST_CHECK(sc.insert("/A/B", strategyNameP));
   // { '/'=>P, '/A/B'=>P }
 
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/")   .getName(), nameP);
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/A")  .getName(), nameP);
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/A/B").getName(), nameP);
-  // same instance
-  BOOST_CHECK_EQUAL(&sc.findEffectiveStrategy("ndn:/"),
-                    &sc.findEffectiveStrategy("ndn:/A/B"));
+  BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP);
+  BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameP);
+  BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP);
+  // same entry, same instance
+  BOOST_CHECK_EQUAL(&sc.findEffectiveStrategy("/"), &sc.findEffectiveStrategy("/A"));
+  // different entries, distinct instances
+  BOOST_CHECK_NE(&sc.findEffectiveStrategy("/"), &sc.findEffectiveStrategy("/A/B"));
 
-  sc.erase("ndn:/A"); // no effect
+  sc.erase("/A"); // no effect
   // { '/'=>P, '/A/B'=>P }
 
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/")   .getName(), nameP);
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/A")  .getName(), nameP);
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/A/B").getName(), nameP);
+  BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP);
+  BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameP);
+  BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP);
 
-  BOOST_CHECK(sc.insert("ndn:/A", nameQ));
+  BOOST_CHECK(sc.insert("/A", strategyNameQ));
   // { '/'=>P, '/A/B'=>P, '/A'=>Q }
 
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/")   .getName(), nameP);
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/A")  .getName(), nameQ);
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/A/B").getName(), nameP);
+  BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP);
+  BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameQ);
+  BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP);
 
-  sc.erase("ndn:/A/B");
+  sc.erase("/A/B");
   // { '/'=>P, '/A'=>Q }
 
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/")   .getName(), nameP);
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/A")  .getName(), nameQ);
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/A/B").getName(), nameQ);
+  BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameP);
+  BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameQ);
+  BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameQ);
 
-  BOOST_CHECK(!sc.insert("ndn:/", nameZ)); // non existent strategy
+  BOOST_CHECK(!sc.insert("/", strategyNameZ)); // non existent strategy
 
-  BOOST_CHECK(sc.insert("ndn:/", nameQ));
-  BOOST_CHECK(sc.insert("ndn:/A", nameP));
+  BOOST_CHECK(sc.insert("/", strategyNameQ));
+  BOOST_CHECK(sc.insert("/A", strategyNameP));
   // { '/'=>Q, '/A'=>P }
 
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/")   .getName(), nameQ);
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/A")  .getName(), nameP);
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/A/B").getName(), nameP);
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/D")  .getName(), nameQ);
+  BOOST_CHECK_EQUAL(this->findInstanceName("/"), strategyNameQ);
+  BOOST_CHECK_EQUAL(this->findInstanceName("/A"), strategyNameP);
+  BOOST_CHECK_EQUAL(this->findInstanceName("/A/B"), strategyNameP);
+  BOOST_CHECK_EQUAL(this->findInstanceName("/D"), strategyNameQ);
 }
 
 BOOST_AUTO_TEST_CASE(FindEffectiveStrategyWithPitEntry)
 {
-  Name nameP("ndn:/strategy/P");
-  Name nameQ("ndn:/strategy/Q");
-  install<DummyStrategy>(forwarder, nameP);
-  install<DummyStrategy>(forwarder, nameQ);
-
   shared_ptr<Data> dataABC = makeData("/A/B/C");
   Name fullName = dataABC->getFullName();
 
-  BOOST_CHECK(sc.insert("/A", nameP));
-  BOOST_CHECK(sc.insert(fullName, nameQ));
+  BOOST_CHECK(sc.insert("/A", strategyNameP));
+  BOOST_CHECK(sc.insert(fullName, strategyNameQ));
 
   Pit& pit = forwarder.getPit();
   shared_ptr<Interest> interestAB = makeInterest("/A/B");
@@ -175,26 +174,34 @@
   shared_ptr<Interest> interestFull = makeInterest(fullName);
   shared_ptr<pit::Entry> pitFull = pit.insert(*interestFull).first;
 
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy(*pitAB).getName(), nameP);
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy(*pitFull).getName(), nameQ);
+  BOOST_CHECK_EQUAL(this->findInstanceName(*pitAB), strategyNameP);
+  BOOST_CHECK_EQUAL(this->findInstanceName(*pitFull), strategyNameQ);
 }
 
 BOOST_AUTO_TEST_CASE(FindEffectiveStrategyWithMeasurementsEntry)
 {
-  Name nameP("ndn:/strategy/P");
-  Name nameQ("ndn:/strategy/Q");
-  install<DummyStrategy>(forwarder, nameP);
-  install<DummyStrategy>(forwarder, nameQ);
-
-  BOOST_CHECK(sc.insert("/A", nameP));
-  BOOST_CHECK(sc.insert("/A/B/C", nameQ));
+  BOOST_CHECK(sc.insert("/A", strategyNameP));
+  BOOST_CHECK(sc.insert("/A/B/C", strategyNameQ));
 
   Measurements& measurements = forwarder.getMeasurements();
   measurements::Entry& mAB = measurements.get("/A/B");
   measurements::Entry& mABCD = measurements.get("/A/B/C/D");
 
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy(mAB).getName(), nameP);
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy(mABCD).getName(), nameQ);
+  BOOST_CHECK_EQUAL(this->findInstanceName(mAB), strategyNameP);
+  BOOST_CHECK_EQUAL(this->findInstanceName(mABCD), strategyNameQ);
+}
+
+BOOST_AUTO_TEST_CASE(Erase)
+{
+  NameTree& nameTree = forwarder.getNameTree();
+
+  sc.insert("/", strategyNameP);
+
+  size_t nNameTreeEntriesBefore = nameTree.size();
+
+  sc.insert("/A/B", strategyNameQ);
+  sc.erase("/A/B");
+  BOOST_CHECK_EQUAL(nameTree.size(), nNameTreeEntriesBefore);
 }
 
 //XXX BOOST_CONCEPT_ASSERT((ForwardIterator<std::vector<int>::iterator>))
@@ -203,16 +210,11 @@
 
 BOOST_AUTO_TEST_CASE(Enumerate)
 {
-  Name nameP("ndn:/strategy/P");
-  Name nameQ("ndn:/strategy/Q");
-  install<DummyStrategy>(forwarder, nameP);
-  install<DummyStrategy>(forwarder, nameQ);
-
-  sc.insert("ndn:/",      nameP);
-  sc.insert("ndn:/A/B",   nameQ);
-  sc.insert("ndn:/A/B/C", nameP);
-  sc.insert("ndn:/D",     nameP);
-  sc.insert("ndn:/E",     nameQ);
+  sc.insert("/",      strategyNameP);
+  sc.insert("/A/B",   strategyNameQ);
+  sc.insert("/A/B/C", strategyNameP);
+  sc.insert("/D",     strategyNameP);
+  sc.insert("/E",     strategyNameQ);
 
   BOOST_CHECK_EQUAL(sc.size(), 5);
 
@@ -220,12 +222,12 @@
   for (StrategyChoice::const_iterator it = sc.begin(); it != sc.end(); ++it) {
     map[it->getPrefix()] = it->getStrategyName();
   }
-  BOOST_CHECK_EQUAL(map.size(), 5);
-  BOOST_CHECK_EQUAL(map["ndn:/"],      nameP);
-  BOOST_CHECK_EQUAL(map["ndn:/A/B"],   nameQ);
-  BOOST_CHECK_EQUAL(map["ndn:/A/B/C"], nameP);
-  BOOST_CHECK_EQUAL(map["ndn:/D"],     nameP);
-  BOOST_CHECK_EQUAL(map["ndn:/E"],     nameQ);
+
+  BOOST_CHECK_EQUAL(map.at("/"),      strategyNameP);
+  BOOST_CHECK_EQUAL(map.at("/A/B"),   strategyNameQ);
+  BOOST_CHECK_EQUAL(map.at("/A/B/C"), strategyNameP);
+  BOOST_CHECK_EQUAL(map.at("/D"),     strategyNameP);
+  BOOST_CHECK_EQUAL(map.at("/E"),     strategyNameQ);
   BOOST_CHECK_EQUAL(map.size(), 5);
 }
 
@@ -239,136 +241,38 @@
   }
 };
 
+BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES(ClearStrategyInfo, 2)
 BOOST_AUTO_TEST_CASE(ClearStrategyInfo)
 {
-  Name nameP("ndn:/strategy/P");
-  Name nameQ("ndn:/strategy/Q");
-  install<DummyStrategy>(forwarder, nameP);
-  install<DummyStrategy>(forwarder, nameQ);
-
   Measurements& measurements = forwarder.getMeasurements();
 
-  BOOST_CHECK(sc.insert("ndn:/", nameP));
+  BOOST_CHECK(sc.insert("/", strategyNameP));
   // { '/'=>P }
-  measurements.get("ndn:/").insertStrategyInfo<PStrategyInfo>();
-  measurements.get("ndn:/A").insertStrategyInfo<PStrategyInfo>();
-  measurements.get("ndn:/A/B").insertStrategyInfo<PStrategyInfo>();
-  measurements.get("ndn:/A/C").insertStrategyInfo<PStrategyInfo>();
+  measurements.get("/").insertStrategyInfo<PStrategyInfo>();
+  measurements.get("/A").insertStrategyInfo<PStrategyInfo>();
+  measurements.get("/A/B").insertStrategyInfo<PStrategyInfo>();
+  measurements.get("/A/C").insertStrategyInfo<PStrategyInfo>();
 
-  BOOST_CHECK(sc.insert("ndn:/A/B", nameP));
+  BOOST_CHECK(sc.insert("/A/B", strategyNameP));
   // { '/'=>P, '/A/B'=>P }
-  BOOST_CHECK(measurements.get("ndn:/").getStrategyInfo<PStrategyInfo>() != nullptr);
-  BOOST_CHECK(measurements.get("ndn:/A").getStrategyInfo<PStrategyInfo>() != nullptr);
-  BOOST_CHECK(measurements.get("ndn:/A/B").getStrategyInfo<PStrategyInfo>() != nullptr);
-  BOOST_CHECK(measurements.get("ndn:/A/C").getStrategyInfo<PStrategyInfo>() != nullptr);
+  BOOST_CHECK(measurements.get("/").getStrategyInfo<PStrategyInfo>() != nullptr);
+  BOOST_CHECK(measurements.get("/A").getStrategyInfo<PStrategyInfo>() != nullptr);
+  BOOST_CHECK(measurements.get("/A/B").getStrategyInfo<PStrategyInfo>() != nullptr); // expected failure
+  BOOST_CHECK(measurements.get("/A/C").getStrategyInfo<PStrategyInfo>() != nullptr);
 
-  BOOST_CHECK(sc.insert("ndn:/A", nameQ));
+  BOOST_CHECK(sc.insert("/A", strategyNameQ));
   // { '/'=>P, '/A/B'=>P, '/A'=>Q }
-  BOOST_CHECK(measurements.get("ndn:/").getStrategyInfo<PStrategyInfo>() != nullptr);
-  BOOST_CHECK(measurements.get("ndn:/A").getStrategyInfo<PStrategyInfo>() == nullptr);
-  BOOST_CHECK(measurements.get("ndn:/A/B").getStrategyInfo<PStrategyInfo>() != nullptr);
-  BOOST_CHECK(measurements.get("ndn:/A/C").getStrategyInfo<PStrategyInfo>() == nullptr);
+  BOOST_CHECK(measurements.get("/").getStrategyInfo<PStrategyInfo>() != nullptr);
+  BOOST_CHECK(measurements.get("/A").getStrategyInfo<PStrategyInfo>() == nullptr);
+  BOOST_CHECK(measurements.get("/A/B").getStrategyInfo<PStrategyInfo>() != nullptr); // expected failure
+  BOOST_CHECK(measurements.get("/A/C").getStrategyInfo<PStrategyInfo>() == nullptr);
 
-  sc.erase("ndn:/A/B");
+  sc.erase("/A/B");
   // { '/'=>P, '/A'=>Q }
-  BOOST_CHECK(measurements.get("ndn:/").getStrategyInfo<PStrategyInfo>() != nullptr);
-  BOOST_CHECK(measurements.get("ndn:/A").getStrategyInfo<PStrategyInfo>() == nullptr);
-  BOOST_CHECK(measurements.get("ndn:/A/B").getStrategyInfo<PStrategyInfo>() == nullptr);
-  BOOST_CHECK(measurements.get("ndn:/A/C").getStrategyInfo<PStrategyInfo>() == nullptr);
-}
-
-BOOST_AUTO_TEST_CASE(EraseNameTreeEntry)
-{
-  Name nameP("ndn:/strategy/P");
-  Name nameQ("ndn:/strategy/Q");
-  install<DummyStrategy>(forwarder, nameP);
-  install<DummyStrategy>(forwarder, nameQ);
-
-  NameTree& nameTree = forwarder.getNameTree();
-
-  sc.insert("ndn:/", nameP);
-
-  size_t nNameTreeEntriesBefore = nameTree.size();
-
-  sc.insert("ndn:/A/B", nameQ);
-  sc.erase("ndn:/A/B");
-  BOOST_CHECK_EQUAL(nameTree.size(), nNameTreeEntriesBefore);
-}
-
-BOOST_AUTO_TEST_CASE(Versioning)
-{
-  Forwarder forwarder;
-  Name nameP("ndn:/strategy/P");
-  Name nameP1("ndn:/strategy/P/%FD%01");
-  Name nameP2("ndn:/strategy/P/%FD%02");
-  Name name3("ndn:/%FD%03");
-  Name name4("ndn:/%FD%04");
-  Name nameQ("ndn:/strategy/Q");
-  Name nameQ5("ndn:/strategy/Q/%FD%05");
-
-  // install
-  auto strategyP1 = make_unique<DummyStrategy>(ref(forwarder), nameP1);
-  Strategy* instanceP1 = strategyP1.get();
-  auto strategyP1b = make_unique<DummyStrategy>(ref(forwarder), nameP1);
-  auto strategyP2 = make_unique<DummyStrategy>(ref(forwarder), nameP2);
-  auto strategy3 = make_unique<DummyStrategy>(ref(forwarder), name3);
-  auto strategy4 = make_unique<DummyStrategy>(ref(forwarder), name4);
-  auto strategyQ = make_unique<DummyStrategy>(ref(forwarder), nameQ);
-  auto strategyQ5 = make_unique<DummyStrategy>(ref(forwarder), nameQ5);
-
-  bool isInstalled = false;
-  Strategy* installed = nullptr;
-
-  std::tie(isInstalled, installed) = sc.install(std::move(strategyP1));
-  BOOST_CHECK_EQUAL(isInstalled, true);
-  BOOST_CHECK_EQUAL(installed, instanceP1);
-  std::tie(isInstalled, installed) = sc.install(std::move(strategyP1b));
-  BOOST_CHECK_EQUAL(isInstalled, false);
-  BOOST_CHECK_EQUAL(installed, instanceP1);
-
-  BOOST_CHECK_EQUAL(sc.hasStrategy(nameP,  false), true);
-  BOOST_CHECK_EQUAL(sc.hasStrategy(nameP,  true),  false);
-  BOOST_CHECK_EQUAL(sc.hasStrategy(nameP1, true),  true);
-
-  BOOST_CHECK_EQUAL(sc.install(std::move(strategyP2)).first, true);
-  BOOST_CHECK_EQUAL(sc.install(std::move(strategy3)).first, true);
-  BOOST_CHECK_EQUAL(sc.install(std::move(strategy4)).first, true);
-  BOOST_CHECK_EQUAL(sc.install(std::move(strategyQ)).first, true);
-  BOOST_CHECK_EQUAL(sc.install(std::move(strategyQ5)).first, true);
-
-  BOOST_CHECK(sc.insert("ndn:/", nameQ));
-  // exact match, { '/'=>Q }
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/").getName(), nameQ);
-
-  BOOST_CHECK(sc.insert("ndn:/", nameQ));
-  BOOST_CHECK(sc.insert("ndn:/", nameP));
-  // { '/'=>P2 }
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/").getName(), nameP2);
-
-  BOOST_CHECK(sc.insert("ndn:/", nameQ));
-  BOOST_CHECK(sc.insert("ndn:/", nameP1));
-  // { '/'=>P1 }
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/").getName(), nameP1);
-
-  BOOST_CHECK(sc.insert("ndn:/", nameQ));
-  BOOST_CHECK(sc.insert("ndn:/", nameP2));
-  // { '/'=>P2 }
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/").getName(), nameP2);
-
-  BOOST_CHECK(sc.insert("ndn:/", nameQ));
-  BOOST_CHECK(! sc.insert("ndn:/", "ndn:/strategy/A"));
-  // not installed
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/").getName(), nameQ);
-
-  BOOST_CHECK(sc.insert("ndn:/", nameQ));
-  BOOST_CHECK(! sc.insert("ndn:/", "ndn:/strategy/Z"));
-  // not installed
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/").getName(), nameQ);
-
-  BOOST_CHECK(sc.insert("ndn:/", nameP1));
-  BOOST_CHECK(sc.insert("ndn:/", "ndn:/"));
-  // match one component longer only, { '/'=>4 }
-  BOOST_CHECK_EQUAL(sc.findEffectiveStrategy("ndn:/").getName(), name4);
+  BOOST_CHECK(measurements.get("/").getStrategyInfo<PStrategyInfo>() != nullptr);
+  BOOST_CHECK(measurements.get("/A").getStrategyInfo<PStrategyInfo>() == nullptr);
+  BOOST_CHECK(measurements.get("/A/B").getStrategyInfo<PStrategyInfo>() == nullptr);
+  BOOST_CHECK(measurements.get("/A/C").getStrategyInfo<PStrategyInfo>() == nullptr);
 }
 
 BOOST_AUTO_TEST_SUITE_END() // TestStrategyChoice