table: StrategyChoice no longer supports installed instances
All strategies should be registered in the strategy registry.
refs #3868
Change-Id: Ie89b0ffaf9943e591f9f2d80546b013d5cc16ff8
diff --git a/tests/daemon/fw/dummy-strategy.hpp b/tests/daemon/fw/dummy-strategy.hpp
index 6d4d45d..fb82add 100644
--- a/tests/daemon/fw/dummy-strategy.hpp
+++ b/tests/daemon/fw/dummy-strategy.hpp
@@ -97,6 +97,36 @@
shared_ptr<Face> interestOutFace;
};
+/** \brief DummyStrategy with specific version
+ */
+template<uint64_t VERSION>
+class VersionedDummyStrategy : public DummyStrategy
+{
+public:
+ static void
+ registerAs(const Name& strategyName)
+ {
+ DummyStrategy::registerAsImpl<VersionedDummyStrategy<VERSION>>(strategyName);
+ }
+
+ static Name
+ getStrategyName()
+ {
+ return DummyStrategy::getStrategyName(VERSION);
+ }
+
+ /** \brief constructor
+ *
+ * The strategy instance name is taken from \p name ; if it does not contain a version component,
+ * \p VERSION will be appended.
+ */
+ explicit
+ VersionedDummyStrategy(Forwarder& forwarder, const Name& name = getStrategyName())
+ : DummyStrategy(forwarder, Strategy::makeInstanceName(name, getStrategyName()))
+ {
+ }
+};
+
} // namespace tests
} // namespace nfd
diff --git a/tests/daemon/table/strategy-choice.t.cpp b/tests/daemon/table/strategy-choice.t.cpp
index e827321..4508391 100644
--- a/tests/daemon/table/strategy-choice.t.cpp
+++ b/tests/daemon/table/strategy-choice.t.cpp
@@ -74,6 +74,36 @@
using fw::Strategy;
+BOOST_AUTO_TEST_CASE(Versioning)
+{
+ const Name strategyNameV("/strategy-choice-V");
+ const Name strategyNameV0("/strategy-choice-V/%FD%00");
+ const Name strategyNameV1("/strategy-choice-V/%FD%01");
+ const Name strategyNameV2("/strategy-choice-V/%FD%02");
+ const Name strategyNameV3("/strategy-choice-V/%FD%03");
+ const Name strategyNameV4("/strategy-choice-V/%FD%04");
+ const Name strategyNameV5("/strategy-choice-V/%FD%05");
+
+ VersionedDummyStrategy<1>::registerAs(strategyNameV1);
+ VersionedDummyStrategy<3>::registerAs(strategyNameV3);
+ VersionedDummyStrategy<4>::registerAs(strategyNameV4);
+
+ // unversioned: choose latest version
+ BOOST_CHECK_EQUAL(this->insertAndGet("/A", strategyNameV), strategyNameV4);
+
+ // exact version: choose same version
+ BOOST_CHECK_EQUAL(this->insertAndGet("/B", strategyNameV1), strategyNameV1);
+ BOOST_CHECK_EQUAL(this->insertAndGet("/C", strategyNameV3), strategyNameV3);
+ BOOST_CHECK_EQUAL(this->insertAndGet("/D", strategyNameV4), strategyNameV4);
+
+ // lower version: choose next higher version
+ // BOOST_CHECK_EQUAL(this->insertAndGet("/E", strategyNameV0), strategyNameV1);
+ // BOOST_CHECK_EQUAL(this->insertAndGet("/F", strategyNameV2), strategyNameV3);
+
+ // higher version: failure
+ BOOST_CHECK_EQUAL(sc.insert("/G", strategyNameV5), false);
+}
+
BOOST_AUTO_TEST_CASE(Parameters)
{
// no parameters