publisher: set router-name command prefix correctly

refs: #3651

Change-Id: Ic3771de5161fc482f76df78035dcb9f5325e1a9d
diff --git a/tests/publisher/test-lsdb-dataset-interest-handler.cpp b/tests/publisher/test-lsdb-dataset-interest-handler.cpp
index a574df1..80c83ce 100644
--- a/tests/publisher/test-lsdb-dataset-interest-handler.cpp
+++ b/tests/publisher/test-lsdb-dataset-interest-handler.cpp
@@ -81,7 +81,9 @@
   lsdb.installNameLsa(nameLsa);
 
   ndn::Name thisRouter("/This/Router");
-  LsdbDatasetInterestHandler publisher(lsdb, *face, thisRouter, keyChain);
+  LsdbDatasetInterestHandler publisher(lsdb, *face, keyChain);
+  publisher.setRouterNameCommandPrefix(thisRouter);
+
   publisher.startListeningOnLocalhost();
 
   face->processEvents(ndn::time::milliseconds(10));
@@ -136,7 +138,8 @@
 BOOST_AUTO_TEST_CASE(InvalidCommand)
 {
   ndn::Name thisRouter("/This/Router");
-  LsdbDatasetInterestHandler publisher(lsdb, *face, thisRouter, keyChain);
+  LsdbDatasetInterestHandler publisher(lsdb, *face, keyChain);
+  publisher.setRouterNameCommandPrefix(thisRouter);
 
   // Localhost prefix
   publisher.startListeningOnLocalhost();
diff --git a/tests/test-nlsr.cpp b/tests/test-nlsr.cpp
index c0dfc47..d24e512 100644
--- a/tests/test-nlsr.cpp
+++ b/tests/test-nlsr.cpp
@@ -357,6 +357,23 @@
   BOOST_CHECK(nlsr.getCertificate(certKey) != nullptr);
 }
 
+BOOST_FIXTURE_TEST_CASE(SetRouterCommandPrefix, UnitTestTimeFixture)
+{
+  shared_ptr<ndn::util::DummyClientFace> face = make_shared<ndn::util::DummyClientFace>(g_ioService);
+  Nlsr nlsr(g_ioService, g_scheduler, ndn::ref(*face));
+
+  // Simulate loading configuration file
+  ConfParameter& conf = nlsr.getConfParameter();
+  conf.setNetwork("/ndn");
+  conf.setSiteName("/site");
+  conf.setRouterName("/%C1.router/this-router");
+
+  nlsr.initialize();
+
+  BOOST_CHECK_EQUAL(nlsr.getLsdbDatasetHandler().getRouterNameCommandPrefix(),
+                    ndn::Name("/ndn/site/%C1.router/this-router/lsdb"));
+}
+
 BOOST_AUTO_TEST_SUITE_END()
 
 } //namespace test