publisher: implement routing table dataset publisher

refs: #3631, #3634

Change-Id: I7e961fdd0857690bee65d2bdfa4cf3de90ccac06
diff --git a/tests/publisher/publisher-fixture.hpp b/tests/publisher/publisher-fixture.hpp
index 4b702fc..896e7b3 100644
--- a/tests/publisher/publisher-fixture.hpp
+++ b/tests/publisher/publisher-fixture.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2017,  The University of Memphis,
+ * Copyright (c) 2014-2018,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -22,7 +22,7 @@
 #ifndef NLSR_PUBLISHER_FIXTURE_HPP
 #define NLSR_PUBLISHER_FIXTURE_HPP
 
-#include "publisher/lsdb-dataset-interest-handler.hpp"
+#include "publisher/dataset-interest-handler.hpp"
 #include "nlsr.hpp"
 
 #include "../boost-test.hpp"
@@ -48,6 +48,7 @@
     : face(m_ioService, m_keyChain, {true, true})
     , nlsr(m_ioService, m_scheduler, face, m_keyChain)
     , lsdb(nlsr.getLsdb())
+    , rt1(nlsr.getRoutingTable())
   {
     INIT_LOGGERS("/tmp/", "TRACE");
     nlsr.getConfParameter().setNetwork("/ndn");
@@ -100,6 +101,13 @@
     }
   }
 
+  NextHop
+  createNextHop(const std::string& faceUri, double cost)
+  {
+    NextHop nexthop(faceUri, cost);
+    return nexthop;
+  }
+
   CoordinateLsa
   createCoordinateLsa(const std::string& origin, double radius, std::vector<double> angle)
   {
@@ -159,6 +167,7 @@
   Lsdb& lsdb;
 
   ndn::security::pib::Identity routerId;
+  RoutingTable& rt1;
 };
 
 } // namespace test
diff --git a/tests/publisher/test-lsdb-dataset-interest-handler.cpp b/tests/publisher/test-dataset-interest-handler.cpp
similarity index 81%
rename from tests/publisher/test-lsdb-dataset-interest-handler.cpp
rename to tests/publisher/test-dataset-interest-handler.cpp
index cd9fcf3..ccd3b64 100644
--- a/tests/publisher/test-lsdb-dataset-interest-handler.cpp
+++ b/tests/publisher/test-dataset-interest-handler.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2017,  The University of Memphis,
+ * Copyright (c) 2014-2018,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -19,7 +19,7 @@
  * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
  **/
 
-#include "publisher/lsdb-dataset-interest-handler.hpp"
+#include "publisher/dataset-interest-handler.hpp"
 #include "tests/test-common.hpp"
 #include "tlv/tlv-nlsr.hpp"
 
@@ -28,6 +28,8 @@
 
 #include <ndn-cxx/mgmt/nfd/control-response.hpp>
 
+#include <iostream>
+
 namespace nlsr {
 namespace test {
 
@@ -36,6 +38,7 @@
                        std::function<bool(const ndn::Block&)> isSameType)
 {
   face.processEvents(ndn::time::milliseconds(30));
+
   BOOST_REQUIRE_EQUAL(face.sentData.size(), 1);
 
   ndn::Block parser(face.sentData[0].getContent());
@@ -50,17 +53,6 @@
   face.sentData.clear();
 }
 
-void
-checkErrorResponse(ndn::util::DummyClientFace& face, uint64_t expectedCode)
-{
-  BOOST_REQUIRE_EQUAL(face.sentData.size(), 1);
-
-  ndn::nfd::ControlResponse response(face.sentData[0].getContent().blockFromValue());
-  BOOST_CHECK_EQUAL(response.getCode(), expectedCode);
-
-  face.sentData.clear();
-}
-
 BOOST_FIXTURE_TEST_SUITE(PublisherTestLsdbDatasetInterestHandler, PublisherFixture)
 
 BOOST_AUTO_TEST_CASE(Localhost)
@@ -83,6 +75,14 @@
   nameLsa.addName("/RouterA/name1");
   lsdb.installNameLsa(nameLsa);
 
+  // Install routing table
+  RoutingTableEntry rte1("desrouter1");
+  const ndn::Name& DEST_ROUTER = rte1.getDestination();
+
+  NextHop nh = createNextHop("udp://face-test1", 10);
+
+  rt1.addNextHop(DEST_ROUTER, nh);
+
   // Request adjacency LSAs
   face.receive(ndn::Interest(ndn::Name("/localhost/nlsr/lsdb").append("adjacencies")));
   processDatasetInterest(face,
@@ -98,10 +98,11 @@
   processDatasetInterest(face,
     [] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::NameLsa; });
 
-  // Request LSDB Status
-  face.receive(ndn::Interest(ndn::Name("/localhost/nlsr/lsdb").append("list")));
+  // Request Routing Table
+  face.receive(ndn::Interest(ndn::Name("/localhost/nlsr/routing-table")));
   processDatasetInterest(face,
-    [] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::LsdbStatus; });
+    [] (const ndn::Block& block) {
+      return block.type() == ndn::tlv::nlsr::RouteTableEntry; });
 }
 
 
@@ -119,6 +120,14 @@
   CoordinateLsa coordinateLsa = createCoordinateLsa("/RouterA", 10.0, angles);
   lsdb.installCoordinateLsa(coordinateLsa);
 
+  //Install routing table
+  RoutingTableEntry rte1("desrouter1");
+  const ndn::Name& DEST_ROUTER = rte1.getDestination();
+
+  NextHop nh = createNextHop("udp://face-test1", 10);
+
+  rt1.addNextHop(DEST_ROUTER, nh);
+
   // Request adjacency LSAs
   face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/lsdb").append("adjacencies")));
   processDatasetInterest(face,
@@ -134,10 +143,11 @@
   processDatasetInterest(face,
     [] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::NameLsa; });
 
-  // Request LSDB Status
-  face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/lsdb").append("list")));
+  // Request Routing Table
+  face.receive(ndn::Interest(ndn::Name("/ndn/This/Router/routing-table")));
   processDatasetInterest(face,
-    [] (const ndn::Block& block) { return block.type() == ndn::tlv::nlsr::LsdbStatus; });
+    [] (const ndn::Block& block) {
+      return block.type() == ndn::tlv::nlsr::RouteTableEntry; });
 }
 
 BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/test-nlsr.cpp b/tests/test-nlsr.cpp
index 180c295..5c91312 100644
--- a/tests/test-nlsr.cpp
+++ b/tests/test-nlsr.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014-2017,  The University of Memphis,
+ * Copyright (c) 2014-2018,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -362,7 +362,7 @@
 {
   nlsr.initialize();
 
-  BOOST_CHECK_EQUAL(nlsr.getLsdbDatasetHandler().getRouterNameCommandPrefix(),
+  BOOST_CHECK_EQUAL(nlsr.getDatasetHandler().getRouterNameCommandPrefix(),
                     ndn::Name("/ndn/site/%C1.Router/this-router/lsdb"));
 }
 
diff --git a/tests/tlv/test-destination.cpp b/tests/tlv/test-destination.cpp
new file mode 100644
index 0000000..b74120d
--- /dev/null
+++ b/tests/tlv/test-destination.cpp
@@ -0,0 +1,86 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014-2018,  The University of Memphis,
+ *                           Regents of the University of California,
+ *                           Arizona Board of Regents.
+ *
+ * This file is part of NLSR (Named-data Link State Routing).
+ * See AUTHORS.md for complete list of NLSR authors and contributors.
+ *
+ * NLSR is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+#include "tlv/destination.hpp"
+
+#include "../boost-test.hpp"
+
+namespace nlsr {
+namespace tlv {
+namespace test {
+
+BOOST_AUTO_TEST_SUITE(TlvTestDes)
+
+const uint8_t DesData[] =
+{
+  // Header
+  0x8e, 0x13,
+  // Routername 746573742f646573742f746c76
+  0x07, 0x11, 0x08, 0x04, 0x74, 0x65, 0x73, 0x74, 0x08, 0x04, 0x64, 0x65, 0x73, 0x74,
+  0x08, 0x03, 0x74, 0x6c, 0x76
+};
+
+BOOST_AUTO_TEST_CASE(DesEncode)
+{
+  Destination des1;
+  des1.setName("/test/dest/tlv");
+
+  const ndn::Block& wire = des1.wireEncode();
+
+  BOOST_REQUIRE_EQUAL_COLLECTIONS(DesData,
+                                  DesData + sizeof(DesData),
+                                  wire.begin(), wire.end());
+}
+
+BOOST_AUTO_TEST_CASE(DesDecode)
+{
+  Destination des1;
+
+  des1.wireDecode(ndn::Block(DesData, sizeof(DesData)));
+
+  ndn::Name DEST_NAME = ndn::Name("/test/dest/tlv");
+  BOOST_REQUIRE_EQUAL(des1.getName(), DEST_NAME);
+}
+
+BOOST_AUTO_TEST_CASE(DesOutputStream)
+{
+  Destination des1;
+  des1.setName("/test/dest/tlv");
+
+  std::ostringstream os;
+  os << des1;
+
+  BOOST_CHECK_EQUAL(os.str(), "Destination: /test/dest/tlv");
+}
+
+BOOST_AUTO_TEST_CASE(DesMake)
+{
+  RoutingTableEntry rte("/test/dest/tlv");
+
+  std::shared_ptr<Destination> des = makeDes(rte);
+  BOOST_CHECK_EQUAL(des->getName(), rte.getDestination());
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace test
+} // namespace tlv
+} // namespace nlsr
diff --git a/tests/tlv/test-nexthops.cpp b/tests/tlv/test-nexthops.cpp
new file mode 100644
index 0000000..a0472e8
--- /dev/null
+++ b/tests/tlv/test-nexthops.cpp
@@ -0,0 +1,80 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014-2018,  The University of Memphis,
+ *                           Regents of the University of California,
+ *                           Arizona Board of Regents.
+ *
+ * This file is part of NLSR (Named-data Link State Routing).
+ * See AUTHORS.md for complete list of NLSR authors and contributors.
+ *
+ * NLSR is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+#include "tlv/nexthop.hpp"
+
+#include "../boost-test.hpp"
+
+namespace nlsr {
+namespace tlv {
+namespace test {
+
+BOOST_AUTO_TEST_SUITE(TlvTestNexthops)
+
+const uint8_t NexthopData[] =
+{
+  // Header
+  0x8f, 0x1d,
+  // Uri
+  0x8d, 0x11, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f, 0x70, 0x2f, 0x74, 0x6c, 0x76,
+  // Cost
+  0x86, 0x08, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0xfa, 0x3f
+};
+
+BOOST_AUTO_TEST_CASE(NexthopEncode)
+{
+  NextHop nexthops1;
+  nexthops1.setUri("/test/nexthop/tlv");
+  nexthops1.setCost(1.65);
+
+  const ndn::Block& wire = nexthops1.wireEncode();
+
+  BOOST_REQUIRE_EQUAL_COLLECTIONS(NexthopData,
+                                  NexthopData + sizeof(NexthopData),
+                                  wire.begin(), wire.end());
+}
+
+BOOST_AUTO_TEST_CASE(NexthopDecode)
+{
+  NextHop nexthops1;
+
+  nexthops1.wireDecode(ndn::Block(NexthopData, sizeof(NexthopData)));
+
+  BOOST_REQUIRE_EQUAL(nexthops1.getUri(), "/test/nexthop/tlv");
+  BOOST_REQUIRE_EQUAL(nexthops1.getCost(), 1.65);
+}
+
+BOOST_AUTO_TEST_CASE(AdjacencyOutputStream)
+{
+  NextHop nexthops1;
+  nexthops1.setUri("/test/nexthop/tlv");
+  nexthops1.setCost(99);
+
+  std::ostringstream os;
+  os << nexthops1;
+  BOOST_CHECK_EQUAL(os.str(), "NextHop(Uri: /test/nexthop/tlv, Cost: 99)\n");
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace test
+} // namespace tlv
+} // namespace nlsr
diff --git a/tests/tlv/test-routing-table-entry.cpp b/tests/tlv/test-routing-table-entry.cpp
new file mode 100644
index 0000000..5b882a2
--- /dev/null
+++ b/tests/tlv/test-routing-table-entry.cpp
@@ -0,0 +1,192 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014-2018,  The University of Memphis,
+ *                           Regents of the University of California,
+ *                           Arizona Board of Regents.
+ *
+ * This file is part of NLSR (Named-data Link State Routing).
+ * See AUTHORS.md for complete list of NLSR authors and contributors.
+ *
+ * NLSR is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+#include "tlv/routing-table-entry.hpp"
+
+#include "../boost-test.hpp"
+
+namespace nlsr {
+namespace tlv {
+namespace test {
+
+BOOST_AUTO_TEST_SUITE(TlvTestRoutingTableEntry)
+
+const uint8_t RoutingTableEntryWithNexthopsData[] =
+{
+  // Header
+  0x91, 0x37,
+  // Destination
+  0x8e, 0x09, 0x07, 0x07, 0x08, 0x05, 0x64, 0x65, 0x73, 0x74, 0x31,
+  // Nexthop
+  0x8f, 0x14, 0x8d, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f, 0x70,
+  0x31, 0x86, 0x08, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0xfa, 0x3f,
+  // Nexthop
+  0x8f, 0x14, 0x8d, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f, 0x70,
+  0x32, 0x86, 0x08, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0xfa, 0x3f
+};
+
+const uint8_t RoutingTableEntryWithoutNexthopsData[] =
+{
+  // Header
+  0x91, 0x0b,
+  // Destination
+  0x8e, 0x09, 0x07, 0x07, 0x08, 0x05, 0x64, 0x65, 0x73, 0x74, 0x31
+};
+
+BOOST_AUTO_TEST_CASE(RoutingTableEntryEncodeWithNexthops)
+{
+  RoutingTable rt;
+
+  Destination des1;
+  des1.setName("dest1");
+  rt.setDestination(des1);
+
+  NextHop nexthops1;
+  nexthops1.setUri("nexthop1");
+  nexthops1.setCost(1.65);
+  rt.addNexthops(nexthops1);
+
+  NextHop nexthops2;
+  nexthops2.setUri("nexthop2");
+  nexthops2.setCost(1.65);
+  rt.addNexthops(nexthops2);
+
+  const ndn::Block& wire = rt.wireEncode();
+
+  BOOST_REQUIRE_EQUAL_COLLECTIONS(RoutingTableEntryWithNexthopsData,
+                                  RoutingTableEntryWithNexthopsData +
+                                    sizeof(RoutingTableEntryWithNexthopsData),
+                                  wire.begin(), wire.end());
+}
+
+BOOST_AUTO_TEST_CASE(RoutingTableEntryDecodeWithNexthops)
+{
+  RoutingTable rt;
+
+  rt.wireDecode(ndn::Block(RoutingTableEntryWithNexthopsData,
+                                      sizeof(RoutingTableEntryWithNexthopsData)));
+
+  Destination des = rt.getDestination();
+  BOOST_CHECK_EQUAL(des.getName(), "dest1");
+
+  BOOST_CHECK_EQUAL(rt.hasNexthops(), true);
+  std::list<NextHop> nexthops = rt.getNextHops();
+  std::list<NextHop>::const_iterator it = nexthops.begin();
+  BOOST_CHECK_EQUAL(it->getUri(), "nexthop1");
+  BOOST_CHECK_EQUAL(it->getCost(), 1.65);
+
+  it++;
+  BOOST_CHECK_EQUAL(it->getUri(), "nexthop2");
+  BOOST_CHECK_EQUAL(it->getCost(), 1.65);
+}
+
+BOOST_AUTO_TEST_CASE(RoutingTableEntryEncodeWithoutNexthops)
+{
+  RoutingTable rt;
+
+  Destination des1;
+  des1.setName("dest1");
+  rt.setDestination(des1);
+
+  const ndn::Block& wire = rt.wireEncode();
+
+  BOOST_REQUIRE_EQUAL_COLLECTIONS(RoutingTableEntryWithoutNexthopsData,
+                                  RoutingTableEntryWithoutNexthopsData +
+                                    sizeof(RoutingTableEntryWithoutNexthopsData),
+                                  wire.begin(), wire.end());
+}
+
+BOOST_AUTO_TEST_CASE(RoutingTableEntryDecodeWithoutNexthops)
+{
+  RoutingTable rt;
+
+  rt.wireDecode(ndn::Block(RoutingTableEntryWithoutNexthopsData,
+                           sizeof(RoutingTableEntryWithoutNexthopsData)));
+
+  Destination des = rt.getDestination();
+  BOOST_CHECK_EQUAL(des.getName(), "dest1");
+
+  BOOST_CHECK_EQUAL(rt.hasNexthops(), false);
+}
+
+
+BOOST_AUTO_TEST_CASE(RoutingTableEntryClear)
+{
+  RoutingTable rt;
+  Destination des1;
+  des1.setName("dest1");
+  rt.setDestination(des1);
+
+  NextHop nexthops1;
+  nexthops1.setUri("nexthop1");
+  nexthops1.setCost(99);
+  rt.addNexthops(nexthops1);
+
+  BOOST_CHECK_EQUAL(rt.getNextHops().size(), 1);
+
+  std::list<NextHop> nexthops = rt.getNextHops();
+  std::list<NextHop>::const_iterator it = nexthops.begin();
+  BOOST_CHECK_EQUAL(it->getUri(), "nexthop1");
+  BOOST_CHECK_EQUAL(it->getCost(), 99);
+
+  rt.clearNexthops();
+  BOOST_CHECK_EQUAL(rt.getNextHops().size(), 0);
+
+  NextHop nexthops2;
+  nexthops2.setUri("nexthop2");
+  nexthops2.setCost(99);
+  rt.addNexthops(nexthops2);
+
+  BOOST_CHECK_EQUAL(rt.getNextHops().size(), 1);
+
+  nexthops = rt.getNextHops();
+  it = nexthops.begin();
+  BOOST_CHECK_EQUAL(it->getUri(), "nexthop2");
+  BOOST_CHECK_EQUAL(it->getCost(), 99);
+}
+
+BOOST_AUTO_TEST_CASE(RoutingTableEntryOutputStream)
+{
+  RoutingTable rt;
+  Destination des1;
+  des1.setName("dest1");
+  rt.setDestination(des1);
+
+  NextHop nexthops1;
+  nexthops1.setUri("nexthop1");
+  nexthops1.setCost(99);
+  rt.addNexthops(nexthops1);
+
+  std::ostringstream os;
+  os << rt;
+
+  BOOST_CHECK_EQUAL(os.str(), "Routing Table: \n"
+                                  "Destination: /dest1\n"
+                                  "Nexthops: NexthopList(\n"
+                                  "NextHop(Uri: nexthop1, Cost: 99)\n"
+                                  "\n)");
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace test
+} // namespace tlv
+} // namespace nlsr
diff --git a/tests/tlv/test-routing-table.cpp b/tests/tlv/test-routing-table.cpp
new file mode 100644
index 0000000..c4b798f
--- /dev/null
+++ b/tests/tlv/test-routing-table.cpp
@@ -0,0 +1,169 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014-2018,  The University of Memphis,
+ *                           Regents of the University of California,
+ *                           Arizona Board of Regents.
+ *
+ * This file is part of NLSR (Named-data Link State Routing).
+ * See AUTHORS.md for complete list of NLSR authors and contributors.
+ *
+ * NLSR is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+#include "tlv/routing-table-status.hpp"
+
+#include "../boost-test.hpp"
+
+namespace nlsr {
+namespace tlv {
+namespace test {
+
+BOOST_AUTO_TEST_SUITE(TlvTestRoutingTable)
+
+const uint8_t RoutingTableData1[] =
+{
+  // Header
+  0x90, 0x22,
+  // Routing table entry
+  0x91, 0x20,
+    // Destination
+    0x8e, 0x09, 0x07, 0x07, 0x08, 0x05, 0x64, 0x65, 0x73, 0x74, 0x31,
+    // Nexthop
+    0x8f, 0x13, 0x8d, 0x07, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f, 0x70, 0x86, 0x08, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0xfa, 0x3f
+};
+
+const uint8_t RoutingTableData2[] =
+{
+  // Header
+  0x90, 0x00
+};
+
+BOOST_AUTO_TEST_CASE(RoutingTableEncode1)
+{
+  RoutingTableStatus rtStatus;
+
+  Destination des;
+  des.setName("dest1");
+
+  // RoutingtableEntry
+  RoutingTable rt;
+  rt.setDestination(des);
+
+  NextHop nexthops;
+  nexthops.setUri("nexthop");
+  nexthops.setCost(1.65);
+  rt.addNexthops(nexthops);
+
+  rtStatus.addRoutingTable(rt);
+
+  const ndn::Block& wire = rtStatus.wireEncode();
+
+  BOOST_REQUIRE_EQUAL_COLLECTIONS(RoutingTableData1,
+                                  RoutingTableData1 + sizeof(RoutingTableData1),
+                                  wire.begin(), wire.end());
+}
+
+BOOST_AUTO_TEST_CASE(RoutingTableEncode2)
+{
+  RoutingTableStatus rtStatus;
+
+  const ndn::Block& wire = rtStatus.wireEncode();
+
+  BOOST_REQUIRE_EQUAL_COLLECTIONS(RoutingTableData2,
+                                  RoutingTableData2 + sizeof(RoutingTableData2),
+                                  wire.begin(), wire.end());
+}
+
+BOOST_AUTO_TEST_CASE(RoutingTableDecode1)
+{
+  RoutingTableStatus rtStatus;
+
+  rtStatus.wireDecode(ndn::Block(RoutingTableData1, sizeof(RoutingTableData1)));
+
+  std::list<RoutingTable> rte = rtStatus.getRoutingtable();
+  std::list<RoutingTable>::const_iterator it1 = rte.begin();
+
+  Destination des1 = it1->getDestination();
+  BOOST_CHECK_EQUAL(des1.getName(), "dest1");
+
+  std::list<NextHop> nexthops = it1->getNextHops();
+  std::list<NextHop>::const_iterator it2 = nexthops.begin();
+  BOOST_CHECK_EQUAL(it2->getUri(), "nexthop");
+  BOOST_CHECK_EQUAL(it2->getCost(), 1.65);
+
+  BOOST_CHECK_EQUAL(rtStatus.hasRoutingTable(), true);
+}
+
+BOOST_AUTO_TEST_CASE(RoutingTableDecode2)
+{
+  RoutingTableStatus rtStatus;
+
+  rtStatus.wireDecode(ndn::Block(RoutingTableData2, sizeof(RoutingTableData2)));
+
+  BOOST_CHECK_EQUAL(rtStatus.hasRoutingTable(), false);
+}
+
+BOOST_AUTO_TEST_CASE(RoutingTableClear)
+{
+  RoutingTableStatus rtStatus;
+  Destination des;
+  des.setName("dest1");
+
+  // RoutingtableEntry
+  RoutingTable rt;
+  rt.setDestination(des);
+
+  NextHop nexthops;
+  nexthops.setUri("nexthop");
+  nexthops.setCost(1.65);
+  rt.addNexthops(nexthops);
+
+  rtStatus.addRoutingTable(rt);
+
+  BOOST_CHECK_EQUAL(rtStatus.hasRoutingTable(), true);
+  rtStatus.clearRoutingTable();
+  BOOST_CHECK_EQUAL(rtStatus.hasRoutingTable(), false);
+}
+
+BOOST_AUTO_TEST_CASE(RoutingTableOutputStream)
+{
+  RoutingTableStatus rtStatus;
+  Destination des;
+  des.setName("dest1");
+
+  // RoutingtableEntry
+  RoutingTable rt;
+  rt.setDestination(des);
+
+  NextHop nexthops;
+  nexthops.setUri("nexthop");
+  nexthops.setCost(99);
+  rt.addNexthops(nexthops);
+
+  rtStatus.addRoutingTable(rt);
+
+  std::ostringstream os;
+  os << rtStatus;
+
+  BOOST_CHECK_EQUAL(os.str(), "Routing Table Status: \n"
+                                "Routing Table: \n"
+                                  "Destination: /dest1\n"
+                                  "Nexthops: NexthopList(\n"
+                                  "NextHop(Uri: nexthop, Cost: 99)\n"
+                                  "\n)");
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace test
+} // namespace tlv
+} // namespace nlsr