rib: ReadvertiseDestination availability
refs: #3818
Change-Id: Ifc2875ba38025595f3d6a8f8207f5ec126f93c90
diff --git a/tests/rib/readvertise/nfd-rib-readvertise-destination.t.cpp b/tests/rib/readvertise/nfd-rib-readvertise-destination.t.cpp
index 433c92f..61cfb62 100644
--- a/tests/rib/readvertise/nfd-rib-readvertise-destination.t.cpp
+++ b/tests/rib/readvertise/nfd-rib-readvertise-destination.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2016, Regents of the University of California,
+ * Copyright (c) 2014-2017, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -46,7 +46,7 @@
, nFailureCallbacks(0)
, face(getGlobalIoService(), m_keyChain, {true, false})
, controller(face, m_keyChain)
- , dest(controller, Name("/localhop/nfd/rib/readvertise"))
+ , dest(controller, Name("/localhop/nfd/rib/readvertise"), rib)
, successCallback([this] () {
nSuccessCallbacks++;
})
@@ -63,6 +63,7 @@
protected:
ndn::util::DummyClientFace face;
ndn::nfd::Controller controller;
+ Rib rib;
NfdRibReadvertiseDestination dest;
std::function<void()> successCallback;
std::function<void(const std::string&)> failureCallback;
@@ -231,6 +232,30 @@
scenario.checkCommandOutcome(this);
}
+BOOST_AUTO_TEST_CASE(DestinationAvailability)
+{
+ std::vector<bool> availabilityChangeHistory;
+ Name prefix("/localhop/nfd/rib/readvertise");
+ Route route;
+
+ dest.afterAvailabilityChange.connect(
+ std::bind(&std::vector<bool>::push_back, &availabilityChangeHistory, _1));
+ BOOST_CHECK_EQUAL(dest.isAvailable(), false);
+
+ rib.insert(prefix, route);
+ this->advanceClocks(time::milliseconds(100), 1);
+ BOOST_CHECK_EQUAL(dest.isAvailable(), true);
+ BOOST_CHECK_EQUAL(availabilityChangeHistory.size(), 1);
+ BOOST_CHECK_EQUAL(availabilityChangeHistory.back(), true);
+
+ rib.erase(prefix, route);
+
+ this->advanceClocks(time::milliseconds(100), 1);
+ BOOST_CHECK_EQUAL(dest.isAvailable(), false);
+ BOOST_CHECK_EQUAL(availabilityChangeHistory.size(), 2);
+ BOOST_CHECK_EQUAL(availabilityChangeHistory.back(), false);
+}
+
BOOST_AUTO_TEST_SUITE_END() // TestNfdRibReadvertiseDestination
} // namespace tests