diff --git a/tests/daemon/rib/create-route.hpp b/tests/daemon/rib/create-route.hpp
new file mode 100644
index 0000000..b248575
--- /dev/null
+++ b/tests/daemon/rib/create-route.hpp
@@ -0,0 +1,53 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2014-2019,  Regents of the University of California,
+ *                           Arizona Board of Regents,
+ *                           Colorado State University,
+ *                           University Pierre & Marie Curie, Sorbonne University,
+ *                           Washington University in St. Louis,
+ *                           Beijing Institute of Technology,
+ *                           The University of Memphis.
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NFD_TESTS_DAEMON_RIB_CREATE_ROUTE_HPP
+#define NFD_TESTS_DAEMON_RIB_CREATE_ROUTE_HPP
+
+#include "rib/route.hpp"
+
+namespace nfd {
+namespace rib {
+namespace tests {
+
+inline Route
+createRoute(uint64_t faceId,
+            std::underlying_type_t<ndn::nfd::RouteOrigin> origin,
+            uint64_t cost = 0,
+            std::underlying_type_t<ndn::nfd::RouteFlags> flags = ndn::nfd::ROUTE_FLAGS_NONE)
+{
+  Route r;
+  r.faceId = faceId;
+  r.origin = static_cast<ndn::nfd::RouteOrigin>(origin);
+  r.cost = cost;
+  r.flags = flags;
+  return r;
+}
+
+} // namespace tests
+} // namespace rib
+} // namespace nfd
+
+#endif // NFD_TESTS_DAEMON_RIB_CREATE_ROUTE_HPP
diff --git a/tests/daemon/rib/fib-updates-common.hpp b/tests/daemon/rib/fib-updates-common.hpp
new file mode 100644
index 0000000..4668af5
--- /dev/null
+++ b/tests/daemon/rib/fib-updates-common.hpp
@@ -0,0 +1,159 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2014-2019,  Regents of the University of California,
+ *                           Arizona Board of Regents,
+ *                           Colorado State University,
+ *                           University Pierre & Marie Curie, Sorbonne University,
+ *                           Washington University in St. Louis,
+ *                           Beijing Institute of Technology,
+ *                           The University of Memphis.
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef NFD_TESTS_DAEMON_RIB_FIB_UPDATES_COMMON_HPP
+#define NFD_TESTS_DAEMON_RIB_FIB_UPDATES_COMMON_HPP
+
+#include "rib/fib-updater.hpp"
+
+#include "tests/identity-management-fixture.hpp"
+#include "tests/daemon/rib/create-route.hpp"
+
+#include <ndn-cxx/util/dummy-client-face.hpp>
+
+namespace nfd {
+namespace rib {
+namespace tests {
+
+inline bool
+compareNameFaceIdCostAction(const FibUpdate& lhs, const FibUpdate& rhs)
+{
+  if (lhs.name < rhs.name) {
+    return true;
+  }
+  else if (lhs.name == rhs.name) {
+    if (lhs.faceId < rhs.faceId) {
+      return true;
+    }
+    else if (lhs.faceId == rhs.faceId) {
+      if (lhs.cost < rhs.cost) {
+        return true;
+      }
+      else if (lhs.cost == rhs.cost) {
+        return lhs.action < rhs.action;
+      }
+    }
+  }
+
+  return false;
+}
+
+class FibUpdatesFixture : public nfd::tests::IdentityManagementFixture
+{
+public:
+  FibUpdatesFixture()
+    : face(g_io, m_keyChain)
+    , controller(face, m_keyChain)
+    , fibUpdater(rib, controller)
+  {
+  }
+
+  void
+  insertRoute(const Name& name, uint64_t faceId,
+              std::underlying_type_t<ndn::nfd::RouteOrigin> origin,
+              uint64_t cost,
+              std::underlying_type_t<ndn::nfd::RouteFlags> flags)
+  {
+    Route route = createRoute(faceId, origin, cost, flags);
+
+    RibUpdate update;
+    update.setAction(RibUpdate::REGISTER)
+          .setName(name)
+          .setRoute(route);
+
+    simulateSuccessfulResponse();
+    rib.beginApplyUpdate(update, nullptr, nullptr);
+  }
+
+  void
+  eraseRoute(const Name& name, uint64_t faceId,
+             std::underlying_type_t<ndn::nfd::RouteOrigin> origin)
+  {
+    Route route = createRoute(faceId, origin, 0, 0);
+
+    RibUpdate update;
+    update.setAction(RibUpdate::UNREGISTER)
+          .setName(name)
+          .setRoute(route);
+
+    simulateSuccessfulResponse();
+    rib.beginApplyUpdate(update, nullptr, nullptr);
+  }
+
+  void
+  destroyFace(uint64_t faceId)
+  {
+    simulateSuccessfulResponse();
+    rib.beginRemoveFace(faceId);
+  }
+
+  const FibUpdater::FibUpdateList&
+  getFibUpdates()
+  {
+    fibUpdates.clear();
+    fibUpdates = fibUpdater.m_updatesForBatchFaceId;
+    fibUpdates.insert(fibUpdates.end(), fibUpdater.m_updatesForNonBatchFaceId.begin(),
+                                        fibUpdater.m_updatesForNonBatchFaceId.end());
+
+    return fibUpdates;
+  }
+
+  FibUpdater::FibUpdateList
+  getSortedFibUpdates()
+  {
+    FibUpdater::FibUpdateList updates = getFibUpdates();
+    updates.sort(&compareNameFaceIdCostAction);
+    return updates;
+  }
+
+  void
+  clearFibUpdates()
+  {
+    fibUpdater.m_updatesForBatchFaceId.clear();
+    fibUpdater.m_updatesForNonBatchFaceId.clear();
+  }
+
+private:
+  void
+  simulateSuccessfulResponse()
+  {
+    rib.mockFibResponse = [] (const RibUpdateBatch&) { return true; };
+    rib.wantMockFibResponseOnce = true;
+  }
+
+public:
+  ndn::util::DummyClientFace face;
+  ndn::nfd::Controller controller;
+
+  Rib rib;
+  FibUpdater fibUpdater;
+  FibUpdater::FibUpdateList fibUpdates;
+};
+
+} // namespace tests
+} // namespace rib
+} // namespace nfd
+
+#endif // NFD_TESTS_DAEMON_RIB_FIB_UPDATES_COMMON_HPP
diff --git a/tests/daemon/rib/fib-updates-erase-face.t.cpp b/tests/daemon/rib/fib-updates-erase-face.t.cpp
new file mode 100644
index 0000000..d55f207
--- /dev/null
+++ b/tests/daemon/rib/fib-updates-erase-face.t.cpp
@@ -0,0 +1,431 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014-2016,  Regents of the University of California,
+ *                           Arizona Board of Regents,
+ *                           Colorado State University,
+ *                           University Pierre & Marie Curie, Sorbonne University,
+ *                           Washington University in St. Louis,
+ *                           Beijing Institute of Technology,
+ *                           The University of Memphis.
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "rib/rib.hpp"
+
+#include "tests/test-common.hpp"
+#include "fib-updates-common.hpp"
+
+namespace nfd {
+namespace rib {
+namespace tests {
+
+BOOST_FIXTURE_TEST_SUITE(TestFibUpdates, FibUpdatesFixture)
+
+BOOST_AUTO_TEST_SUITE(EraseFace)
+
+BOOST_AUTO_TEST_CASE(WithInheritedFace_Root)
+{
+  insertRoute("/", 1, 0, 10, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a", 1, 0, 50, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a/b", 2, 0, 75, 0);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 1 updates: 1 to remove face 1 from /
+  eraseRoute("/", 1, 0);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 1);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::REMOVE_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(WithInheritedFace)
+{
+  insertRoute("/a", 5, 0, 10, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a", 5, 255, 5, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a", 2, 0, 20, 0);
+  insertRoute("/a/b", 3, 0, 5, 0);
+
+  // /a should have face 5 with cost 10; /a/b should have face 3 with cost 5 and
+  // face 5 with cost 10
+  eraseRoute("/a", 5, 255);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 2 updates: 1 to remove face 3 from /a/b and one to remove inherited route
+  eraseRoute("/a/b", 3, 0);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 2);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 3);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::REMOVE_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 5);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::REMOVE_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(MultipleFaces)
+{
+  insertRoute("/a", 5, 0, 10, 0);
+  insertRoute("/a", 5, 255, 5, 0);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 1 updates: 1 to update cost to 10 for /a
+  eraseRoute("/a", 5, 255);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 1);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 5);
+  BOOST_CHECK_EQUAL(update->cost, 10);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(NoFlags_NoCaptureChange_NoCaptureOnRoute)
+{
+  insertRoute("/", 1, 0, 5, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a", 2, 0, 10, 0);
+  insertRoute("/a/b", 3, 0, 10, 0);
+  insertRoute("/a/c", 1, 0, 100, 0);
+  insertRoute("/a", 1, 128, 50, 0);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 1 updates: 1 to update cost for /a
+  eraseRoute("/a", 1, 128);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 1);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost, 5);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(MakeRibEmpty)
+{
+  insertRoute("/", 1, 0, 5, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 1 updates: 1 to remove route from /
+  eraseRoute("/", 1, 0);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 1);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::REMOVE_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(NoFlags_NoCaptureChange_CaptureOnRoute)
+{
+  insertRoute("/", 1, 0, 5, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a", 2, 0, 10, ndn::nfd::ROUTE_FLAG_CAPTURE);
+  insertRoute("/a/b", 3, 0, 10, 0);
+  insertRoute("/a/c", 1, 0, 100, 0);
+  insertRoute("/a", 1, 128, 50, 0);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 1 updates: 1 to remove route from /a
+  eraseRoute("/a", 1, 128);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 1);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::REMOVE_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(BothFlags_NoCaptureChange_CaptureOnRoute)
+{
+  insertRoute("/", 1, 0, 5, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a", 2, 0, 10, ndn::nfd::ROUTE_FLAG_CAPTURE);
+  insertRoute("/a/b", 3, 0, 10, 0);
+  insertRoute("/a/c", 1, 0, 100, 0);
+  insertRoute("/a", 1, 128, 50, (ndn::nfd::ROUTE_FLAG_CHILD_INHERIT |
+                                     ndn::nfd::ROUTE_FLAG_CAPTURE));
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 2 updates: 1 to remove face1 from /a and
+  // 1 to remove face1 from /a/b
+  eraseRoute("/a", 1, 128);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 2);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::REMOVE_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::REMOVE_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(BothFlags_CaptureChange_NoCaptureOnRoute)
+{
+  insertRoute("/", 1, 0, 5, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a", 2, 0, 10, 0);
+  insertRoute("/a/b", 3, 0, 10, 0);
+  insertRoute("/a/c", 1, 0, 100, 0);
+  insertRoute("/a", 1, 128, 50, (ndn::nfd::ROUTE_FLAG_CHILD_INHERIT |
+                                     ndn::nfd::ROUTE_FLAG_CAPTURE));
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 2 updates: 1 to add face1 to /a and
+  // 1 to add face1 to /a/b
+  eraseRoute("/a", 1, 128);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 2);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost, 5);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost, 5);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(ChildInherit_NoCaptureChange_NoCaptureOnRoute)
+{
+  insertRoute("/", 1, 0, 5, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a", 2, 0, 10, 0);
+  insertRoute("/a/b", 3, 0, 10, 0);
+  insertRoute("/a/c", 1, 0, 100, 0);
+  insertRoute("/a", 1, 128, 50, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 2 updates: 2 to add face1 to /a and /a/b
+  eraseRoute("/a", 1, 128);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 2);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost, 5);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost, 5);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(ChildInherit_NoCaptureChange_CaptureOnRoute)
+{
+  insertRoute("/", 1, 0, 5, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a", 2, 0, 10, ndn::nfd::ROUTE_FLAG_CAPTURE);
+  insertRoute("/a/b", 3, 0, 10, 0);
+  insertRoute("/a/c", 1, 0, 100, 0);
+  insertRoute("/a", 1, 128, 50, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 2 updates: 2 to remove face 1 from /a and /a/b
+  eraseRoute("/a", 1, 128);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 2);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::REMOVE_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::REMOVE_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(Capture_CaptureChange_NoCaptureOnRoute)
+{
+  insertRoute("/", 1, 0, 5, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a", 2, 0, 10, 0);
+  insertRoute("/a/b", 3, 0, 10, 0);
+  insertRoute("/a/c", 1, 0, 100, 0);
+  insertRoute("/a", 1, 128, 50, ndn::nfd::ROUTE_FLAG_CAPTURE);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 2 updates: 1 to update cost on /a and
+  // 1 to add face1 to /a/b
+  eraseRoute("/a", 1 ,128);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 2);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost, 5);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost, 5);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(Capture_NoCaptureChange_CaptureOnRoute)
+{
+  insertRoute("/", 1, 0, 5, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a", 2, 0, 10, ndn::nfd::ROUTE_FLAG_CAPTURE);
+  insertRoute("/a/b", 3, 0, 10, 0);
+  insertRoute("/a/c", 1, 0, 100, 0);
+  insertRoute("/a", 1, 128, 50, ndn::nfd::ROUTE_FLAG_CAPTURE);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 1 updates: 1 to remove route from /a
+  eraseRoute("/a", 1, 128);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 1);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::REMOVE_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(EraseFaceById)
+{
+  insertRoute("/", 1, 0, 5, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a", 3, 0, 10, 0);
+  insertRoute("/a/b", 4, 0, 10, 0);
+  insertRoute("/a/c", 1, 0, 100, 0);
+  insertRoute("/a", 2, 128, 50, ndn::nfd::ROUTE_FLAG_CAPTURE);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 2 updates: 2 to add face ID 1 to /a and /a/b
+  destroyFace(2);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 2);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(RemoveNamespaceWithAncestorFace) // Bug #2757
+{
+  uint64_t faceId = 263;
+
+  // Register route back to laptop
+  insertRoute("/", faceId, ndn::nfd::ROUTE_ORIGIN_STATIC, 0, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+
+  // Register remote prefix
+  insertRoute("/Z/A", faceId, ndn::nfd::ROUTE_ORIGIN_CLIENT, 15, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Unregister remote prefix
+  // Should create an update to remove the remote prefix but should not create
+  // an update to add the ancestor route to the remote prefix's namespace
+  eraseRoute("/Z/A", faceId, ndn::nfd::ROUTE_ORIGIN_CLIENT);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 1);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/Z/A");
+  BOOST_CHECK_EQUAL(update->faceId, faceId);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::REMOVE_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(RemoveNamespaceWithCapture) // Bug #3404
+{
+  insertRoute("/", 262, ndn::nfd::ROUTE_ORIGIN_STATIC, 0, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+
+  uint64_t appFaceId = 264;
+  ndn::Name ndnConPrefix("/ndn/edu/site/ndnrtc/user/username/streams/main_camera/low");
+  insertRoute(ndnConPrefix, appFaceId, ndn::nfd::ROUTE_ORIGIN_CLIENT, 0,
+              ndn::nfd::ROUTE_FLAG_CHILD_INHERIT | ndn::nfd::ROUTE_FLAG_CAPTURE);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  destroyFace(appFaceId);
+
+  // FibUpdater should not generate any inherited routes for the erased RibEntry
+  BOOST_CHECK_EQUAL(fibUpdater.m_inheritedRoutes.size(), 0);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // EraseFace
+
+BOOST_AUTO_TEST_SUITE_END() // FibUpdates
+
+} // namespace tests
+} // namespace rib
+} // namespace nfd
diff --git a/tests/daemon/rib/fib-updates-new-face.t.cpp b/tests/daemon/rib/fib-updates-new-face.t.cpp
new file mode 100644
index 0000000..49cd56f
--- /dev/null
+++ b/tests/daemon/rib/fib-updates-new-face.t.cpp
@@ -0,0 +1,272 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014-2015,  Regents of the University of California,
+ *                           Arizona Board of Regents,
+ *                           Colorado State University,
+ *                           University Pierre & Marie Curie, Sorbonne University,
+ *                           Washington University in St. Louis,
+ *                           Beijing Institute of Technology,
+ *                           The University of Memphis.
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "rib/rib.hpp"
+
+#include "tests/test-common.hpp"
+#include "fib-updates-common.hpp"
+
+namespace nfd {
+namespace rib {
+namespace tests {
+
+BOOST_FIXTURE_TEST_SUITE(TestFibUpdates, FibUpdatesFixture)
+
+BOOST_AUTO_TEST_SUITE(NewFace)
+
+BOOST_AUTO_TEST_CASE(Basic)
+{
+  // should generate 1 update
+  insertRoute("/", 1, 0, 50, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+
+  FibUpdater::FibUpdateList updates = getFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 1);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+
+  BOOST_CHECK_EQUAL(update->name,  "/");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost,   50);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  // Clear any updates generated from previous insertions
+  clearFibUpdates();
+
+  // should generate 2 updates
+  insertRoute("/a", 2, 0, 50, 0);
+
+  updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 2);
+
+  update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost,   50);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 2);
+  BOOST_CHECK_EQUAL(update->cost,   50);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // should generate 2 updates
+  insertRoute("/a/b", 3, 0, 10, 0);
+
+  updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 2);
+
+  update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost,   50);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 3);
+  BOOST_CHECK_EQUAL(update->cost,   10);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(UpdateOnLowerCostNoChildInherit)
+{
+  insertRoute("/", 1, 0, 50, 0);
+
+  // Clear any updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 0 updates
+  insertRoute("/", 1, 128, 75, 0);
+
+  BOOST_CHECK_EQUAL(getFibUpdates().size(), 0);
+}
+
+BOOST_AUTO_TEST_CASE(UpdateOnLowerCostOnly)
+{
+  insertRoute("/",  1, 0, 50, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a", 2, 0, 10, 0);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 2 updates: to update cost for face 1 on / and /a
+  insertRoute("/", 1, 0, 25, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 2);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost,   25);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost,   25);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 0 updates
+  insertRoute("/", 1, 128, 50, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+
+  BOOST_CHECK_EQUAL(getFibUpdates().size(), 0);
+}
+
+BOOST_AUTO_TEST_CASE(NoCaptureChangeWithoutChildInherit)
+{
+  insertRoute("/",    1, 0, 50, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a",   2, 0, 10, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a/b", 3, 0, 10, 0);
+  insertRoute("/a/c", 4, 0, 10, ndn::nfd::ROUTE_FLAG_CAPTURE);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 1 update: 1 to add face 5 to /a
+  insertRoute("/a", 5, 128, 50, 0);
+
+  const FibUpdater::FibUpdateList& updates = getFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 1);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 5);
+  BOOST_CHECK_EQUAL(update->cost,   50);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(NoCaptureChangeWithChildInherit)
+{
+  insertRoute("/",    1, 0, 50, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a",   2, 0, 10, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a/b", 3, 0, 10, 0);
+  insertRoute("/a/c", 4, 0, 10, ndn::nfd::ROUTE_FLAG_CAPTURE);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 2 updates: one for the inserted route and
+  // one to add route to /a/b
+  insertRoute("/a", 4, 128, 5, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 2);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 4);
+  BOOST_CHECK_EQUAL(update->cost,   5);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 4);
+  BOOST_CHECK_EQUAL(update->cost,   5);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(CaptureTurnedOnWithoutChildInherit)
+{
+  insertRoute("/",    1, 0, 50, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a",   2, 0, 10, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a/b", 3, 0, 10, 0);
+  insertRoute("/a/c", 4, 0, 10, 0);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 3 updates:
+  // - one for the inserted route for /a and
+  // - two to remove face1 from /a/b and /a/c
+  insertRoute("/a", 1, 128, 50, ndn::nfd::ROUTE_FLAG_CAPTURE);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 3);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost,   50);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::REMOVE_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a/c");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::REMOVE_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(CaptureTurnedOnWithChildInherit)
+{
+  insertRoute("/",    1, 0, 50, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a",   2, 0, 10, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a/b", 3, 0, 10, 0);
+  insertRoute("/a/c", 4, 0, 10, 0);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 2 updates:
+  // - one for the inserted route for /a and
+  // - one to update /a/b with the new cost
+  insertRoute("/a", 1, 128, 50, (ndn::nfd::ROUTE_FLAG_CAPTURE |
+                                     ndn::nfd::ROUTE_FLAG_CHILD_INHERIT));
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 3);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost,   50);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost,   50);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // NewFace
+
+BOOST_AUTO_TEST_SUITE_END() // FibUpdates
+
+} // namespace tests
+} // namespace rib
+} // namespace nfd
diff --git a/tests/daemon/rib/fib-updates-new-namespace.t.cpp b/tests/daemon/rib/fib-updates-new-namespace.t.cpp
new file mode 100644
index 0000000..90abd31
--- /dev/null
+++ b/tests/daemon/rib/fib-updates-new-namespace.t.cpp
@@ -0,0 +1,200 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014-2015,  Regents of the University of California,
+ *                           Arizona Board of Regents,
+ *                           Colorado State University,
+ *                           University Pierre & Marie Curie, Sorbonne University,
+ *                           Washington University in St. Louis,
+ *                           Beijing Institute of Technology,
+ *                           The University of Memphis.
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "rib/rib.hpp"
+
+#include "tests/test-common.hpp"
+#include "fib-updates-common.hpp"
+
+namespace nfd {
+namespace rib {
+namespace tests {
+
+BOOST_FIXTURE_TEST_SUITE(TestFibUpdates, FibUpdatesFixture)
+
+BOOST_AUTO_TEST_SUITE(NewNamespace)
+
+BOOST_AUTO_TEST_CASE(NoFlags)
+{
+  // No flags, empty RIB, should generate 1 update for the inserted route
+  insertRoute("/a/b", 1, 0, 10, 0);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 1);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost, 10);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  // Reset RIB
+  eraseRoute("/a/b", 1, 0);
+  clearFibUpdates();
+
+  // Parent with child inherit flag
+  insertRoute("/a", 2, 0, 70, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a", 3, 0, 30, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 3 updates, 1 for the inserted route and 2 from inheritance
+  insertRoute("/a/b", 1, 0, 10, 0);
+
+  updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 3);
+
+  update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost, 10);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 2);
+  BOOST_CHECK_EQUAL(update->cost, 70);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 3);
+  BOOST_CHECK_EQUAL(update->cost, 30);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(BothFlags)
+{
+  // Empty RIB, should generate 1 update for the inserted route
+  insertRoute("/a", 1, 0, 10, (ndn::nfd::ROUTE_FLAG_CHILD_INHERIT | ndn::nfd::ROUTE_FLAG_CAPTURE));
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 1);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost, 10);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  // Reset RIB
+  eraseRoute("/a", 1, 0);
+  clearFibUpdates();
+
+  insertRoute("/", 2, 0, 70, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a/b", 3, 0, 30, 0);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 3 updates, 1 for the inserted route, 1 to add the route to the child,
+  // and 1 to remove the previously inherited route
+  insertRoute("/a", 1, 0, 10, (ndn::nfd::ROUTE_FLAG_CHILD_INHERIT | ndn::nfd::ROUTE_FLAG_CAPTURE));
+
+  updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 3);
+
+  update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost, 10);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost, 10);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 2);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::REMOVE_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(ChildInherit)
+{
+  insertRoute("/", 1, 0, 50, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a/b", 2, 0, 10, 0);
+  insertRoute("/a/c", 3, 0, 10, ndn::nfd::ROUTE_FLAG_CAPTURE);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 2 updates: 1 for the inserted route and 1 to add the route to "/a/b"
+  insertRoute("/a", 1, 0, 10, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 2);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost, 10);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost, 10);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(Capture)
+{
+  insertRoute("/", 1, 0, 50, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a/b", 2, 0, 10, 0);
+  insertRoute("/a/c", 3, 0, 10, ndn::nfd::ROUTE_FLAG_CAPTURE);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 2 updates: 1 for the inserted route and
+  // 1 to remove the inherited route from "/a/b"
+  insertRoute("/a", 1, 0, 10, ndn::nfd::ROUTE_FLAG_CAPTURE);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 2);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost, 10);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::REMOVE_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // NewNamespace
+
+BOOST_AUTO_TEST_SUITE_END() // FibUpdates
+
+} // namespace tests
+} // namespace rib
+} // namespace nfd
diff --git a/tests/daemon/rib/fib-updates-update-face.t.cpp b/tests/daemon/rib/fib-updates-update-face.t.cpp
new file mode 100644
index 0000000..54cd2d4
--- /dev/null
+++ b/tests/daemon/rib/fib-updates-update-face.t.cpp
@@ -0,0 +1,266 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014-2015,  Regents of the University of California,
+ *                           Arizona Board of Regents,
+ *                           Colorado State University,
+ *                           University Pierre & Marie Curie, Sorbonne University,
+ *                           Washington University in St. Louis,
+ *                           Beijing Institute of Technology,
+ *                           The University of Memphis.
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "rib/rib.hpp"
+
+#include "tests/test-common.hpp"
+#include "fib-updates-common.hpp"
+
+namespace nfd {
+namespace rib {
+namespace tests {
+
+BOOST_FIXTURE_TEST_SUITE(TestFibUpdates, FibUpdatesFixture)
+
+BOOST_AUTO_TEST_SUITE(UpdateFace)
+
+BOOST_AUTO_TEST_CASE(TurnOffChildInheritLowerCost)
+{
+  insertRoute("/", 1, 0, 50, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a", 2, 0, 10, 0);
+  insertRoute("/", 1, 128, 25, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 2 updates: 1 to update the cost of / face 1 to 50 and
+  // 1 to update the cost of /a face 1 to 50
+  insertRoute("/", 1, 128, 75, 0);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 2);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost,   50);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost,   50);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(UpdateOnLowerCostOnly)
+{
+  insertRoute("/", 1, 0, 50, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a", 2, 0, 10, 0);
+  insertRoute("/", 1, 128, 100, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 0 updates
+  insertRoute("/", 1, 128, 75, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 0);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 2 updates
+  insertRoute("/", 1, 128, 25, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+
+  updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 2);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost,   25);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost,   25);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(NoChangeInCost)
+{
+  insertRoute("/", 1, 0, 50, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a", 2, 0, 100, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a/b", 3, 0, 10, 0);
+  insertRoute("/a/c", 4, 0, 10, ndn::nfd::ROUTE_FLAG_CAPTURE);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 0 updates
+  insertRoute("/a", 2, 0, 100, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 0);
+}
+
+BOOST_AUTO_TEST_CASE(ChangeCost)
+{
+  insertRoute("/", 1, 0, 50, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a", 2, 0, 100, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a/b", 3, 0, 10, 0);
+  insertRoute("/a/c", 4, 0, 10, ndn::nfd::ROUTE_FLAG_CAPTURE);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Should generate 2 updates: 1 to add face2 with new cost to /a and
+  // 1 to add face2 with new cost to /a/b
+  insertRoute("/a", 2, 0, 300, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 2);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 2);
+  BOOST_CHECK_EQUAL(update->cost,   300);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 2);
+  BOOST_CHECK_EQUAL(update->cost,   300);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(TurnOnChildInherit)
+{
+  insertRoute("/", 1, 0, 50, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a", 2, 0, 10, 0);
+  insertRoute("/a/b", 3, 0, 10, 0);
+  insertRoute("/a/c", 4, 0, 10, ndn::nfd::ROUTE_FLAG_CAPTURE);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Turn on child inherit flag for the entry in /a
+  // Should generate 1 updates: 1 to add face to /a/b
+  insertRoute("/a", 2, 0, 10, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 1);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 2);
+  BOOST_CHECK_EQUAL(update->cost,   10);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(TurnOffChildInherit)
+{
+  insertRoute("/", 1, 0, 50, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a", 1, 0, 100, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a/b", 2, 0, 10, 0);
+  insertRoute("/a/c", 1, 0, 25, 0);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Turn off child inherit flag for the entry in /a
+  // Should generate 1 update: 1 to add face1 to /a/b
+  insertRoute("/a", 1, 0, 100, 0);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 1);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost,   50);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(TurnOnCapture)
+{
+  insertRoute("/", 1, 0, 50, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a", 2, 0, 10, 0);
+  insertRoute("/a/b", 3, 0, 10, 0);
+  insertRoute("/a/c", 1, 0, 10, 0);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Turn on capture flag for the entry in /a
+  // Should generate 2 updates: 1 to remove face1 from /a and
+  // 1 to remove face1 from /a/b
+  insertRoute("/a", 2, 0, 10, ndn::nfd::ROUTE_FLAG_CAPTURE);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 2);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::REMOVE_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::REMOVE_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_CASE(TurnOffCapture)
+{
+  insertRoute("/", 1, 0, 50, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  insertRoute("/a", 2, 0, 10, ndn::nfd::ROUTE_FLAG_CAPTURE);
+  insertRoute("/a/b", 3, 0, 10, 0);
+  insertRoute("/a/c", 1, 0, 10, 0);
+
+  // Clear updates generated from previous insertions
+  clearFibUpdates();
+
+  // Turn off capture flag for the entry in /a
+  // Should generate 2 updates: 1 to add face1 to /a and
+  // 1 to add face1 to /a/b
+  insertRoute("/a", 2, 0, 10, 0);
+
+  FibUpdater::FibUpdateList updates = getSortedFibUpdates();
+  BOOST_REQUIRE_EQUAL(updates.size(), 2);
+
+  FibUpdater::FibUpdateList::const_iterator update = updates.begin();
+  BOOST_CHECK_EQUAL(update->name,  "/a");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost, 50);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+
+  ++update;
+  BOOST_CHECK_EQUAL(update->name,  "/a/b");
+  BOOST_CHECK_EQUAL(update->faceId, 1);
+  BOOST_CHECK_EQUAL(update->cost, 50);
+  BOOST_CHECK_EQUAL(update->action, FibUpdate::ADD_NEXTHOP);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // UpdateFace
+
+BOOST_AUTO_TEST_SUITE_END() // FibUpdates
+
+} // namespace tests
+} // namespace rib
+} // namespace nfd
diff --git a/tests/daemon/rib/readvertise/client-to-nlsr-readvertise-policy.t.cpp b/tests/daemon/rib/readvertise/client-to-nlsr-readvertise-policy.t.cpp
new file mode 100644
index 0000000..6925de1
--- /dev/null
+++ b/tests/daemon/rib/readvertise/client-to-nlsr-readvertise-policy.t.cpp
@@ -0,0 +1,76 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2014-2018,  Regents of the University of California,
+ *                           Arizona Board of Regents,
+ *                           Colorado State University,
+ *                           University Pierre & Marie Curie, Sorbonne University,
+ *                           Washington University in St. Louis,
+ *                           Beijing Institute of Technology,
+ *                           The University of Memphis.
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "rib/readvertise/client-to-nlsr-readvertise-policy.hpp"
+
+#include "tests/test-common.hpp"
+
+namespace nfd {
+namespace rib {
+namespace tests {
+
+using namespace nfd::tests;
+
+BOOST_AUTO_TEST_SUITE(Readvertise)
+BOOST_FIXTURE_TEST_SUITE(TestClientToNlsrReadvertisePolicy, BaseFixture)
+
+BOOST_AUTO_TEST_CASE(ReadvertiseClientRoute)
+{
+  auto entry = make_shared<RibEntry>();
+  entry->setName("/test/A");
+  Route route;
+  route.origin = ndn::nfd::ROUTE_ORIGIN_CLIENT;
+  auto routeIt = entry->insertRoute(route).first;
+  RibRouteRef rrr{entry, routeIt};
+
+  ClientToNlsrReadvertisePolicy policy;
+  optional<ReadvertiseAction> action = policy.handleNewRoute(rrr);
+
+  BOOST_REQUIRE(action);
+  BOOST_CHECK_EQUAL(action->prefix, "/test/A");
+  BOOST_REQUIRE_EQUAL(action->signer, ndn::security::SigningInfo());
+}
+
+BOOST_AUTO_TEST_CASE(DontReadvertiseRoute)
+{
+  auto entry = make_shared<RibEntry>();
+  entry->setName("/test/A");
+  Route route;
+  route.origin = ndn::nfd::ROUTE_ORIGIN_NLSR;
+  auto routeIt = entry->insertRoute(route).first;
+  RibRouteRef rrr{entry, routeIt};
+
+  ClientToNlsrReadvertisePolicy policy;
+  optional<ReadvertiseAction> action = policy.handleNewRoute(rrr);
+
+  BOOST_CHECK(!action);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // TestClientToNlsrReadvertisePolicy
+BOOST_AUTO_TEST_SUITE_END() // Readvertise
+
+} // namespace tests
+} // namespace rib
+} // namespace nfd
diff --git a/tests/daemon/rib/readvertise/host-to-gateway-readvertise-policy.t.cpp b/tests/daemon/rib/readvertise/host-to-gateway-readvertise-policy.t.cpp
new file mode 100644
index 0000000..1b357cb
--- /dev/null
+++ b/tests/daemon/rib/readvertise/host-to-gateway-readvertise-policy.t.cpp
@@ -0,0 +1,114 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2014-2018,  Regents of the University of California,
+ *                           Arizona Board of Regents,
+ *                           Colorado State University,
+ *                           University Pierre & Marie Curie, Sorbonne University,
+ *                           Washington University in St. Louis,
+ *                           Beijing Institute of Technology,
+ *                           The University of Memphis.
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "rib/readvertise/host-to-gateway-readvertise-policy.hpp"
+
+#include "tests/identity-management-fixture.hpp"
+
+#include <ndn-cxx/security/signing-helpers.hpp>
+
+namespace nfd {
+namespace rib {
+namespace tests {
+
+using namespace nfd::tests;
+
+class HostToGatewayReadvertisePolicyFixture : public IdentityManagementFixture
+{
+public:
+  RibRouteRef
+  makeNewRoute(const Name& prefix) {
+    auto entry = make_shared<RibEntry>();
+    entry->setName(prefix);
+
+    Route route;
+    auto routeIt = entry->insertRoute(route).first;
+    return RibRouteRef{entry, routeIt};
+  }
+
+  shared_ptr<HostToGatewayReadvertisePolicy>
+  makePolicy(const ConfigSection& section = ConfigSection())
+  {
+    return make_shared<HostToGatewayReadvertisePolicy>(m_keyChain, section);
+  }
+};
+
+BOOST_AUTO_TEST_SUITE(Readvertise)
+BOOST_FIXTURE_TEST_SUITE(TestHostToGatewayReadvertisePolicy,
+                         HostToGatewayReadvertisePolicyFixture)
+
+BOOST_AUTO_TEST_CASE(PrefixToAdvertise)
+{
+  BOOST_REQUIRE(addIdentity("/A"));
+  BOOST_REQUIRE(addIdentity("/A/B"));
+  BOOST_REQUIRE(addIdentity("/C/nrd"));
+
+  auto test = [this] (Name routeName, optional<ReadvertiseAction> expectedAction) {
+    auto policy = makePolicy();
+    auto action = policy->handleNewRoute(makeNewRoute(routeName));
+
+    if (expectedAction) {
+      BOOST_REQUIRE(action);
+      BOOST_CHECK_EQUAL(action->prefix, expectedAction->prefix);
+      BOOST_REQUIRE_EQUAL(action->signer, expectedAction->signer);
+    }
+    else {
+      BOOST_REQUIRE(!action);
+    }
+  };
+
+  test("/D/app", nullopt);
+  test("/A/B/app", ReadvertiseAction{"/A", ndn::security::signingByIdentity("/A")});
+  test("/C/nrd", ReadvertiseAction{"/C", ndn::security::signingByIdentity("/C/nrd")});
+}
+
+BOOST_AUTO_TEST_CASE(DontReadvertise)
+{
+  auto policy = makePolicy();
+  BOOST_REQUIRE(!policy->handleNewRoute(makeNewRoute("/localhost/test")));
+  BOOST_REQUIRE(!policy->handleNewRoute(makeNewRoute("/localhop/nfd")));
+}
+
+BOOST_AUTO_TEST_CASE(LoadRefreshInterval)
+{
+  auto policy = makePolicy();
+  BOOST_CHECK_EQUAL(policy->getRefreshInterval(), time::seconds(25)); // default setting is 25
+
+  ConfigSection section;
+  section.put("refresh_interval_wrong", 10);
+  policy = makePolicy(section);
+  BOOST_CHECK_EQUAL(policy->getRefreshInterval(), time::seconds(25)); // wrong formate
+
+  section.put("refresh_interval", 10);
+  policy = makePolicy(section);
+  BOOST_CHECK_EQUAL(policy->getRefreshInterval(), time::seconds(10));
+}
+
+BOOST_AUTO_TEST_SUITE_END() // TestHostToGatewayReadvertisePolicy
+BOOST_AUTO_TEST_SUITE_END() // Readvertise
+
+} // namespace tests
+} // namespace rib
+} // namespace nfd
diff --git a/tests/daemon/rib/readvertise/nfd-rib-readvertise-destination.t.cpp b/tests/daemon/rib/readvertise/nfd-rib-readvertise-destination.t.cpp
new file mode 100644
index 0000000..4967788
--- /dev/null
+++ b/tests/daemon/rib/readvertise/nfd-rib-readvertise-destination.t.cpp
@@ -0,0 +1,257 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2014-2019,  Regents of the University of California,
+ *                           Arizona Board of Regents,
+ *                           Colorado State University,
+ *                           University Pierre & Marie Curie, Sorbonne University,
+ *                           Washington University in St. Louis,
+ *                           Beijing Institute of Technology,
+ *                           The University of Memphis.
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "rib/readvertise/nfd-rib-readvertise-destination.hpp"
+
+#include "tests/identity-management-fixture.hpp"
+#include "tests/test-common.hpp"
+
+#include <ndn-cxx/security/signing-info.hpp>
+#include <ndn-cxx/util/dummy-client-face.hpp>
+
+namespace nfd {
+namespace rib {
+namespace tests {
+
+using namespace nfd::tests;
+
+class NfdRibReadvertiseDestinationFixture : public IdentityManagementTimeFixture
+{
+public:
+  NfdRibReadvertiseDestinationFixture()
+    : nSuccessCallbacks(0)
+    , nFailureCallbacks(0)
+    , face(g_io, m_keyChain, {true, false})
+    , scheduler(g_io)
+    , controller(face, m_keyChain)
+    , dest(controller, rib, ndn::nfd::CommandOptions().setPrefix("/localhost/nlsr"))
+    , successCallback([this] { nSuccessCallbacks++; })
+    , failureCallback([this] (const std::string& str) { nFailureCallbacks++; })
+  {
+  }
+
+public:
+  uint32_t nSuccessCallbacks;
+  uint32_t nFailureCallbacks;
+
+protected:
+  ndn::util::DummyClientFace face;
+  ndn::util::Scheduler scheduler;
+  ndn::nfd::Controller controller;
+  Rib rib;
+  NfdRibReadvertiseDestination dest;
+  std::function<void()> successCallback;
+  std::function<void(const std::string&)> failureCallback;
+};
+
+BOOST_AUTO_TEST_SUITE(Readvertise)
+BOOST_FIXTURE_TEST_SUITE(TestNfdRibReadvertiseDestination, NfdRibReadvertiseDestinationFixture)
+
+class AdvertiseSuccessScenario
+{
+public:
+  ndn::nfd::ControlResponse
+  makeResponse(const ControlParameters& sentCp)
+  {
+    ControlParameters response;
+
+    response.setFaceId(1)
+      .setName(sentCp.getName())
+      .setOrigin(ndn::nfd::ROUTE_ORIGIN_CLIENT)
+      .setCost(0)
+      .setFlags(ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+
+    ndn::nfd::ControlResponse responsePayload;
+    responsePayload.setCode(200)
+      .setText("Successfully registered.")
+      .setBody(response.wireEncode());
+    return responsePayload;
+  }
+
+  void
+  checkCommandOutcome(NfdRibReadvertiseDestinationFixture* fixture)
+  {
+    BOOST_CHECK_EQUAL(fixture->nSuccessCallbacks, 1);
+    BOOST_CHECK_EQUAL(fixture->nFailureCallbacks, 0);
+  }
+};
+
+class AdvertiseFailureScenario
+{
+public:
+  ndn::nfd::ControlResponse
+  makeResponse(ControlParameters sentCp)
+  {
+    ndn::nfd::ControlResponse responsePayload(403, "Not Authenticated");
+    return responsePayload;
+  }
+
+  void
+  checkCommandOutcome(NfdRibReadvertiseDestinationFixture* fixture)
+  {
+    BOOST_CHECK_EQUAL(fixture->nFailureCallbacks, 1);
+    BOOST_CHECK_EQUAL(fixture->nSuccessCallbacks, 0);
+  }
+};
+
+using AdvertiseScenarios = boost::mpl::vector<AdvertiseSuccessScenario, AdvertiseFailureScenario>;
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(Advertise, Scenario, AdvertiseScenarios)
+{
+  Scenario scenario;
+  Name prefix("/ndn/memphis/test");
+  ReadvertisedRoute rr(prefix);
+  const Name RIB_REGISTER_COMMAND_PREFIX("/localhost/nlsr/rib/register");
+
+  dest.advertise(rr, successCallback, failureCallback);
+  advanceClocks(time::milliseconds(100));
+
+  // Retrieve the sent Interest to build the response
+  BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
+  const Interest& sentInterest = face.sentInterests[0];
+  BOOST_CHECK(RIB_REGISTER_COMMAND_PREFIX.isPrefixOf(sentInterest.getName()));
+
+  // Parse the sent command Interest to check correctness.
+  ControlParameters sentCp;
+  BOOST_CHECK_NO_THROW(sentCp.wireDecode(sentInterest.getName().get(RIB_REGISTER_COMMAND_PREFIX.size()).blockFromValue()));
+  BOOST_CHECK_EQUAL(sentCp.getOrigin(), ndn::nfd::ROUTE_ORIGIN_CLIENT);
+  BOOST_CHECK_EQUAL(sentCp.getName(), prefix);
+
+  ndn::nfd::ControlResponse responsePayload = scenario.makeResponse(sentCp);
+  auto responseData = makeData(sentInterest.getName());
+  responseData->setContent(responsePayload.wireEncode());
+  face.receive(*responseData);
+  this->advanceClocks(time::milliseconds(10));
+
+  scenario.checkCommandOutcome(this);
+}
+
+class WithdrawSuccessScenario
+{
+public:
+  ndn::nfd::ControlResponse
+  makeResponse(const ControlParameters& sentCp)
+  {
+    ControlParameters response;
+
+    response.setFaceId(1)
+      .setName(sentCp.getName())
+      .setOrigin(ndn::nfd::ROUTE_ORIGIN_CLIENT);
+
+    ndn::nfd::ControlResponse responsePayload;
+    responsePayload.setCode(200)
+      .setText("Successfully removed")
+      .setBody(response.wireEncode());
+
+    return responsePayload;
+  }
+
+  void
+  checkCommandOutcome(NfdRibReadvertiseDestinationFixture* fixture)
+  {
+    BOOST_CHECK_EQUAL(fixture->nSuccessCallbacks, 1);
+    BOOST_CHECK_EQUAL(fixture->nFailureCallbacks, 0);
+  }
+};
+
+class WithdrawFailureScenario
+{
+public:
+  ndn::nfd::ControlResponse
+  makeResponse(ControlParameters sentCp)
+  {
+    ndn::nfd::ControlResponse responsePayload(403, "Not authenticated");
+    return responsePayload;
+  }
+
+  void
+  checkCommandOutcome(NfdRibReadvertiseDestinationFixture* fixture)
+  {
+    BOOST_CHECK_EQUAL(fixture->nFailureCallbacks, 1);
+    BOOST_CHECK_EQUAL(fixture->nSuccessCallbacks, 0);
+  }
+};
+
+using WithdrawScenarios = boost::mpl::vector<WithdrawSuccessScenario, WithdrawFailureScenario>;
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(Withdraw, Scenario, WithdrawScenarios)
+{
+  Scenario scenario;
+  Name prefix("/ndn/memphis/test");
+  ReadvertisedRoute rr(prefix);
+  const Name RIB_UNREGISTER_COMMAND_PREFIX("/localhost/nlsr/rib/unregister");
+
+  dest.withdraw(rr, successCallback, failureCallback);
+  this->advanceClocks(time::milliseconds(10));
+
+  // Retrieve the sent Interest to build the response
+  BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
+  const Interest& sentInterest = face.sentInterests[0];
+  BOOST_CHECK(RIB_UNREGISTER_COMMAND_PREFIX.isPrefixOf(sentInterest.getName()));
+
+  ControlParameters sentCp;
+  BOOST_CHECK_NO_THROW(sentCp.wireDecode(sentInterest.getName().get(RIB_UNREGISTER_COMMAND_PREFIX.size()).blockFromValue()));
+  BOOST_CHECK_EQUAL(sentCp.getOrigin(), ndn::nfd::ROUTE_ORIGIN_CLIENT);
+  BOOST_CHECK_EQUAL(sentCp.getName(), prefix);
+
+  ndn::nfd::ControlResponse responsePayload = scenario.makeResponse(sentCp);
+  auto responseData = makeData(sentInterest.getName());
+  responseData->setContent(responsePayload.wireEncode());
+
+  face.receive(*responseData);
+  this->advanceClocks(time::milliseconds(1));
+
+  scenario.checkCommandOutcome(this);
+}
+
+BOOST_AUTO_TEST_CASE(DestinationAvailability)
+{
+  std::vector<bool> availabilityChangeHistory;
+  Name commandPrefix("/localhost/nlsr");
+  Route route;
+
+  dest.afterAvailabilityChange.connect(
+    std::bind(&std::vector<bool>::push_back, &availabilityChangeHistory, _1));
+  BOOST_CHECK_EQUAL(dest.isAvailable(), false);
+
+  rib.insert(commandPrefix, route);
+  this->advanceClocks(time::milliseconds(100));
+  BOOST_CHECK_EQUAL(dest.isAvailable(), true);
+  BOOST_REQUIRE_EQUAL(availabilityChangeHistory.size(), 1);
+  BOOST_CHECK_EQUAL(availabilityChangeHistory.back(), true);
+
+  rib.erase(commandPrefix, route);
+  this->advanceClocks(time::milliseconds(100));
+  BOOST_CHECK_EQUAL(dest.isAvailable(), false);
+  BOOST_REQUIRE_EQUAL(availabilityChangeHistory.size(), 2);
+  BOOST_CHECK_EQUAL(availabilityChangeHistory.back(), false);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // TestNfdRibReadvertiseDestination
+BOOST_AUTO_TEST_SUITE_END() // Readvertise
+
+} // namespace tests
+} // namespace rib
+} // namespace nfd
diff --git a/tests/daemon/rib/readvertise/readvertise.t.cpp b/tests/daemon/rib/readvertise/readvertise.t.cpp
new file mode 100644
index 0000000..1ff0f85
--- /dev/null
+++ b/tests/daemon/rib/readvertise/readvertise.t.cpp
@@ -0,0 +1,306 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2014-2018,  Regents of the University of California,
+ *                           Arizona Board of Regents,
+ *                           Colorado State University,
+ *                           University Pierre & Marie Curie, Sorbonne University,
+ *                           Washington University in St. Louis,
+ *                           Beijing Institute of Technology,
+ *                           The University of Memphis.
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "rib/readvertise/readvertise.hpp"
+
+#include "tests/identity-management-fixture.hpp"
+
+#include <ndn-cxx/util/dummy-client-face.hpp>
+#include <boost/range/adaptor/transformed.hpp>
+#include <boost/range/algorithm/copy.hpp>
+
+namespace nfd {
+namespace rib {
+namespace tests {
+
+using namespace nfd::tests;
+
+class DummyReadvertisePolicy : public ReadvertisePolicy
+{
+public:
+  optional<ReadvertiseAction>
+  handleNewRoute(const RibRouteRef& route) const override
+  {
+    return this->decision;
+  }
+
+  time::milliseconds
+  getRefreshInterval() const override
+  {
+    return time::seconds(60);
+  }
+
+public:
+  optional<ReadvertiseAction> decision;
+};
+
+class DummyReadvertiseDestination : public ReadvertiseDestination
+{
+public:
+  DummyReadvertiseDestination()
+  {
+    this->setAvailability(true);
+  }
+
+  void
+  advertise(const ReadvertisedRoute& rr,
+            std::function<void()> successCb,
+            std::function<void(const std::string&)> failureCb) override
+  {
+    advertiseHistory.push_back({time::steady_clock::now(), rr.prefix});
+    if (shouldSucceed) {
+      successCb();
+    }
+    else {
+      failureCb("FAKE-FAILURE");
+    }
+  }
+
+  void
+  withdraw(const ReadvertisedRoute& rr,
+           std::function<void()> successCb,
+           std::function<void(const std::string&)> failureCb) override
+  {
+    withdrawHistory.push_back({time::steady_clock::now(), rr.prefix});
+    if (shouldSucceed) {
+      successCb();
+    }
+    else {
+      failureCb("FAKE-FAILURE");
+    }
+  }
+
+  void
+  setAvailability(bool isAvailable)
+  {
+    this->ReadvertiseDestination::setAvailability(isAvailable);
+  }
+
+public:
+  struct HistoryEntry
+  {
+    time::steady_clock::TimePoint timestamp;
+    Name prefix;
+  };
+
+  bool shouldSucceed = true;
+  std::vector<HistoryEntry> advertiseHistory;
+  std::vector<HistoryEntry> withdrawHistory;
+};
+
+class ReadvertiseFixture : public IdentityManagementTimeFixture
+{
+public:
+  ReadvertiseFixture()
+    : m_face(g_io, m_keyChain, {false, false})
+    , m_scheduler(g_io)
+  {
+    auto policyUnique = make_unique<DummyReadvertisePolicy>();
+    policy = policyUnique.get();
+    auto destinationUnique = make_unique<DummyReadvertiseDestination>();
+    destination = destinationUnique.get();
+    readvertise = make_unique<Readvertise>(m_rib, m_scheduler,
+                                           std::move(policyUnique), std::move(destinationUnique));
+  }
+
+  void
+  insertRoute(const Name& prefix, uint64_t faceId, ndn::nfd::RouteOrigin origin)
+  {
+    Route route;
+    route.faceId = faceId;
+    route.origin = origin;
+    m_rib.insert(prefix, route);
+    this->advanceClocks(time::milliseconds(6));
+  }
+
+  void
+  eraseRoute(const Name& prefix, uint64_t faceId, ndn::nfd::RouteOrigin origin)
+  {
+    Route route;
+    route.faceId = faceId;
+    route.origin = origin;
+    m_rib.erase(prefix, route);
+    this->advanceClocks(time::milliseconds(6));
+  }
+
+  void
+  setDestinationAvailability(bool isAvailable)
+  {
+    destination->setAvailability(isAvailable);
+    this->advanceClocks(time::milliseconds(6));
+  }
+
+protected:
+  DummyReadvertisePolicy* policy;
+  DummyReadvertiseDestination* destination;
+  unique_ptr<Readvertise> readvertise;
+
+private:
+  ndn::util::DummyClientFace m_face;
+  ndn::util::Scheduler m_scheduler;
+  Rib m_rib;
+};
+
+BOOST_AUTO_TEST_SUITE(Readvertise)
+BOOST_FIXTURE_TEST_SUITE(TestReadvertise, ReadvertiseFixture)
+
+BOOST_AUTO_TEST_CASE(AddRemoveRoute)
+{
+  policy->decision = ReadvertiseAction{"/A", ndn::security::SigningInfo()};
+
+  // advertising /A
+  this->insertRoute("/A/1", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT);
+  BOOST_CHECK_EQUAL(destination->advertiseHistory.size(), 1);
+  BOOST_CHECK_EQUAL(destination->advertiseHistory.at(0).prefix, "/A");
+
+  // /A is already advertised
+  this->insertRoute("/A/2", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT);
+  BOOST_CHECK_EQUAL(destination->advertiseHistory.size(), 1);
+
+  // refresh every 60 seconds
+  destination->advertiseHistory.clear();
+  this->advanceClocks(time::seconds(61), 5);
+  BOOST_CHECK_EQUAL(destination->advertiseHistory.size(), 5);
+
+  // /A is still needed by /A/2 route
+  this->eraseRoute("/A/1", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT);
+  BOOST_CHECK_EQUAL(destination->withdrawHistory.size(), 0);
+
+  // withdrawing /A
+  this->eraseRoute("/A/2", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT);
+  BOOST_CHECK_EQUAL(destination->withdrawHistory.size(), 1);
+  BOOST_CHECK_EQUAL(destination->withdrawHistory.at(0).prefix, "/A");
+}
+
+BOOST_AUTO_TEST_CASE(NoAdvertise)
+{
+  policy->decision = nullopt;
+
+  this->insertRoute("/A/1", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT);
+  this->insertRoute("/A/2", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT);
+  this->eraseRoute("/A/1", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT);
+  this->eraseRoute("/A/2", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT);
+
+  BOOST_CHECK_EQUAL(destination->advertiseHistory.size(), 0);
+  BOOST_CHECK_EQUAL(destination->withdrawHistory.size(), 0);
+}
+
+BOOST_AUTO_TEST_CASE(DestinationAvailability)
+{
+  this->setDestinationAvailability(false);
+
+  policy->decision = ReadvertiseAction{"/A", ndn::security::SigningInfo()};
+  this->insertRoute("/A/1", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT);
+  policy->decision = ReadvertiseAction{"/B", ndn::security::SigningInfo()};
+  this->insertRoute("/B/1", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT);
+  BOOST_CHECK_EQUAL(destination->advertiseHistory.size(), 0);
+
+  this->setDestinationAvailability(true);
+  std::set<Name> advertisedPrefixes;
+  boost::copy(destination->advertiseHistory | boost::adaptors::transformed(
+                [] (const DummyReadvertiseDestination::HistoryEntry& he) { return he.prefix; }),
+              std::inserter(advertisedPrefixes, advertisedPrefixes.end()));
+  std::set<Name> expectedPrefixes{"/A", "/B"};
+  BOOST_CHECK_EQUAL_COLLECTIONS(advertisedPrefixes.begin(), advertisedPrefixes.end(),
+                                expectedPrefixes.begin(), expectedPrefixes.end());
+  destination->advertiseHistory.clear();
+
+  this->setDestinationAvailability(false);
+  this->eraseRoute("/B/1", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT);
+  BOOST_CHECK_EQUAL(destination->withdrawHistory.size(), 0);
+
+  this->setDestinationAvailability(true);
+  BOOST_CHECK_EQUAL(destination->withdrawHistory.size(), 0);
+  BOOST_CHECK_EQUAL(destination->advertiseHistory.size(), 1);
+  BOOST_CHECK_EQUAL(destination->advertiseHistory.at(0).prefix, "/A");
+}
+
+BOOST_AUTO_TEST_CASE(AdvertiseRetryInterval)
+{
+  destination->shouldSucceed = false;
+
+  policy->decision = ReadvertiseAction{"/A", ndn::security::SigningInfo()};
+  this->insertRoute("/A/1", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT);
+
+  this->advanceClocks(time::seconds(10), time::seconds(3600));
+  BOOST_REQUIRE_GT(destination->advertiseHistory.size(), 2);
+
+  // destination->advertise keeps failing, so interval should increase
+  using FloatInterval = time::duration<float, time::steady_clock::Duration::period>;
+  FloatInterval initialInterval = destination->advertiseHistory[1].timestamp -
+                                  destination->advertiseHistory[0].timestamp;
+  FloatInterval lastInterval = initialInterval;
+  for (size_t i = 2; i < destination->advertiseHistory.size(); ++i) {
+    FloatInterval interval = destination->advertiseHistory[i].timestamp -
+                             destination->advertiseHistory[i - 1].timestamp;
+    BOOST_CHECK_CLOSE(interval.count(), (lastInterval * 2.0).count(), 10.0);
+    lastInterval = interval;
+  }
+
+  destination->shouldSucceed = true;
+  this->advanceClocks(time::seconds(3600));
+  destination->advertiseHistory.clear();
+
+  // destination->advertise has succeeded, retry interval should reset to initial
+  destination->shouldSucceed = false;
+  this->advanceClocks(time::seconds(10), time::seconds(300));
+  BOOST_REQUIRE_GE(destination->advertiseHistory.size(), 2);
+  FloatInterval restartInterval = destination->advertiseHistory[1].timestamp -
+                                  destination->advertiseHistory[0].timestamp;
+  BOOST_CHECK_CLOSE(restartInterval.count(), initialInterval.count(), 10.0);
+}
+
+BOOST_AUTO_TEST_CASE(ChangeDuringRetry)
+{
+  destination->shouldSucceed = false;
+  policy->decision = ReadvertiseAction{"/A", ndn::security::SigningInfo()};
+  this->insertRoute("/A/1", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT);
+  this->advanceClocks(time::seconds(10), time::seconds(300));
+  BOOST_CHECK_GT(destination->advertiseHistory.size(), 0);
+  BOOST_CHECK_EQUAL(destination->withdrawHistory.size(), 0);
+
+  // destination->advertise has been failing, but we want to withdraw
+  destination->advertiseHistory.clear();
+  destination->withdrawHistory.clear();
+  this->eraseRoute("/A/1", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT);
+  this->advanceClocks(time::seconds(10), time::seconds(300));
+  BOOST_CHECK_EQUAL(destination->advertiseHistory.size(), 0); // don't try to advertise
+  BOOST_CHECK_GT(destination->withdrawHistory.size(), 0); // try to withdraw
+
+  // destination->withdraw has been failing, but we want to advertise
+  destination->advertiseHistory.clear();
+  destination->withdrawHistory.clear();
+  this->insertRoute("/A/1", 1, ndn::nfd::ROUTE_ORIGIN_CLIENT);
+  this->advanceClocks(time::seconds(10), time::seconds(300));
+  BOOST_CHECK_GT(destination->advertiseHistory.size(), 0); // try to advertise
+  BOOST_CHECK_EQUAL(destination->withdrawHistory.size(), 0); // don't try to withdraw
+}
+
+BOOST_AUTO_TEST_SUITE_END() // TestReadvertise
+BOOST_AUTO_TEST_SUITE_END() // Readvertise
+
+} // namespace tests
+} // namespace rib
+} // namespace nfd
diff --git a/tests/daemon/rib/rib-entry.t.cpp b/tests/daemon/rib/rib-entry.t.cpp
new file mode 100644
index 0000000..a5c9f3c
--- /dev/null
+++ b/tests/daemon/rib/rib-entry.t.cpp
@@ -0,0 +1,175 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2014-2018,  Regents of the University of California,
+ *                           Arizona Board of Regents,
+ *                           Colorado State University,
+ *                           University Pierre & Marie Curie, Sorbonne University,
+ *                           Washington University in St. Louis,
+ *                           Beijing Institute of Technology,
+ *                           The University of Memphis.
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "rib/rib-entry.hpp"
+#include "tests/test-common.hpp"
+
+namespace nfd {
+namespace rib {
+namespace tests {
+
+using namespace nfd::tests;
+
+BOOST_FIXTURE_TEST_SUITE(TestRibEntry, BaseFixture)
+
+BOOST_AUTO_TEST_CASE(Basic)
+{
+  rib::RibEntry entry;
+  rib::RibEntry::iterator entryIt;
+  bool didInsert = false;
+
+  rib::Route route1;
+  route1.faceId = 1;
+  route1.origin = ndn::nfd::ROUTE_ORIGIN_APP;
+
+  std::tie(entryIt, didInsert) = entry.insertRoute(route1);
+  BOOST_CHECK_EQUAL(entry.getRoutes().size(), 1);
+  BOOST_CHECK(entryIt == entry.findRoute(route1));
+  BOOST_CHECK(didInsert);
+
+  Route route2;
+  route2.faceId = 1;
+  route2.origin = ndn::nfd::ROUTE_ORIGIN_NLSR;
+
+  std::tie(entryIt, didInsert) = entry.insertRoute(route2);
+  BOOST_CHECK_EQUAL(entry.getRoutes().size(), 2);
+  BOOST_CHECK(entryIt == entry.findRoute(route2));
+  BOOST_CHECK(didInsert);
+
+  entry.eraseRoute(route1);
+  BOOST_CHECK_EQUAL(entry.getRoutes().size(), 1);
+  BOOST_CHECK(entry.findRoute(route1) == entry.end());
+
+  BOOST_CHECK(entry.findRoute(route1) == entry.getRoutes().end());
+  BOOST_CHECK(entry.findRoute(route2) != entry.getRoutes().end());
+
+  std::tie(entryIt, didInsert) = entry.insertRoute(route2);
+  BOOST_CHECK_EQUAL(entry.getRoutes().size(), 1);
+  BOOST_CHECK(!didInsert);
+
+  entry.eraseRoute(route1);
+  BOOST_CHECK_EQUAL(entry.getRoutes().size(), 1);
+  BOOST_CHECK(entry.findRoute(route2) != entry.getRoutes().end());
+}
+
+BOOST_FIXTURE_TEST_SUITE(GetAnnouncement, UnitTestTimeFixture)
+
+static Route
+makeSimpleRoute(uint64_t faceId)
+{
+  Route route;
+  route.faceId = faceId;
+  return route;
+}
+
+static Route
+makeSimpleRoute(uint64_t faceId, time::steady_clock::Duration expiration)
+{
+  Route route = makeSimpleRoute(faceId);
+  route.expires = time::steady_clock::now() + expiration;
+  return route;
+}
+
+BOOST_AUTO_TEST_CASE(Empty)
+{
+  RibEntry entry;
+  // entry has no Route
+
+  advanceClocks(1_s);
+  auto pa = entry.getPrefixAnnouncement(15_s, 30_s);
+  BOOST_CHECK_GE(pa.getExpiration(), 15_s);
+  BOOST_CHECK_LE(pa.getExpiration(), 30_s);
+  // A RibEntry without Route does not have a defined expiration time,
+  // so this test only checks that there's no exception and the expiration period is clamped.
+}
+
+BOOST_AUTO_TEST_CASE(ReuseAnnouncement1)
+{
+  RibEntry entry;
+  entry.insertRoute(Route(makePrefixAnn("/A", 212_s), 5858));
+  entry.insertRoute(Route(makePrefixAnn("/A", 555_s), 2454));
+  entry.insertRoute(makeSimpleRoute(8282, 799_s));
+  entry.insertRoute(makeSimpleRoute(1141));
+
+  advanceClocks(1_s);
+  auto pa = entry.getPrefixAnnouncement(15_s, 30_s);
+  BOOST_CHECK_EQUAL(pa.getExpiration(), 555_s); // not modified and not clamped
+}
+
+BOOST_AUTO_TEST_CASE(ReuseAnnouncement2)
+{
+  RibEntry entry;
+  entry.insertRoute(Route(makePrefixAnn("/A", 212_s), 7557)); // expires at +212s
+
+  advanceClocks(100_s);
+  entry.insertRoute(Route(makePrefixAnn("/A", 136_s), 1010)); // expires at +236s
+
+  advanceClocks(1_s);
+  auto pa = entry.getPrefixAnnouncement(15_s, 30_s);
+  BOOST_CHECK_EQUAL(pa.getExpiration(), 136_s);
+  // Although face 7557's announcement has a longer expiration period,
+  // the route for face 1010 expires last and thus its announcement is chosen.
+}
+
+BOOST_AUTO_TEST_CASE(MakeAnnouncement)
+{
+  RibEntry entry;
+  entry.insertRoute(makeSimpleRoute(6398, 765_s));
+  entry.insertRoute(makeSimpleRoute(2954, 411_s));
+
+  advanceClocks(1_s);
+  auto pa = entry.getPrefixAnnouncement(15_s, 999_s);
+  BOOST_CHECK_EQUAL(pa.getExpiration(), 764_s);
+}
+
+BOOST_AUTO_TEST_CASE(MakeAnnouncementInfinite)
+{
+  RibEntry entry;
+  entry.insertRoute(makeSimpleRoute(4877, 240_s));
+  entry.insertRoute(makeSimpleRoute(5053));
+
+  advanceClocks(1_s);
+  auto pa = entry.getPrefixAnnouncement(15_s, 877_s);
+  BOOST_CHECK_EQUAL(pa.getExpiration(), 877_s); // clamped at maxExpiration
+}
+
+BOOST_AUTO_TEST_CASE(MakeAnnouncementShortExpiration)
+{
+  RibEntry entry;
+  entry.insertRoute(makeSimpleRoute(4877, 8_s));
+  entry.insertRoute(makeSimpleRoute(5053, 9_s));
+
+  advanceClocks(1_s);
+  auto pa = entry.getPrefixAnnouncement(15_s, 666_s);
+  BOOST_CHECK_EQUAL(pa.getExpiration(), 15_s); // clamped at minExpiration
+}
+
+BOOST_AUTO_TEST_SUITE_END() // GetAnnouncement
+
+BOOST_AUTO_TEST_SUITE_END() // TestRibEntry
+
+} // namespace tests
+} // namespace rib
+} // namespace nfd
diff --git a/tests/daemon/rib/rib-manager.t.cpp b/tests/daemon/rib/rib-manager.t.cpp
new file mode 100644
index 0000000..be59ca5
--- /dev/null
+++ b/tests/daemon/rib/rib-manager.t.cpp
@@ -0,0 +1,554 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2014-2018,  Regents of the University of California,
+ *                           Arizona Board of Regents,
+ *                           Colorado State University,
+ *                           University Pierre & Marie Curie, Sorbonne University,
+ *                           Washington University in St. Louis,
+ *                           Beijing Institute of Technology,
+ *                           The University of Memphis.
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "rib/rib-manager.hpp"
+#include "core/fib-max-depth.hpp"
+
+#include "tests/manager-common-fixture.hpp"
+
+#include <ndn-cxx/lp/tags.hpp>
+#include <ndn-cxx/mgmt/nfd/face-event-notification.hpp>
+#include <ndn-cxx/mgmt/nfd/face-status.hpp>
+#include <ndn-cxx/mgmt/nfd/rib-entry.hpp>
+
+namespace nfd {
+namespace rib {
+namespace tests {
+
+using namespace nfd::tests;
+
+struct ConfigurationStatus
+{
+  bool isLocalhostConfigured;
+  bool isLocalhopConfigured;
+};
+
+static ConfigSection
+getValidatorConfigSection()
+{
+  ConfigSection section;
+  section.put("trust-anchor.type", "any");
+  return section;
+}
+
+class RibManagerFixture : public ManagerCommonFixture
+{
+public:
+  explicit
+  RibManagerFixture(const ConfigurationStatus& status, bool shouldClearRib)
+    : m_commands(m_face.sentInterests)
+    , m_status(status)
+    , m_scheduler(g_io)
+    , m_nfdController(m_face, m_keyChain)
+    , m_fibUpdater(m_rib, m_nfdController)
+    , m_manager(m_rib, m_face, m_keyChain, m_nfdController, m_dispatcher, m_scheduler)
+  {
+    m_rib.mockFibResponse = [] (const RibUpdateBatch& batch) {
+      BOOST_CHECK(batch.begin() != batch.end());
+      return true;
+    };
+    m_rib.wantMockFibResponseOnce = false;
+
+    if (m_status.isLocalhostConfigured) {
+      m_manager.applyLocalhostConfig(getValidatorConfigSection(), "test");
+    }
+    if (m_status.isLocalhopConfigured) {
+      m_manager.enableLocalhop(getValidatorConfigSection(), "test");
+    }
+    else {
+      m_manager.disableLocalhop();
+    }
+
+    registerWithNfd();
+
+    if (shouldClearRib) {
+      clearRib();
+    }
+  }
+
+private:
+  void
+  registerWithNfd()
+  {
+    m_manager.registerWithNfd();
+    advanceClocks(time::milliseconds(1));
+
+    auto replyFibAddCommand = [this] (const Interest& interest) {
+      nfd::ControlParameters params(interest.getName().get(-5).blockFromValue());
+      BOOST_CHECK(params.getName() == "/localhost/nfd/rib" || params.getName() == "/localhop/nfd/rib");
+      params.setFaceId(1).setCost(0);
+      nfd::ControlResponse resp;
+
+      resp.setCode(200).setBody(params.wireEncode());
+      shared_ptr<Data> data = make_shared<Data>(interest.getName());
+      data->setContent(resp.wireEncode());
+
+      m_keyChain.sign(*data, ndn::security::SigningInfo(ndn::security::SigningInfo::SIGNER_TYPE_SHA256));
+
+      m_face.getIoService().post([this, data] { m_face.receive(*data); });
+    };
+
+    Name commandPrefix("/localhost/nfd/fib/add-nexthop");
+    for (const auto& command : m_commands) {
+      if (commandPrefix.isPrefixOf(command.getName())) {
+        replyFibAddCommand(command);
+        advanceClocks(time::milliseconds(1));
+      }
+    }
+
+    // clear commands and responses
+    m_responses.clear();
+    m_commands.clear();
+  }
+
+  void
+  clearRib()
+  {
+    while (!m_rib.empty()) {
+      m_rib.erase(m_rib.begin()->first, *m_rib.begin()->second->begin());
+    }
+  }
+
+public:
+  static ControlParameters
+  makeRegisterParameters(const Name& name, uint64_t faceId = 0,
+                         time::milliseconds expiry = time::milliseconds::max())
+  {
+    return ControlParameters()
+      .setName(name)
+      .setFaceId(faceId)
+      .setOrigin(ndn::nfd::ROUTE_ORIGIN_NLSR)
+      .setCost(10)
+      .setFlags(0)
+      .setExpirationPeriod(expiry);
+  }
+
+  static ControlParameters
+  makeUnregisterParameters(const Name& name, uint64_t faceId = 0)
+  {
+    return ControlParameters()
+      .setName(name)
+      .setFaceId(faceId)
+      .setOrigin(ndn::nfd::ROUTE_ORIGIN_NLSR);
+  }
+
+public:
+  enum class CheckCommandResult {
+    OK,
+    OUT_OF_BOUNDARY,
+    WRONG_FORMAT,
+    WRONG_VERB,
+    WRONG_PARAMS_FORMAT,
+    WRONG_PARAMS_NAME,
+    WRONG_PARAMS_FACE
+  };
+
+  CheckCommandResult
+  checkCommand(size_t idx, const char* verbStr, const ControlParameters& expectedParams) const
+  {
+    if (idx > m_commands.size()) {
+      return CheckCommandResult::OUT_OF_BOUNDARY;
+    }
+    const auto& name = m_commands[idx].getName();
+
+    if (!FIB_COMMAND_PREFIX.isPrefixOf(name) || FIB_COMMAND_PREFIX.size() >= name.size()) {
+      return CheckCommandResult::WRONG_FORMAT;
+    }
+    const auto& verb = name[FIB_COMMAND_PREFIX.size()];
+
+    Name::Component expectedVerb(verbStr);
+    if (verb != expectedVerb) {
+      return CheckCommandResult::WRONG_VERB;
+    }
+
+    ControlParameters parameters;
+    try {
+      Block rawParameters = name[FIB_COMMAND_PREFIX.size() + 1].blockFromValue();
+      parameters.wireDecode(rawParameters);
+    }
+    catch (...) {
+      return CheckCommandResult::WRONG_PARAMS_FORMAT;
+    }
+
+    if (parameters.getName() != expectedParams.getName()) {
+      return CheckCommandResult::WRONG_PARAMS_NAME;
+    }
+
+    if (parameters.getFaceId() != expectedParams.getFaceId()) {
+      return CheckCommandResult::WRONG_PARAMS_FACE;
+    }
+
+    return CheckCommandResult::OK;
+  }
+
+protected:
+  static const Name FIB_COMMAND_PREFIX;
+  std::vector<Interest>& m_commands;
+  ConfigurationStatus m_status;
+
+  ndn::util::Scheduler m_scheduler;
+  ndn::nfd::Controller m_nfdController;
+  Rib m_rib;
+  FibUpdater m_fibUpdater;
+  RibManager m_manager;
+};
+
+const Name RibManagerFixture::FIB_COMMAND_PREFIX("/localhost/nfd/fib");
+
+std::ostream&
+operator<<(std::ostream& os, RibManagerFixture::CheckCommandResult result)
+{
+  switch (result) {
+  case RibManagerFixture::CheckCommandResult::OK:
+    return os << "OK";
+  case RibManagerFixture::CheckCommandResult::OUT_OF_BOUNDARY:
+    return os << "OUT_OF_BOUNDARY";
+  case RibManagerFixture::CheckCommandResult::WRONG_FORMAT:
+    return os << "WRONG_FORMAT";
+  case RibManagerFixture::CheckCommandResult::WRONG_VERB:
+    return os << "WRONG_VERB";
+  case RibManagerFixture::CheckCommandResult::WRONG_PARAMS_FORMAT:
+    return os << "WRONG_PARAMS_FORMAT";
+  case RibManagerFixture::CheckCommandResult::WRONG_PARAMS_NAME:
+    return os << "WRONG_PARAMS_NAME";
+  case RibManagerFixture::CheckCommandResult::WRONG_PARAMS_FACE:
+    return os << "WRONG_PARAMS_FACE";
+  };
+
+  return os << static_cast<int>(result);
+}
+
+BOOST_AUTO_TEST_SUITE(TestRibManager)
+
+class AddTopPrefixFixture : public RibManagerFixture
+{
+public:
+  AddTopPrefixFixture()
+    : RibManagerFixture({true, true}, false)
+  {
+  }
+};
+
+BOOST_FIXTURE_TEST_CASE(AddTopPrefix, AddTopPrefixFixture)
+{
+  BOOST_CHECK_EQUAL(m_rib.size(), 2);
+
+  std::vector<Name> ribEntryNames;
+  for (auto&& entry : m_rib) {
+    ribEntryNames.push_back(entry.first);
+  }
+  BOOST_CHECK_EQUAL(ribEntryNames[0], "/localhop/nfd");
+  BOOST_CHECK_EQUAL(ribEntryNames[1], "/localhost/nfd");
+}
+
+class UnauthorizedRibManagerFixture : public RibManagerFixture
+{
+public:
+  UnauthorizedRibManagerFixture()
+    : RibManagerFixture({false, false}, true)
+  {
+  }
+};
+
+class LocalhostAuthorizedRibManagerFixture : public RibManagerFixture
+{
+public:
+  LocalhostAuthorizedRibManagerFixture()
+    : RibManagerFixture({true, false}, true)
+  {
+  }
+};
+
+class LocalhopAuthorizedRibManagerFixture : public RibManagerFixture
+{
+public:
+  LocalhopAuthorizedRibManagerFixture()
+    : RibManagerFixture({false, true}, true)
+  {
+  }
+};
+
+class AuthorizedRibManagerFixture : public RibManagerFixture
+{
+public:
+  AuthorizedRibManagerFixture()
+    : RibManagerFixture({true, true}, true)
+  {
+  }
+};
+
+using AllFixtures = boost::mpl::vector<
+  UnauthorizedRibManagerFixture,
+  LocalhostAuthorizedRibManagerFixture,
+  LocalhopAuthorizedRibManagerFixture,
+  AuthorizedRibManagerFixture
+>;
+
+BOOST_FIXTURE_TEST_CASE_TEMPLATE(CommandAuthorization, T, AllFixtures, T)
+{
+  auto parameters  = this->makeRegisterParameters("/test-authorization", 9527);
+  auto commandHost = this->makeControlCommandRequest("/localhost/nfd/rib/register", parameters);
+  auto commandHop  = this->makeControlCommandRequest("/localhop/nfd/rib/register", parameters);
+  auto successResp = this->makeResponse(200, "Success", parameters);
+  auto failureResp = ControlResponse(403, "authorization rejected");
+
+  BOOST_CHECK_EQUAL(this->m_responses.size(), 0);
+  this->receiveInterest(commandHost);
+  this->receiveInterest(commandHop);
+
+  auto nExpectedResponses = this->m_status.isLocalhopConfigured ? 2 : 1;
+  auto expectedLocalhostResponse = this->m_status.isLocalhostConfigured ? successResp : failureResp;
+  auto expectedLocalhopResponse = this->m_status.isLocalhopConfigured ? successResp : failureResp;
+
+  BOOST_REQUIRE_EQUAL(this->m_responses.size(), nExpectedResponses);
+  BOOST_CHECK_EQUAL(this->checkResponse(0, commandHost.getName(), expectedLocalhostResponse),
+                    ManagerCommonFixture::CheckResponseResult::OK);
+  if (nExpectedResponses == 2) {
+    BOOST_CHECK_EQUAL(this->checkResponse(1, commandHop.getName(), expectedLocalhopResponse),
+                      ManagerCommonFixture::CheckResponseResult::OK);
+  }
+}
+
+BOOST_FIXTURE_TEST_SUITE(RegisterUnregister, LocalhostAuthorizedRibManagerFixture)
+
+BOOST_AUTO_TEST_CASE(Basic)
+{
+  auto paramsRegister    = makeRegisterParameters("/test-register-unregister", 9527);
+  auto paramsUnregister  = makeUnregisterParameters("/test-register-unregister", 9527);
+
+  auto commandRegister = makeControlCommandRequest("/localhost/nfd/rib/register", paramsRegister);
+  commandRegister.setTag(make_shared<lp::IncomingFaceIdTag>(1234));
+  auto commandUnregister = makeControlCommandRequest("/localhost/nfd/rib/unregister", paramsUnregister);
+  commandUnregister.setTag(make_shared<lp::IncomingFaceIdTag>(1234));
+
+  receiveInterest(commandRegister);
+  receiveInterest(commandUnregister);
+
+  BOOST_REQUIRE_EQUAL(m_responses.size(), 2);
+  BOOST_CHECK_EQUAL(checkResponse(0, commandRegister.getName(), makeResponse(200, "Success", paramsRegister)),
+                    CheckResponseResult::OK);
+  BOOST_CHECK_EQUAL(checkResponse(1, commandUnregister.getName(), makeResponse(200, "Success", paramsUnregister)),
+                    CheckResponseResult::OK);
+
+  BOOST_REQUIRE_EQUAL(m_commands.size(), 2);
+  BOOST_CHECK_EQUAL(checkCommand(0, "add-nexthop", paramsRegister), CheckCommandResult::OK);
+  BOOST_CHECK_EQUAL(checkCommand(1, "remove-nexthop", paramsUnregister), CheckCommandResult::OK);
+}
+
+BOOST_AUTO_TEST_CASE(SelfOperation)
+{
+  auto paramsRegister = makeRegisterParameters("/test-self-register-unregister");
+  auto paramsUnregister = makeUnregisterParameters("/test-self-register-unregister");
+  BOOST_CHECK_EQUAL(paramsRegister.getFaceId(), 0);
+  BOOST_CHECK_EQUAL(paramsUnregister.getFaceId(), 0);
+
+  const uint64_t inFaceId = 9527;
+  auto commandRegister = makeControlCommandRequest("/localhost/nfd/rib/register", paramsRegister);
+  commandRegister.setTag(make_shared<lp::IncomingFaceIdTag>(inFaceId));
+  auto commandUnregister = makeControlCommandRequest("/localhost/nfd/rib/unregister", paramsUnregister);
+  commandUnregister.setTag(make_shared<lp::IncomingFaceIdTag>(inFaceId));
+
+  receiveInterest(commandRegister);
+  receiveInterest(commandUnregister);
+
+  paramsRegister.setFaceId(inFaceId);
+  paramsUnregister.setFaceId(inFaceId);
+
+  BOOST_REQUIRE_EQUAL(m_responses.size(), 2);
+  BOOST_CHECK_EQUAL(checkResponse(0, commandRegister.getName(), makeResponse(200, "Success", paramsRegister)),
+                    CheckResponseResult::OK);
+  BOOST_CHECK_EQUAL(checkResponse(1, commandUnregister.getName(), makeResponse(200, "Success", paramsUnregister)),
+                    CheckResponseResult::OK);
+
+  BOOST_REQUIRE_EQUAL(m_commands.size(), 2);
+  BOOST_CHECK_EQUAL(checkCommand(0, "add-nexthop", paramsRegister), CheckCommandResult::OK);
+  BOOST_CHECK_EQUAL(checkCommand(1, "remove-nexthop", paramsUnregister), CheckCommandResult::OK);
+}
+
+BOOST_AUTO_TEST_CASE(Expiration)
+{
+  auto paramsRegister = makeRegisterParameters("/test-expiry", 9527, time::milliseconds(50));
+  auto paramsUnregister = makeRegisterParameters("/test-expiry", 9527);
+  receiveInterest(makeControlCommandRequest("/localhost/nfd/rib/register", paramsRegister));
+
+  advanceClocks(time::milliseconds(55));
+  BOOST_REQUIRE_EQUAL(m_commands.size(), 2); // the registered route has expired
+  BOOST_CHECK_EQUAL(checkCommand(0, "add-nexthop", paramsRegister), CheckCommandResult::OK);
+  BOOST_CHECK_EQUAL(checkCommand(1, "remove-nexthop", paramsUnregister), CheckCommandResult::OK);
+
+  m_commands.clear();
+  paramsRegister.setExpirationPeriod(time::milliseconds(100));
+  receiveInterest(makeControlCommandRequest("/localhost/nfd/rib/register", paramsRegister));
+
+  advanceClocks(time::milliseconds(55));
+  BOOST_REQUIRE_EQUAL(m_commands.size(), 1); // the registered route is still active
+  BOOST_CHECK_EQUAL(checkCommand(0, "add-nexthop", paramsRegister), CheckCommandResult::OK);
+}
+
+BOOST_AUTO_TEST_CASE(NameTooLong)
+{
+  Name prefix;
+  while (prefix.size() <= FIB_MAX_DEPTH) {
+    prefix.append("A");
+  }
+  auto params = makeRegisterParameters(prefix, 2899);
+  auto command = makeControlCommandRequest("/localhost/nfd/rib/register", params);
+  receiveInterest(command);
+
+  BOOST_REQUIRE_EQUAL(m_responses.size(), 1);
+  BOOST_CHECK_EQUAL(checkResponse(0, command.getName(), ControlResponse(414,
+                      "Route prefix cannot exceed " + ndn::to_string(FIB_MAX_DEPTH) +
+                      " components")),
+                    CheckResponseResult::OK);
+
+  BOOST_CHECK_EQUAL(m_commands.size(), 0);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // RegisterUnregister
+
+BOOST_FIXTURE_TEST_CASE(RibDataset, UnauthorizedRibManagerFixture)
+{
+  uint64_t faceId = 0;
+  auto generateRoute = [&faceId] () -> Route {
+    Route route;
+    route.faceId = ++faceId;
+    route.cost = route.faceId * 10;
+    route.expires = nullopt;
+    return route;
+  };
+
+  const size_t nEntries = 108;
+  std::set<Name> actualPrefixes;
+  for (size_t i = 0; i < nEntries; ++i) {
+    Name prefix = Name("/test-dataset").appendNumber(i);
+    actualPrefixes.insert(prefix);
+    m_rib.insert(prefix, generateRoute());
+    if (i & 0x1) {
+      m_rib.insert(prefix, generateRoute());
+      m_rib.insert(prefix, generateRoute());
+    }
+  }
+
+  receiveInterest(Interest("/localhost/nfd/rib/list"));
+
+  Block content = concatenateResponses();
+  content.parse();
+  BOOST_REQUIRE_EQUAL(content.elements().size(), nEntries);
+
+  std::vector<ndn::nfd::RibEntry> receivedRecords, expectedRecords;
+  for (size_t idx = 0; idx < nEntries; ++idx) {
+    ndn::nfd::RibEntry decodedEntry(content.elements()[idx]);
+    receivedRecords.push_back(decodedEntry);
+    actualPrefixes.erase(decodedEntry.getName());
+
+    auto matchedEntryIt = m_rib.find(decodedEntry.getName());
+    BOOST_REQUIRE(matchedEntryIt != m_rib.end());
+
+    auto matchedEntry = matchedEntryIt->second;
+    BOOST_REQUIRE(matchedEntry != nullptr);
+
+    expectedRecords.emplace_back();
+    expectedRecords.back().setName(matchedEntry->getName());
+    for (const auto& route : matchedEntry->getRoutes()) {
+      expectedRecords.back().addRoute(ndn::nfd::Route()
+                                      .setFaceId(route.faceId)
+                                      .setOrigin(route.origin)
+                                      .setCost(route.cost)
+                                      .setFlags(route.flags));
+    }
+  }
+
+  BOOST_CHECK_EQUAL(actualPrefixes.size(), 0);
+  BOOST_CHECK_EQUAL_COLLECTIONS(receivedRecords.begin(), receivedRecords.end(),
+                                expectedRecords.begin(), expectedRecords.end());
+}
+
+BOOST_FIXTURE_TEST_SUITE(FaceMonitor, LocalhostAuthorizedRibManagerFixture)
+
+BOOST_AUTO_TEST_CASE(FetchActiveFacesEvent)
+{
+  BOOST_CHECK_EQUAL(m_commands.size(), 0);
+
+  advanceClocks(time::seconds(301)); // RibManager::ACTIVE_FACE_FETCH_INTERVAL = 300s
+  BOOST_REQUIRE_EQUAL(m_commands.size(), 2);
+  BOOST_CHECK_EQUAL(m_commands[0].getName(), "/localhost/nfd/faces/events");
+  BOOST_CHECK_EQUAL(m_commands[1].getName(), "/localhost/nfd/faces/list");
+}
+
+BOOST_AUTO_TEST_CASE(RemoveInvalidFaces)
+{
+  auto parameters1 = makeRegisterParameters("/test-remove-invalid-faces-1");
+  auto parameters2 = makeRegisterParameters("/test-remove-invalid-faces-2");
+  receiveInterest(makeControlCommandRequest("/localhost/nfd/rib/register", parameters1.setFaceId(1)));
+  receiveInterest(makeControlCommandRequest("/localhost/nfd/rib/register", parameters1.setFaceId(2)));
+  receiveInterest(makeControlCommandRequest("/localhost/nfd/rib/register", parameters2.setFaceId(2)));
+  BOOST_REQUIRE_EQUAL(m_rib.size(), 3);
+
+  ndn::nfd::FaceStatus status;
+  status.setFaceId(1);
+  std::vector<ndn::nfd::FaceStatus> activeFaces;
+  activeFaces.push_back(status);
+
+  m_manager.removeInvalidFaces(activeFaces);
+  advanceClocks(time::milliseconds(100));
+  BOOST_REQUIRE_EQUAL(m_rib.size(), 1);
+
+  auto it1 = m_rib.find("/test-remove-invalid-faces-1");
+  auto it2 = m_rib.find("/test-remove-invalid-faces-2");
+  BOOST_CHECK(it2 == m_rib.end());
+  BOOST_REQUIRE(it1 != m_rib.end());
+  BOOST_CHECK(it1->second->hasFaceId(1));
+  BOOST_CHECK(!it1->second->hasFaceId(2));
+}
+
+BOOST_AUTO_TEST_CASE(OnNotification)
+{
+  auto parameters1 = makeRegisterParameters("/test-face-event-notification-1", 1);
+  auto parameters2 = makeRegisterParameters("/test-face-event-notification-2", 1);
+  receiveInterest(makeControlCommandRequest("/localhost/nfd/rib/register", parameters1));
+  receiveInterest(makeControlCommandRequest("/localhost/nfd/rib/register", parameters2));
+  BOOST_REQUIRE_EQUAL(m_rib.size(), 2);
+
+  auto makeNotification = [] (ndn::nfd::FaceEventKind eventKind, uint64_t faceId) -> ndn::nfd::FaceEventNotification {
+    ndn::nfd::FaceEventNotification notification;
+    notification.setKind(eventKind).setFaceId(faceId);
+    return notification;
+  };
+
+  m_manager.onNotification(makeNotification(ndn::nfd::FaceEventKind::FACE_EVENT_DESTROYED, 1));
+  advanceClocks(time::milliseconds(100));
+  BOOST_CHECK_EQUAL(m_rib.size(), 0);
+
+  m_manager.onNotification(makeNotification(ndn::nfd::FaceEventKind::FACE_EVENT_CREATED, 2));
+  advanceClocks(time::milliseconds(100));
+  BOOST_CHECK_EQUAL(m_rib.size(), 0);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // FaceMonitor
+BOOST_AUTO_TEST_SUITE_END() // TestRibManager
+
+} // namespace tests
+} // namespace rib
+} // namespace nfd
diff --git a/tests/daemon/rib/rib-update.t.cpp b/tests/daemon/rib/rib-update.t.cpp
new file mode 100644
index 0000000..22577f0
--- /dev/null
+++ b/tests/daemon/rib/rib-update.t.cpp
@@ -0,0 +1,84 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2014-2019,  Regents of the University of California,
+ *                           Arizona Board of Regents,
+ *                           Colorado State University,
+ *                           University Pierre & Marie Curie, Sorbonne University,
+ *                           Washington University in St. Louis,
+ *                           Beijing Institute of Technology,
+ *                           The University of Memphis.
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "rib/rib-update.hpp"
+#include "rib/rib-update-batch.hpp"
+
+#include "tests/test-common.hpp"
+#include "tests/daemon/rib/create-route.hpp"
+
+namespace nfd {
+namespace rib {
+namespace tests {
+
+BOOST_FIXTURE_TEST_SUITE(TestRibUpdate, nfd::tests::BaseFixture)
+
+BOOST_AUTO_TEST_CASE(BatchBasic)
+{
+  const uint64_t faceId = 1;
+
+  RibUpdateBatch batch(faceId);
+
+  Route routeRegister = createRoute(faceId, 128, 10, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+
+  RibUpdate registerUpdate;
+  registerUpdate.setAction(RibUpdate::REGISTER)
+                .setName("/a")
+                .setRoute(routeRegister);
+
+  batch.add(registerUpdate);
+
+  BOOST_CHECK_EQUAL(batch.getFaceId(), faceId);
+
+  Route routeUnregister = createRoute(faceId, 0, 0, ndn::nfd::ROUTE_FLAG_CAPTURE);
+
+  RibUpdate unregisterUpdate;
+  unregisterUpdate.setAction(RibUpdate::UNREGISTER)
+                  .setName("/a/b")
+                  .setRoute(routeUnregister);
+
+  batch.add(unregisterUpdate);
+
+  BOOST_REQUIRE_EQUAL(batch.size(), 2);
+  RibUpdateBatch::const_iterator it = batch.begin();
+
+  BOOST_CHECK_EQUAL(it->getAction(), RibUpdate::REGISTER);
+  BOOST_CHECK_EQUAL(it->getName(), "/a");
+  BOOST_CHECK_EQUAL(it->getRoute(), routeRegister);
+
+  ++it;
+  BOOST_CHECK_EQUAL(it->getAction(), RibUpdate::UNREGISTER);
+  BOOST_CHECK_EQUAL(it->getName(), "/a/b");
+  BOOST_CHECK_EQUAL(it->getRoute(), routeUnregister);
+
+  ++it;
+  BOOST_CHECK(it == batch.end());
+}
+
+BOOST_AUTO_TEST_SUITE_END() // TestRibUpdate
+
+} // namespace tests
+} // namespace rib
+} // namespace nfd
diff --git a/tests/daemon/rib/rib.t.cpp b/tests/daemon/rib/rib.t.cpp
new file mode 100644
index 0000000..26a47b3
--- /dev/null
+++ b/tests/daemon/rib/rib.t.cpp
@@ -0,0 +1,335 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2014-2019,  Regents of the University of California,
+ *                           Arizona Board of Regents,
+ *                           Colorado State University,
+ *                           University Pierre & Marie Curie, Sorbonne University,
+ *                           Washington University in St. Louis,
+ *                           Beijing Institute of Technology,
+ *                           The University of Memphis.
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "rib/rib.hpp"
+
+#include "tests/test-common.hpp"
+#include "tests/daemon/rib/create-route.hpp"
+
+namespace nfd {
+namespace rib {
+namespace tests {
+
+BOOST_FIXTURE_TEST_SUITE(TestRib, nfd::tests::BaseFixture)
+
+BOOST_AUTO_TEST_CASE(Parent)
+{
+  rib::Rib rib;
+
+  Name name1("/");
+  rib.insert(name1, createRoute(1, 20));
+
+  Name name2("/hello");
+  rib.insert(name2, createRoute(2, 20));
+
+  Name name3("/hello/world");
+  rib.insert(name3, createRoute(3, 20));
+
+  shared_ptr<rib::RibEntry> ribEntry = rib.findParent(name3);
+  BOOST_REQUIRE(ribEntry != nullptr);
+  BOOST_CHECK_EQUAL(ribEntry->getRoutes().front().faceId, 2);
+
+  ribEntry = rib.findParent(name2);
+  BOOST_REQUIRE(ribEntry != nullptr);
+  BOOST_CHECK_EQUAL(ribEntry->getRoutes().front().faceId, 1);
+
+  Name name4("/hello/test/foo/bar");
+  rib.insert(name4, createRoute(3, 20));
+
+  ribEntry = rib.findParent(name4);
+  BOOST_REQUIRE(ribEntry != nullptr);
+  BOOST_CHECK(ribEntry->getRoutes().front().faceId == 2);
+}
+
+BOOST_AUTO_TEST_CASE(Children)
+{
+  rib::Rib rib;
+
+  Name name1("/");
+  rib.insert(name1, createRoute(1, 20));
+
+  Name name2("/hello/world");
+  rib.insert(name2, createRoute(2, 20));
+
+  Name name3("/hello/test/foo/bar");
+  rib.insert(name3, createRoute(3, 20));
+
+  BOOST_CHECK_EQUAL((rib.find(name1)->second)->getChildren().size(), 2);
+  BOOST_CHECK_EQUAL((rib.find(name2)->second)->getChildren().size(), 0);
+  BOOST_CHECK_EQUAL((rib.find(name3)->second)->getChildren().size(), 0);
+
+  Name name4("/hello");
+  rib.insert(name4, createRoute(4, 20));
+
+  BOOST_CHECK_EQUAL((rib.find(name1)->second)->getChildren().size(), 1);
+  BOOST_CHECK_EQUAL((rib.find(name2)->second)->getChildren().size(), 0);
+  BOOST_CHECK_EQUAL((rib.find(name3)->second)->getChildren().size(), 0);
+  BOOST_CHECK_EQUAL((rib.find(name4)->second)->getChildren().size(), 2);
+
+  BOOST_CHECK_EQUAL((rib.find(name1)->second)->getChildren().front()->getName(), "/hello");
+  BOOST_CHECK_EQUAL((rib.find(name4)->second)->getParent()->getName(), "/");
+
+  BOOST_REQUIRE(static_cast<bool>((rib.find(name2)->second)->getParent()));
+  BOOST_CHECK_EQUAL((rib.find(name2)->second)->getParent()->getName(), name4);
+  BOOST_REQUIRE(static_cast<bool>((rib.find(name3)->second)->getParent()));
+  BOOST_CHECK_EQUAL((rib.find(name3)->second)->getParent()->getName(), name4);
+}
+
+BOOST_AUTO_TEST_CASE(EraseFace)
+{
+  rib::Rib rib;
+
+  Route route1 = createRoute(1, 20);
+  Name name1("/");
+  rib.insert(name1, route1);
+
+  Route route2 = createRoute(2, 20);
+  Name name2("/hello/world");
+  rib.insert(name2, route2);
+
+  Route route3 = createRoute(1, 20);
+  Name name3("/hello/world");
+  rib.insert(name3, route3);
+
+  Route route4 = createRoute(1, 20);
+  Name name4("/not/inserted");
+
+  rib.erase(name4, route4);
+  rib.erase(name1, route1);
+
+  BOOST_CHECK(rib.find(name1) == rib.end());
+  BOOST_CHECK_EQUAL((rib.find(name2)->second)->getRoutes().size(), 2);
+
+  rib.erase(name2, route2);
+
+  BOOST_CHECK_EQUAL((rib.find(name2)->second)->getRoutes().size(), 1);
+  BOOST_CHECK_EQUAL((rib.find(name2)->second)->getRoutes().front().faceId, 1);
+
+  rib.erase(name3, route3);
+
+  BOOST_CHECK(rib.find(name2) == rib.end());
+
+  rib.erase(name4, route4);
+}
+
+BOOST_AUTO_TEST_CASE(EraseRibEntry)
+{
+  rib::Rib rib;
+
+  Name name1("/");
+  rib.insert(name1, createRoute(1, 20));
+
+  Route route2 = createRoute(2, 20);
+  Name name2("/hello");
+  rib.insert(name2, route2);
+
+  Name name3("/hello/world");
+  rib.insert(name3, createRoute(1, 20));
+
+  shared_ptr<rib::RibEntry> ribEntry1 = rib.find(name1)->second;
+  shared_ptr<rib::RibEntry> ribEntry2 = rib.find(name2)->second;
+  shared_ptr<rib::RibEntry> ribEntry3 = rib.find(name3)->second;
+
+  BOOST_CHECK(ribEntry1->getChildren().front() == ribEntry2);
+  BOOST_CHECK(ribEntry3->getParent() == ribEntry2);
+
+  rib.erase(name2, route2);
+  BOOST_CHECK(ribEntry1->getChildren().front() == ribEntry3);
+  BOOST_CHECK(ribEntry3->getParent() == ribEntry1);
+}
+
+BOOST_AUTO_TEST_CASE(Basic)
+{
+  rib::Rib rib;
+
+  Route route1;
+  Name name1("/hello/world");
+  route1.faceId = 1;
+  route1.cost = 10;
+  route1.flags = ndn::nfd::ROUTE_FLAG_CHILD_INHERIT | ndn::nfd::ROUTE_FLAG_CAPTURE;
+  route1.expires = time::steady_clock::now() + time::milliseconds(1500);
+
+  rib.insert(name1, route1);
+  BOOST_CHECK_EQUAL(rib.size(), 1);
+
+  rib.insert(name1, route1);
+  BOOST_CHECK_EQUAL(rib.size(), 1);
+
+  Route route2;
+  Name name2("/hello/world");
+  route2.faceId = 1;
+  route2.cost = 100;
+  route2.flags = ndn::nfd::ROUTE_FLAG_CHILD_INHERIT;
+  route2.expires = time::steady_clock::now() + time::seconds(0);
+
+  rib.insert(name2, route2);
+  BOOST_CHECK_EQUAL(rib.size(), 1);
+
+  route2.faceId = 2;
+  rib.insert(name2, route2);
+  BOOST_CHECK_EQUAL(rib.size(), 2);
+
+  BOOST_CHECK(rib.find(name1)->second->hasFaceId(route1.faceId));
+  BOOST_CHECK(rib.find(name1)->second->hasFaceId(route2.faceId));
+
+  Name name3("/foo/bar");
+  rib.insert(name3, route2);
+  BOOST_CHECK_EQUAL(rib.size(), 3);
+
+  route2.origin = ndn::nfd::ROUTE_ORIGIN_AUTOCONF;
+  rib.insert(name3, route2);
+  BOOST_CHECK_EQUAL(rib.size(), 4);
+
+  rib.erase(name3, route2);
+  BOOST_CHECK_EQUAL(rib.size(), 3);
+
+  Name name4("/hello/world");
+  rib.erase(name4, route2);
+  BOOST_CHECK_EQUAL(rib.size(), 3);
+
+  route2.origin = ndn::nfd::ROUTE_ORIGIN_APP;
+  rib.erase(name4, route2);
+  BOOST_CHECK_EQUAL(rib.size(), 2);
+
+  BOOST_CHECK(rib.find(name2, route2) == nullptr);
+  BOOST_CHECK(rib.find(name1, route1) != nullptr);
+
+  Name name5("/hello/world/666");
+  Name name6("/hello/world/cs/ua/edu");
+  BOOST_CHECK(rib.findLongestPrefix(name1, route1) != nullptr);
+  BOOST_CHECK(rib.findLongestPrefix(name5, route1) != nullptr);
+  BOOST_CHECK(rib.findLongestPrefix(name6, route1) != nullptr);
+
+  rib.erase(name1, route1);
+  BOOST_CHECK_EQUAL(rib.size(), 1);
+}
+
+BOOST_AUTO_TEST_CASE(RibSignals)
+{
+  rib::Rib rib;
+
+  Route route;
+  Name name("/hello/world");
+
+  Route route1 = createRoute(1, 20, 10);
+  Route route2 = createRoute(2, 30, 20);
+
+  RibRouteRef routeInfo;
+
+  int nAfterInsertEntryInvocations = 0;
+  int nAfterAddRouteInvocations = 0;
+  int nBeforeRemoveRouteInvocations = 0;
+  int nAfterEraseEntryInvocations = 0;
+  rib.afterInsertEntry.connect([&] (const Name& inName) {
+      BOOST_CHECK_EQUAL(nAfterInsertEntryInvocations, 0);
+      BOOST_CHECK_EQUAL(nAfterAddRouteInvocations, 0);
+      BOOST_CHECK(rib.find(name) != rib.end());
+      nAfterInsertEntryInvocations++;
+    });
+
+  rib.afterAddRoute.connect([&] (const RibRouteRef& rrr) {
+      BOOST_CHECK_EQUAL(nAfterInsertEntryInvocations, 1);
+      BOOST_CHECK(rib.find(name) != rib.end());
+      BOOST_CHECK(rib.find(name, route) != nullptr);
+      nAfterAddRouteInvocations++;
+    });
+
+  rib.beforeRemoveRoute.connect([&] (const RibRouteRef& rrr) {
+      BOOST_CHECK_EQUAL(nAfterEraseEntryInvocations, 0);
+      BOOST_CHECK(rib.find(name) != rib.end());
+      BOOST_CHECK(rib.find(name, route) != nullptr);
+      nBeforeRemoveRouteInvocations++;
+    });
+
+  rib.afterEraseEntry.connect([&] (const Name& inName) {
+      BOOST_CHECK_EQUAL(nBeforeRemoveRouteInvocations, 2);
+      BOOST_CHECK_EQUAL(nAfterEraseEntryInvocations, 0);
+      BOOST_CHECK(rib.find(name) == rib.end());
+      nAfterEraseEntryInvocations++;
+    });
+
+  route = route1;
+  rib.insert(name, route);
+  BOOST_CHECK_EQUAL(nAfterInsertEntryInvocations, 1);
+  BOOST_CHECK_EQUAL(nAfterAddRouteInvocations, 1);
+
+  route = route2;
+  rib.insert(name, route);
+  BOOST_CHECK_EQUAL(nAfterInsertEntryInvocations, 1);
+  BOOST_CHECK_EQUAL(nAfterAddRouteInvocations, 2);
+
+  route = route1;
+  rib.erase(name, route);
+  BOOST_CHECK_EQUAL(nBeforeRemoveRouteInvocations, 1);
+  BOOST_CHECK_EQUAL(nAfterEraseEntryInvocations, 0);
+
+  route = route2;
+  rib.erase(name, route);
+  BOOST_CHECK_EQUAL(nBeforeRemoveRouteInvocations, 2);
+  BOOST_CHECK_EQUAL(nAfterEraseEntryInvocations, 1);
+}
+
+BOOST_AUTO_TEST_CASE(Output)
+{
+  rib::Rib rib;
+
+  Route root = createRoute(1, 20);
+  Name name1("/");
+  root.expires = nullopt;
+  rib.insert(name1, root);
+
+  Route route1 = createRoute(2, 20);
+  Name name2("/hello");
+  route1.expires = nullopt;
+  rib.insert(name2, route1);
+
+  Route route2 = createRoute(3, 20);
+  Name name3("/hello/world");
+  route2.expires = nullopt;
+  rib.insert(name3, route2);
+
+  const std::string ribStr = std::string(R"TEXT(
+RibEntry {
+  Name: /
+  Route(faceid: 1, origin: 20, cost: 0, flags: 0x0, never expires)
+}
+RibEntry {
+  Name: /hello
+  Route(faceid: 2, origin: 20, cost: 0, flags: 0x0, never expires)
+}
+RibEntry {
+  Name: /hello/world
+  Route(faceid: 3, origin: 20, cost: 0, flags: 0x0, never expires)
+}
+)TEXT").substr(1);
+
+  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(rib), ribStr);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // TestRib
+
+} // namespace tests
+} // namespace rib
+} // namespace nfd
diff --git a/tests/daemon/rib/route.t.cpp b/tests/daemon/rib/route.t.cpp
new file mode 100644
index 0000000..b1390b8
--- /dev/null
+++ b/tests/daemon/rib/route.t.cpp
@@ -0,0 +1,165 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2014-2018,  Regents of the University of California,
+ *                           Arizona Board of Regents,
+ *                           Colorado State University,
+ *                           University Pierre & Marie Curie, Sorbonne University,
+ *                           Washington University in St. Louis,
+ *                           Beijing Institute of Technology,
+ *                           The University of Memphis.
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "rib/route.hpp"
+
+#include "tests/test-common.hpp"
+
+namespace nfd {
+namespace rib {
+namespace tests {
+
+using namespace nfd::tests;
+
+BOOST_FIXTURE_TEST_SUITE(TestRoute, BaseFixture)
+
+BOOST_FIXTURE_TEST_SUITE(CreateFromAnnouncement, UnitTestTimeFixture)
+
+BOOST_AUTO_TEST_CASE(NoValidity)
+{
+  auto pa = makePrefixAnn("/A", 212_s);
+  Route route(pa, 1815);
+  BOOST_CHECK_EQUAL(route.faceId, 1815);
+  BOOST_CHECK_EQUAL(route.origin, ndn::nfd::ROUTE_ORIGIN_PREFIXANN);
+  BOOST_CHECK_EQUAL(route.cost, 2048);
+  BOOST_CHECK_EQUAL(route.flags, ndn::nfd::ROUTE_FLAG_CHILD_INHERIT);
+  BOOST_CHECK_EQUAL(route.annExpires, time::steady_clock::now() + 212_s);
+  BOOST_REQUIRE(route.expires);
+  BOOST_CHECK_EQUAL(*route.expires, route.annExpires);
+}
+
+BOOST_AUTO_TEST_CASE(BeforeNotBefore)
+{
+  auto pa = makePrefixAnn("/A", 212_s, {10_s, 80_s});
+  Route route(pa, 1053);
+  BOOST_CHECK_LE(route.annExpires, time::steady_clock::now());
+  BOOST_REQUIRE(route.expires);
+  BOOST_CHECK_LE(*route.expires, time::steady_clock::now());
+}
+
+BOOST_AUTO_TEST_CASE(AfterNotAfter)
+{
+  auto pa = makePrefixAnn("/A", 212_s, {-80_s, -10_s});
+  Route route(pa, 2972);
+  BOOST_CHECK_LE(route.annExpires, time::steady_clock::now());
+  BOOST_REQUIRE(route.expires);
+  BOOST_CHECK_LE(*route.expires, time::steady_clock::now());
+}
+
+BOOST_AUTO_TEST_CASE(ExpirationLtValidity)
+{
+  auto pa = makePrefixAnn("/A", 212_s, {-100_s, 300_s});
+  Route route(pa, 7804);
+  BOOST_CHECK_EQUAL(route.annExpires, time::steady_clock::now() + 212_s);
+  BOOST_REQUIRE(route.expires);
+  BOOST_CHECK_EQUAL(*route.expires, route.annExpires);
+}
+
+BOOST_AUTO_TEST_CASE(ValidityLtExpiration)
+{
+  auto pa = makePrefixAnn("/A", 212_s, {-100_s, 200_s});
+  Route route(pa, 7804);
+  BOOST_CHECK_EQUAL(route.annExpires, time::steady_clock::now() + 200_s);
+  BOOST_REQUIRE(route.expires);
+  BOOST_CHECK_EQUAL(*route.expires, route.annExpires);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // CreateFromAnnouncement
+
+BOOST_AUTO_TEST_CASE(Equality)
+{
+  Route a;
+  Route b;
+  BOOST_CHECK_EQUAL(a, b);
+
+  a.faceId = b.faceId = 15404;
+  a.origin = b.origin = ndn::nfd::ROUTE_ORIGIN_NLSR;
+  a.flags = b.flags = ndn::nfd::ROUTE_FLAG_CHILD_INHERIT;
+  a.cost = b.cost = 28826;
+  a.expires = b.expires = time::steady_clock::now() + 26782232_ms;
+  BOOST_CHECK_EQUAL(a, b);
+
+  b.faceId = 18559;
+  BOOST_CHECK_NE(a, b);
+  a.faceId = 18559;
+
+  b.origin = ndn::nfd::ROUTE_ORIGIN_CLIENT;
+  BOOST_CHECK_NE(a, b);
+  a.origin = ndn::nfd::ROUTE_ORIGIN_CLIENT;
+
+  b.flags = ndn::nfd::ROUTE_FLAG_CAPTURE;
+  BOOST_CHECK_NE(a, b);
+  a.flags = ndn::nfd::ROUTE_FLAG_CAPTURE;
+
+  b.cost = 103;
+  BOOST_CHECK_NE(a, b);
+  a.cost = 103;
+
+  b.expires = nullopt;
+  BOOST_CHECK_NE(a, b);
+  a.expires = nullopt;
+
+  BOOST_CHECK_EQUAL(a, b);
+}
+
+BOOST_FIXTURE_TEST_CASE(EqualityAnn, UnitTestTimeFixture)
+{
+  auto ann1 = makePrefixAnn("/ann", 1_h);
+  auto ann2 = makePrefixAnn("/ann", 2_h);
+  BOOST_CHECK_EQUAL(Route(ann1, 7001), Route(ann1, 7001));
+  BOOST_CHECK_NE(Route(ann1, 7001), Route(ann1, 7002));
+  BOOST_CHECK_NE(Route(ann1, 7001), Route(ann2, 7001));
+}
+
+BOOST_FIXTURE_TEST_CASE(Output, UnitTestTimeFixture)
+{
+  Route r;
+  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(r),
+                    "Route(faceid: 0, origin: app, cost: 0, flags: 0x0, never expires)");
+
+  r.faceId = 4980;
+  r.origin = ndn::nfd::ROUTE_ORIGIN_STATIC;
+  r.flags = ndn::nfd::ROUTE_FLAG_CHILD_INHERIT;
+  r.cost = 2312;
+  r.expires = time::steady_clock::now() + 791214234_ms;
+  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(r),
+                    "Route(faceid: 4980, origin: static, cost: 2312, flags: 0x1, expires in: "
+                    "791214234 milliseconds)");
+
+  r.expires = nullopt;
+  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(r),
+                    "Route(faceid: 4980, origin: static, cost: 2312, flags: 0x1, never expires)");
+
+  r = Route(makePrefixAnn("/ann", 1_h), 3247);
+  BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(r),
+                    "Route(faceid: 3247, origin: prefixann, cost: 2048, flags: 0x1, expires in: "
+                    "3600000 milliseconds, announcement: (/ann expires=3600000 milliseconds))");
+}
+
+BOOST_AUTO_TEST_SUITE_END() // TestRoute
+
+} // namespace tests
+} // namespace rib
+} // namespace nfd
diff --git a/tests/daemon/rib/service.t.cpp b/tests/daemon/rib/service.t.cpp
new file mode 100644
index 0000000..14ee649
--- /dev/null
+++ b/tests/daemon/rib/service.t.cpp
@@ -0,0 +1,62 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2014-2018,  Regents of the University of California,
+ *                           Arizona Board of Regents,
+ *                           Colorado State University,
+ *                           University Pierre & Marie Curie, Sorbonne University,
+ *                           Washington University in St. Louis,
+ *                           Beijing Institute of Technology,
+ *                           The University of Memphis.
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "rib/service.hpp"
+#include "tests/rib-io-fixture.hpp"
+#include "tests/test-common.hpp"
+
+namespace nfd {
+namespace rib {
+namespace tests {
+
+BOOST_FIXTURE_TEST_SUITE(TestService, nfd::tests::RibIoFixture)
+
+BOOST_AUTO_TEST_CASE(Basic)
+{
+  ConfigSection section;
+  section.put("face_system.unix.path", "/var/run/nfd.sock");
+
+  ndn::KeyChain ribKeyChain;
+
+  BOOST_CHECK_THROW(Service::get(), std::logic_error);
+  BOOST_CHECK_THROW(Service(section, ribKeyChain), std::logic_error);
+
+  runOnRibIoService([&] {
+    {
+      BOOST_CHECK_THROW(Service::get(), std::logic_error);
+      Service ribService(section, ribKeyChain);
+      BOOST_CHECK_EQUAL(&ribService, &Service::get());
+    }
+    BOOST_CHECK_THROW(Service::get(), std::logic_error);
+    Service ribService(section, ribKeyChain);
+    BOOST_CHECK_THROW(Service(section, ribKeyChain), std::logic_error);
+  });
+}
+
+BOOST_AUTO_TEST_SUITE_END() // TestRibService
+
+} // namespace tests
+} // namespace rib
+} // namespace nfd
diff --git a/tests/daemon/rib/sl-announce.t.cpp b/tests/daemon/rib/sl-announce.t.cpp
new file mode 100644
index 0000000..86b6025
--- /dev/null
+++ b/tests/daemon/rib/sl-announce.t.cpp
@@ -0,0 +1,334 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2014-2018,  Regents of the University of California,
+ *                           Arizona Board of Regents,
+ *                           Colorado State University,
+ *                           University Pierre & Marie Curie, Sorbonne University,
+ *                           Washington University in St. Louis,
+ *                           Beijing Institute of Technology,
+ *                           The University of Memphis.
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "rib/rib-manager.hpp"
+
+#include "tests/identity-management-fixture.hpp"
+
+#include <ndn-cxx/util/dummy-client-face.hpp>
+
+namespace nfd {
+namespace rib {
+namespace tests {
+
+using namespace nfd::tests;
+
+class RibManagerSlAnnounceFixture : public IdentityManagementTimeFixture
+{
+public:
+  using SlAnnounceResult = RibManager::SlAnnounceResult;
+
+  RibManagerSlAnnounceFixture()
+    : m_face(g_io, m_keyChain)
+    , m_scheduler(g_io)
+    , m_nfdController(m_face, m_keyChain)
+    , m_dispatcher(m_face, m_keyChain)
+    , m_fibUpdater(rib, m_nfdController)
+    , m_trustedSigner(m_keyChain.createIdentity("/trusted", ndn::RsaKeyParams()))
+    , m_untrustedSigner(m_keyChain.createIdentity("/untrusted", ndn::RsaKeyParams()))
+  {
+    rib.mockFibResponse = [] (const RibUpdateBatch&) { return true; };
+    rib.wantMockFibResponseOnce = false;
+
+    // Face, Controller, Dispatcher are irrelevant to SlAnnounce functions but required by
+    // RibManager construction, so they are private. RibManager is a pointer to avoid code style
+    // rule 1.4 violation.
+    manager = make_unique<RibManager>(rib, m_face, m_keyChain, m_nfdController, m_dispatcher, m_scheduler);
+
+    loadTrustSchema();
+  }
+
+  template<typename ...T>
+  ndn::PrefixAnnouncement
+  makeTrustedAnn(const T&... args)
+  {
+    return signPrefixAnn(makePrefixAnn(args...), m_keyChain, m_trustedSigner);
+  }
+
+  template<typename ...T>
+  ndn::PrefixAnnouncement
+  makeUntrustedAnn(const T&... args)
+  {
+    return signPrefixAnn(makePrefixAnn(args...), m_keyChain, m_untrustedSigner);
+  }
+
+  /** \brief Invoke manager->slAnnounce and wait for result.
+   */
+  SlAnnounceResult
+  slAnnounceSync(const ndn::PrefixAnnouncement& pa, uint64_t faceId, time::milliseconds maxLifetime)
+  {
+    optional<SlAnnounceResult> result;
+    manager->slAnnounce(pa, faceId, maxLifetime,
+      [&] (RibManager::SlAnnounceResult res) {
+        BOOST_CHECK(!result);
+        result = res;
+      });
+
+    g_io.poll();
+    BOOST_CHECK(result);
+    return result.value_or(SlAnnounceResult::ERROR);
+  }
+
+  /** \brief Invoke manager->slRenew and wait for result.
+   */
+  SlAnnounceResult
+  slRenewSync(const Name& name, uint64_t faceId, time::milliseconds maxLifetime)
+  {
+    optional<SlAnnounceResult> result;
+    manager->slRenew(name, faceId, maxLifetime,
+      [&] (RibManager::SlAnnounceResult res) {
+        BOOST_CHECK(!result);
+        result = res;
+      });
+
+    g_io.poll();
+    BOOST_CHECK(result);
+    return result.value_or(SlAnnounceResult::ERROR);
+  }
+
+  /** \brief Invoke manager->slFindAnn and wait for result.
+   */
+  optional<ndn::PrefixAnnouncement>
+  slFindAnnSync(const Name& name)
+  {
+    optional<optional<ndn::PrefixAnnouncement>> result;
+    manager->slFindAnn(name,
+      [&] (optional<ndn::PrefixAnnouncement> found) {
+        BOOST_CHECK(!result);
+        result = found;
+      });
+
+    g_io.poll();
+    BOOST_CHECK(result);
+    return result.value_or(nullopt);
+  }
+
+  /** \brief Lookup a route with PREFIXANN origin.
+   */
+  Route*
+  findAnnRoute(const Name& name, uint64_t faceId)
+  {
+    Route routeQuery;
+    routeQuery.faceId = faceId;
+    routeQuery.origin = ndn::nfd::ROUTE_ORIGIN_PREFIXANN;
+    return rib.find(name, routeQuery);
+  }
+
+private:
+  /** \brief Prepare a trust schema and load as localhop_security.
+   *
+   *  Test case may revert this operation with ribManager->disableLocalhop().
+   */
+  void
+  loadTrustSchema()
+  {
+    ConfigSection section;
+    section.put("rule.id", "PA");
+    section.put("rule.for", "data");
+    section.put("rule.checker.type", "customized");
+    section.put("rule.checker.sig-type", "rsa-sha256");
+    section.put("rule.checker.key-locator.type", "name");
+    section.put("rule.checker.key-locator.name", "/trusted");
+    section.put("rule.checker.key-locator.relation", "is-prefix-of");
+    section.put("trust-anchor.type", "base64");
+    section.put("trust-anchor.base64-string", getIdentityCertificateBase64("/trusted"));
+    manager->enableLocalhop(section, "trust-schema.section");
+  }
+
+public:
+  Rib rib;
+  unique_ptr<RibManager> manager;
+
+private:
+  ndn::util::DummyClientFace m_face;
+  ndn::util::Scheduler m_scheduler;
+  ndn::nfd::Controller m_nfdController;
+  ndn::mgmt::Dispatcher m_dispatcher;
+  FibUpdater m_fibUpdater;
+
+  ndn::security::SigningInfo m_trustedSigner;
+  ndn::security::SigningInfo m_untrustedSigner;
+};
+
+BOOST_FIXTURE_TEST_SUITE(TestSlAnnounce, RibManagerSlAnnounceFixture)
+
+BOOST_AUTO_TEST_CASE(AnnounceUnconfigured)
+{
+  manager->disableLocalhop();
+  auto pa = makeTrustedAnn("/fMXN7UeB", 1_h);
+  BOOST_CHECK_EQUAL(slAnnounceSync(pa, 3275, 1_h), SlAnnounceResult::VALIDATION_FAILURE);
+
+  BOOST_CHECK(findAnnRoute("/fMXN7UeB", 3275) == nullptr);
+}
+
+BOOST_AUTO_TEST_CASE(AnnounceValidationError)
+{
+  auto pa = makeUntrustedAnn("/1nzAe0Y4", 1_h);
+  BOOST_CHECK_EQUAL(slAnnounceSync(pa, 2959, 1_h), SlAnnounceResult::VALIDATION_FAILURE);
+
+  BOOST_CHECK(findAnnRoute("/1nzAe0Y4", 2959) == nullptr);
+}
+
+BOOST_AUTO_TEST_CASE(AnnounceInsert_AnnLifetime)
+{
+  auto pa = makeTrustedAnn("/EHJYmJz9", 1_h);
+  BOOST_CHECK_EQUAL(slAnnounceSync(pa, 1641, 2_h), SlAnnounceResult::OK);
+
+  Route* route = findAnnRoute("/EHJYmJz9", 1641);
+  BOOST_REQUIRE(route != nullptr);
+  BOOST_CHECK_EQUAL(route->annExpires, time::steady_clock::now() + 1_h);
+  BOOST_CHECK_EQUAL(route->expires.value(), time::steady_clock::now() + 1_h);
+}
+
+BOOST_AUTO_TEST_CASE(AnnounceInsert_ArgLifetime)
+{
+  auto pa = makeTrustedAnn("/BU9Fec9E", 2_h);
+  BOOST_CHECK_EQUAL(slAnnounceSync(pa, 1282, 1_h), SlAnnounceResult::OK);
+
+  Route* route = findAnnRoute("/BU9Fec9E", 1282);
+  BOOST_REQUIRE(route != nullptr);
+  BOOST_CHECK_EQUAL(route->annExpires, time::steady_clock::now() + 2_h);
+  BOOST_CHECK_EQUAL(route->expires.value(), time::steady_clock::now() + 1_h);
+}
+
+BOOST_AUTO_TEST_CASE(AnnounceReplace)
+{
+  auto pa = makeTrustedAnn("/HsBFGvL3", 1_h);
+  BOOST_CHECK_EQUAL(slAnnounceSync(pa, 2813, 1_h), SlAnnounceResult::OK);
+
+  pa = makeTrustedAnn("/HsBFGvL3", 2_h);
+  BOOST_CHECK_EQUAL(slAnnounceSync(pa, 2813, 2_h), SlAnnounceResult::OK);
+
+  Route* route = findAnnRoute("/HsBFGvL3", 2813);
+  BOOST_REQUIRE(route != nullptr);
+  BOOST_CHECK_EQUAL(route->annExpires, time::steady_clock::now() + 2_h);
+  BOOST_CHECK_EQUAL(route->expires.value(), time::steady_clock::now() + 2_h);
+}
+
+BOOST_AUTO_TEST_CASE(AnnounceExpired)
+{
+  auto pa = makeTrustedAnn("/awrVv6V7", 1_h, std::make_pair(-3_h, -1_h));
+  BOOST_CHECK_EQUAL(slAnnounceSync(pa, 9087, 1_h), SlAnnounceResult::EXPIRED);
+
+  BOOST_CHECK(findAnnRoute("/awrVv6V7", 9087) == nullptr);
+}
+
+BOOST_AUTO_TEST_CASE(RenewNotFound)
+{
+  BOOST_CHECK_EQUAL(slRenewSync("IAYigN73", 1070, 1_h), SlAnnounceResult::NOT_FOUND);
+
+  BOOST_CHECK(findAnnRoute("/IAYigN73", 1070) == nullptr);
+}
+
+BOOST_AUTO_TEST_CASE(RenewProlong_ArgLifetime)
+{
+  auto pa = makeTrustedAnn("/P2IYFqtr", 4_h);
+  BOOST_CHECK_EQUAL(slAnnounceSync(pa, 4506, 2_h), SlAnnounceResult::OK);
+  advanceClocks(1_h); // Route has 1_h remaining lifetime
+
+  BOOST_CHECK_EQUAL(slRenewSync("/P2IYFqtr/2321", 4506, 2_h), SlAnnounceResult::OK);
+
+  Route* route = findAnnRoute("/P2IYFqtr", 4506);
+  BOOST_REQUIRE(route != nullptr);
+  BOOST_CHECK_EQUAL(route->annExpires, time::steady_clock::now() + 3_h);
+  BOOST_CHECK_EQUAL(route->expires.value(), time::steady_clock::now() + 2_h); // set by slRenew
+}
+
+BOOST_AUTO_TEST_CASE(RenewProlong_AnnLifetime)
+{
+  auto pa = makeTrustedAnn("/be01Yiba", 4_h);
+  BOOST_CHECK_EQUAL(slAnnounceSync(pa, 1589, 2_h), SlAnnounceResult::OK);
+  advanceClocks(1_h); // Route has 1_h remaining lifetime
+
+  BOOST_CHECK_EQUAL(slRenewSync("/be01Yiba/4324", 1589, 5_h), SlAnnounceResult::OK);
+
+  Route* route = findAnnRoute("/be01Yiba", 1589);
+  BOOST_REQUIRE(route != nullptr);
+  BOOST_CHECK_EQUAL(route->annExpires, time::steady_clock::now() + 3_h);
+  BOOST_CHECK_EQUAL(route->expires.value(), time::steady_clock::now() + 3_h); // capped by annExpires
+}
+
+BOOST_AUTO_TEST_CASE(RenewShorten)
+{
+  auto pa = makeTrustedAnn("/5XCHYCAd", 4_h);
+  BOOST_CHECK_EQUAL(slAnnounceSync(pa, 3851, 4_h), SlAnnounceResult::OK);
+  advanceClocks(1_h); // Route has 3_h remaining lifetime
+
+  BOOST_CHECK_EQUAL(slRenewSync("/5XCHYCAd/98934", 3851, 1_h), SlAnnounceResult::OK);
+
+  Route* route = findAnnRoute("/5XCHYCAd", 3851);
+  BOOST_REQUIRE(route != nullptr);
+  BOOST_CHECK_EQUAL(route->annExpires, time::steady_clock::now() + 3_h);
+  BOOST_CHECK_EQUAL(route->expires.value(), time::steady_clock::now() + 1_h); // set by slRenew
+}
+
+BOOST_AUTO_TEST_CASE(RenewShorten_Zero)
+{
+  auto pa = makeTrustedAnn("/cdQ7KPNw", 4_h);
+  BOOST_CHECK_EQUAL(slAnnounceSync(pa, 8031, 4_h), SlAnnounceResult::OK);
+  advanceClocks(1_h); // Route has 3_h remaining lifetime
+
+  BOOST_CHECK_EQUAL(slRenewSync("/cdQ7KPNw/8023", 8031, 0_s), SlAnnounceResult::EXPIRED);
+
+  BOOST_CHECK(findAnnRoute("/cdQ7KPNw", 8031) == nullptr);
+}
+
+BOOST_AUTO_TEST_CASE(FindExisting)
+{
+  auto pa = makeTrustedAnn("/JHugsjjr", 1_h);
+  BOOST_CHECK_EQUAL(slAnnounceSync(pa, 2363, 1_h), SlAnnounceResult::OK);
+
+  auto found = slFindAnnSync("/JHugsjjr");
+  BOOST_REQUIRE(found);
+  BOOST_CHECK_EQUAL(found->getAnnouncedName(), "/JHugsjjr");
+  BOOST_CHECK(found->getData());
+
+  auto found2 = slFindAnnSync("/JHugsjjr/StvXhKR5");
+  BOOST_CHECK(found == found2);
+}
+
+BOOST_AUTO_TEST_CASE(FindNew)
+{
+  Route route;
+  route.faceId = 1367;
+  route.origin = ndn::nfd::ROUTE_ORIGIN_APP;
+  rib.insert("/dLY1pRhR", route);
+
+  auto pa = slFindAnnSync("/dLY1pRhR/3qNK9Ngn");
+  BOOST_REQUIRE(pa);
+  BOOST_CHECK_EQUAL(pa->getAnnouncedName(), "/dLY1pRhR");
+}
+
+BOOST_AUTO_TEST_CASE(FindNone)
+{
+  auto pa = slFindAnnSync("/2YNeYuV2");
+  BOOST_CHECK(!pa);
+}
+
+BOOST_AUTO_TEST_SUITE_END() // TestSlAnnounce
+
+} // namespace tests
+} // namespace rib
+} // namespace nfd
