face/mgmt/fw/tools: add localUri to FaceStatus and FaceEventNotification
refs #1396
Change-Id: I6084745c62c44a409ecbd4a795cb712475e32416
diff --git a/tests/mgmt/face-flags.cpp b/tests/mgmt/face-flags.cpp
new file mode 100644
index 0000000..00e4c8b
--- /dev/null
+++ b/tests/mgmt/face-flags.cpp
@@ -0,0 +1,47 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (C) 2014 Named Data Networking Project
+ * See COPYING for copyright and distribution information.
+ */
+
+#include "mgmt/face-flags.hpp"
+
+#include "tests/test-common.hpp"
+#include "tests/face/dummy-face.hpp"
+
+namespace nfd {
+namespace tests {
+
+BOOST_FIXTURE_TEST_SUITE(MgmtFaceFlags, BaseFixture)
+
+template<typename DummyFaceBase>
+class DummyOnDemandFace : public DummyFaceBase
+{
+public:
+ DummyOnDemandFace()
+ {
+ this->setOnDemand(true);
+ }
+};
+
+BOOST_AUTO_TEST_CASE(Get)
+{
+ DummyFace face1;
+ BOOST_CHECK_EQUAL(getFaceFlags(face1), 0);
+
+ DummyLocalFace face2;
+ BOOST_CHECK_EQUAL(getFaceFlags(face2), static_cast<uint64_t>(ndn::nfd::FACE_IS_LOCAL));
+
+ DummyOnDemandFace<DummyFace> face3;
+ BOOST_CHECK_EQUAL(getFaceFlags(face3), static_cast<uint64_t>(ndn::nfd::FACE_IS_ON_DEMAND));
+
+ DummyOnDemandFace<DummyLocalFace> face4;
+ BOOST_CHECK_EQUAL(getFaceFlags(face4), static_cast<uint64_t>(ndn::nfd::FACE_IS_LOCAL |
+ ndn::nfd::FACE_IS_ON_DEMAND));
+
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace tests
+} // namespace nfd
diff --git a/tests/mgmt/face-manager.cpp b/tests/mgmt/face-manager.cpp
index 1c3734d..4d6830c 100644
--- a/tests/mgmt/face-manager.cpp
+++ b/tests/mgmt/face-manager.cpp
@@ -1323,9 +1323,10 @@
ndn::nfd::FaceEventNotification notification(wire);
+ BOOST_CHECK_EQUAL(notification.getKind(), expectedFaceEvent.getKind());
BOOST_CHECK_EQUAL(notification.getFaceId(), expectedFaceEvent.getFaceId());
- BOOST_CHECK_EQUAL(notification.getUri(), expectedFaceEvent.getUri());
- BOOST_CHECK_EQUAL(notification.getEventKind(), expectedFaceEvent.getEventKind());
+ BOOST_CHECK_EQUAL(notification.getRemoteUri(), expectedFaceEvent.getRemoteUri());
+ BOOST_CHECK_EQUAL(notification.getLocalUri(), expectedFaceEvent.getLocalUri());
}
bool
@@ -1428,10 +1429,12 @@
shared_ptr<DummyFace> dummy(make_shared<DummyFace>());
- ndn::nfd::FaceEventNotification expectedFaceEvent(ndn::nfd::FACE_EVENT_CREATED,
- 1,
- dummy->getUri().toString(),
- 0);
+ ndn::nfd::FaceEventNotification expectedFaceEvent;
+ expectedFaceEvent.setKind(ndn::nfd::FACE_EVENT_CREATED)
+ .setFaceId(1)
+ .setRemoteUri(dummy->getRemoteUri().toString())
+ .setLocalUri(dummy->getLocalUri().toString())
+ .setFlags(0);
Block encodedResultParameters(resultParameters.wireEncode());
@@ -1488,9 +1491,12 @@
shared_ptr<Interest> command(make_shared<Interest>(commandName));
generateCommand(*command);
- ndn::nfd::FaceEventNotification expectedFaceEvent(ndn::nfd::FACE_EVENT_DESTROYED,
- dummy->getId(),
- dummy->getUri().toString(), 0);
+ ndn::nfd::FaceEventNotification expectedFaceEvent;
+ expectedFaceEvent.setKind(ndn::nfd::FACE_EVENT_DESTROYED)
+ .setFaceId(dummy->getId())
+ .setRemoteUri(dummy->getRemoteUri().toString())
+ .setLocalUri(dummy->getLocalUri().toString())
+ .setFlags(0);
getFace()->onReceiveData +=
bind(&FaceFixture::callbackDispatch, this, _1,
diff --git a/tests/mgmt/face-status-publisher-common.hpp b/tests/mgmt/face-status-publisher-common.hpp
index 59e99f8..2e7ec55 100644
--- a/tests/mgmt/face-status-publisher-common.hpp
+++ b/tests/mgmt/face-status-publisher-common.hpp
@@ -10,12 +10,13 @@
#include "mgmt/face-status-publisher.hpp"
#include "mgmt/app-face.hpp"
#include "mgmt/internal-face.hpp"
+#include "mgmt/face-flags.hpp"
#include "fw/forwarder.hpp"
-#include "../face/dummy-face.hpp"
#include "tests/test-common.hpp"
+#include "tests/face/dummy-face.hpp"
-#include <ndn-cpp-dev/encoding/tlv.hpp>
+#include <ndn-cpp-dev/management/nfd-face-status.hpp>
namespace nfd {
namespace tests {
@@ -34,16 +35,16 @@
}
void
- setCounters(FaceCounter inInterest,
- FaceCounter inData,
- FaceCounter outInterest,
- FaceCounter outData)
+ setCounters(FaceCounter nInInterests,
+ FaceCounter nInDatas,
+ FaceCounter nOutInterests,
+ FaceCounter nOutDatas)
{
FaceCounters& counters = getMutableCounters();
- counters.getInInterest() = inInterest;
- counters.getInData() = inData;
- counters.getOutInterest() = outInterest;
- counters.getOutData() = outData;
+ counters.getNInInterests() = nInInterests;
+ counters.getNInDatas() = nInDatas;
+ counters.getNOutInterests() = nOutInterests;
+ counters.getNOutDatas() = nOutDatas;
}
@@ -102,66 +103,20 @@
}
void
- validateFaceStatus(const Block& status, const shared_ptr<Face>& reference)
+ validateFaceStatus(const Block& statusBlock, const shared_ptr<Face>& reference)
{
+ ndn::nfd::FaceStatus status;
+ BOOST_REQUIRE_NO_THROW(status.wireDecode(statusBlock));
const FaceCounters& counters = reference->getCounters();
- FaceId faceId = INVALID_FACEID;
- std::string uri;
- FaceCounter inInterest = 0;
- FaceCounter inData = 0;
- FaceCounter outInterest = 0;
- FaceCounter outData = 0;
-
- status.parse();
-
- for (Block::element_const_iterator i = status.elements_begin();
- i != status.elements_end();
- ++i)
- {
- // parse a full set of FaceStatus sub-blocks
- faceId =
- checkedReadNonNegativeIntegerType(i,
- status.elements_end(),
- ndn::tlv::nfd::FaceId);
-
- BOOST_REQUIRE_EQUAL(faceId, reference->getId());
-
- BOOST_REQUIRE(i->type() == ndn::tlv::nfd::Uri);
-
- uri.append(reinterpret_cast<const char*>(i->value()), i->value_size());
- ++i;
-
- BOOST_REQUIRE(i != status.elements_end());
-
- BOOST_REQUIRE_EQUAL(uri, reference->getUri().toString());
-
- inInterest =
- checkedReadNonNegativeIntegerType(i,
- status.elements_end(),
- ndn::tlv::nfd::NInInterests);
-
- BOOST_REQUIRE_EQUAL(inInterest, counters.getInInterest());
-
- inData =
- checkedReadNonNegativeIntegerType(i,
- status.elements_end(),
- ndn::tlv::nfd::NInDatas);
-
- BOOST_REQUIRE_EQUAL(inData, counters.getInData());
-
- outInterest =
- checkedReadNonNegativeIntegerType(i,
- status.elements_end(),
- ndn::tlv::nfd::NOutInterests);
- BOOST_REQUIRE_EQUAL(outInterest, counters.getOutInterest());
-
- outData =
- readNonNegativeIntegerType(*i,
- ndn::tlv::nfd::NOutDatas);
-
- BOOST_REQUIRE_EQUAL(outData, counters.getOutData());
- }
+ BOOST_CHECK_EQUAL(status.getFaceId(), reference->getId());
+ BOOST_CHECK_EQUAL(status.getRemoteUri(), reference->getRemoteUri().toString());
+ BOOST_CHECK_EQUAL(status.getLocalUri(), reference->getLocalUri().toString());
+ BOOST_CHECK_EQUAL(status.getFlags(), getFaceFlags(*reference));
+ BOOST_CHECK_EQUAL(status.getNInInterests(), counters.getNInInterests());
+ BOOST_CHECK_EQUAL(status.getNInDatas(), counters.getNInDatas());
+ BOOST_CHECK_EQUAL(status.getNOutInterests(), counters.getNOutInterests());
+ BOOST_CHECK_EQUAL(status.getNOutDatas(), counters.getNOutDatas());
}
void