tests: don't use makeDummyClientFace
refs #3383
Change-Id: I1803a6f482a4e6bf43363cd08a73c4bbcb26d0a2
diff --git a/tests/core/segment-publisher.t.cpp b/tests/core/segment-publisher.t.cpp
index b72c198..4223d19 100644
--- a/tests/core/segment-publisher.t.cpp
+++ b/tests/core/segment-publisher.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2015, Regents of the University of California,
+ * Copyright (c) 2014-2016, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -27,6 +27,7 @@
#include <ndn-cxx/encoding/tlv.hpp>
#include "tests/test-common.hpp"
+#include "tests/identity-management-fixture.hpp"
#include <ndn-cxx/util/dummy-client-face.hpp>
namespace nfd {
@@ -39,9 +40,9 @@
{
public:
SegmentPublisherTester(ndn::util::DummyClientFace& face,
- const Name& prefix,
- ndn::KeyChain& keyChain,
- const time::milliseconds freshnessPeriod)
+ const Name& prefix,
+ ndn::KeyChain& keyChain,
+ const time::milliseconds freshnessPeriod)
: SegmentPublisher(face, prefix, keyChain, freshnessPeriod)
, m_totalPayloadLength(0)
{
@@ -49,9 +50,7 @@
}
virtual
- ~SegmentPublisherTester()
- {
- }
+ ~SegmentPublisherTester() = default;
uint16_t
getLimit() const
@@ -71,10 +70,9 @@
generate(ndn::EncodingBuffer& outBuffer)
{
size_t totalLength = 0;
- for (int64_t i = 0; i < N; i++)
- {
- totalLength += prependNonNegativeIntegerBlock(outBuffer, tlv::Content, i);
- }
+ for (int64_t i = 0; i < N; ++i) {
+ totalLength += prependNonNegativeIntegerBlock(outBuffer, tlv::Content, i);
+ }
m_totalPayloadLength += totalLength;
return totalLength;
}
@@ -84,13 +82,13 @@
};
template<int64_t N>
-class SegmentPublisherFixture : public BaseFixture
+class SegmentPublisherFixture : public IdentityManagementFixture
{
public:
SegmentPublisherFixture()
- : m_face(ndn::util::makeDummyClientFace())
+ : m_face(m_keyChain)
, m_expectedFreshnessPeriod(time::milliseconds(111))
- , m_publisher(*m_face, "/localhost/nfd/SegmentPublisherFixture",
+ , m_publisher(m_face, "/localhost/nfd/SegmentPublisherFixture",
m_keyChain, m_expectedFreshnessPeriod)
{
}
@@ -106,10 +104,9 @@
m_buffer.appendByteArray(payload.value(), payload.value_size());
uint64_t segmentNo = data.getName()[-1].toSegment();
- if (data.getFinalBlockId() != data.getName()[-1])
- {
- return;
- }
+ if (data.getFinalBlockId() != data.getName()[-1]) {
+ return;
+ }
NFD_LOG_DEBUG("got final block: #" << segmentNo);
@@ -125,18 +122,16 @@
BOOST_REQUIRE_EQUAL(parser.elements_size(), m_publisher.getLimit());
uint64_t expectedNo = m_publisher.getLimit() - 1;
- for (Block::element_const_iterator i = parser.elements_begin();
- i != parser.elements_end();
- ++i)
- {
- uint64_t number = readNonNegativeInteger(*i);
+ std::for_each(parser.elements_begin(), parser.elements_end(),
+ [&expectedNo] (const Block& element) {
+ uint64_t number = readNonNegativeInteger(element);
BOOST_REQUIRE_EQUAL(number, expectedNo);
--expectedNo;
- }
+ });
}
protected:
- shared_ptr<ndn::util::DummyClientFace> m_face;
+ ndn::util::DummyClientFace m_face;
const time::milliseconds m_expectedFreshnessPeriod;
SegmentPublisherTester<N> m_publisher;
ndn::EncodingBuffer m_buffer;
@@ -144,23 +139,22 @@
};
using boost::mpl::int_;
-typedef boost::mpl::vector<int_<10000>, int_<100>, int_<10>, int_<0> > DatasetSizes;
+typedef boost::mpl::vector<int_<10000>, int_<100>, int_<10>, int_<0>> DatasetSizes;
BOOST_AUTO_TEST_SUITE(TestSegmentPublisher)
BOOST_FIXTURE_TEST_CASE_TEMPLATE(Generate, T, DatasetSizes, SegmentPublisherFixture<T::value>)
{
this->m_publisher.publish();
- this->m_face->processEvents();
+ this->m_face.processEvents();
- size_t nSegments = this->m_publisher.getTotalPayloadLength() /
- this->m_publisher.getMaxSegmentSize();
- if (this->m_publisher.getTotalPayloadLength() % this->m_publisher.getMaxSegmentSize() != 0 ||
- nSegments == 0)
- ++nSegments;
+ size_t nSegments =
+ this->m_publisher.getTotalPayloadLength() / this->m_publisher.getMaxSegmentSize() +
+ (this->m_publisher.getTotalPayloadLength() % this->m_publisher.getMaxSegmentSize() != 0 ||
+ this->m_publisher.getTotalPayloadLength() == 0);
- BOOST_CHECK_EQUAL(this->m_face->sentDatas.size(), nSegments);
- for (const Data& data : this->m_face->sentDatas) {
+ BOOST_CHECK_EQUAL(this->m_face.sentData.size(), nSegments);
+ for (const Data& data : this->m_face.sentData) {
this->validate(data);
}
}
diff --git a/tests/daemon/mgmt/face-manager-create-face.t.cpp b/tests/daemon/mgmt/face-manager-create-face.t.cpp
index b827c85..fe6d147 100644
--- a/tests/daemon/mgmt/face-manager-create-face.t.cpp
+++ b/tests/daemon/mgmt/face-manager-create-face.t.cpp
@@ -27,6 +27,7 @@
#include "fw/forwarder.hpp"
#include "tests/test-common.hpp"
+#include "tests/identity-management-fixture.hpp"
#include <ndn-cxx/mgmt/dispatcher.hpp>
#include <ndn-cxx/util/dummy-client-face.hpp>
@@ -46,8 +47,8 @@
{
public:
FaceManagerNode(ndn::KeyChain& keyChain, const std::string& port = "6363")
- : face(ndn::util::makeDummyClientFace(getGlobalIoService(), {true, true}))
- , dispatcher(*face, keyChain, ndn::security::SigningInfo())
+ : face(getGlobalIoService(), keyChain, {true, true})
+ , dispatcher(face, keyChain, ndn::security::SigningInfo())
, manager(forwarder.getFaceTable(), dispatcher, validator)
{
dispatcher.addTopPrefix("/localhost/nfd");
@@ -104,18 +105,19 @@
public:
Forwarder forwarder;
- shared_ptr<ndn::util::DummyClientFace> face;
+ ndn::util::DummyClientFace face;
ndn::mgmt::Dispatcher dispatcher;
CommandValidator validator;
FaceManager manager;
};
class FaceManagerFixture : public UnitTestTimeFixture
+ , public IdentityManagementFixture
{
public:
FaceManagerFixture()
- : node1(keyChain, "16363")
- , node2(keyChain, "26363")
+ : node1(m_keyChain, "16363")
+ , node2(m_keyChain, "26363")
{
advanceClocks(time::milliseconds(1), 100);
}
@@ -128,7 +130,6 @@
}
public:
- ndn::KeyChain keyChain;
FaceManagerNode node1; // used to test FaceManager
FaceManagerNode node2; // acts as a remote endpoint
};
@@ -263,10 +264,10 @@
commandName.append(FaceType().getParameters().wireEncode());
shared_ptr<Interest> command(make_shared<Interest>(commandName));
- this->keyChain.sign(*command);
+ m_keyChain.sign(*command);
bool hasCallbackFired = false;
- this->node1.face->onSendData.connect([this, command, &hasCallbackFired] (const Data& response) {
+ this->node1.face.onSendData.connect([this, command, &hasCallbackFired] (const Data& response) {
// std::cout << response << std::endl;
if (!command->getName().isPrefixOf(response.getName())) {
return;
@@ -287,7 +288,7 @@
hasCallbackFired = true;
});
- this->node1.face->receive(*command);
+ this->node1.face.receive(*command);
this->advanceClocks(time::milliseconds(1), 100);
BOOST_CHECK(hasCallbackFired);
@@ -314,9 +315,9 @@
commandName.append(FaceType1().getParameters().wireEncode());
shared_ptr<Interest> command(make_shared<Interest>(commandName));
- this->keyChain.sign(*command);
+ m_keyChain.sign(*command);
- this->node1.face->receive(*command);
+ this->node1.face.receive(*command);
this->advanceClocks(time::milliseconds(1), 10);
}
@@ -329,10 +330,10 @@
commandName.append(FaceType2().getParameters().wireEncode());
shared_ptr<Interest> command(make_shared<Interest>(commandName));
- this->keyChain.sign(*command);
+ m_keyChain.sign(*command);
bool hasCallbackFired = false;
- this->node1.face->onSendData.connect([this, command, &hasCallbackFired] (const Data& response) {
+ this->node1.face.onSendData.connect([this, command, &hasCallbackFired] (const Data& response) {
if (!command->getName().isPrefixOf(response.getName())) {
return;
}
@@ -347,7 +348,7 @@
hasCallbackFired = true;
});
- this->node1.face->receive(*command);
+ this->node1.face.receive(*command);
this->advanceClocks(time::milliseconds(1), 10);
BOOST_CHECK(hasCallbackFired);
@@ -390,10 +391,10 @@
commandName.append(OtherNodeFace().getParameters().wireEncode());
shared_ptr<Interest> command(make_shared<Interest>(commandName));
- this->keyChain.sign(*command);
+ m_keyChain.sign(*command);
ndn::util::signal::ScopedConnection connection =
- this->node2.face->onSendData.connect([this, command] (const Data& response) {
+ this->node2.face.onSendData.connect([this, command] (const Data& response) {
if (!command->getName().isPrefixOf(response.getName())) {
return;
}
@@ -409,7 +410,7 @@
face->sendInterest(*dummyInterest);
});
- this->node2.face->receive(*command);
+ this->node2.face.receive(*command);
this->advanceClocks(time::milliseconds(1), 10);
}
@@ -433,10 +434,10 @@
commandName.append(FaceType().getParameters().wireEncode());
shared_ptr<Interest> command(make_shared<Interest>(commandName));
- this->keyChain.sign(*command);
+ m_keyChain.sign(*command);
bool hasCallbackFired = false;
- this->node1.face->onSendData.connect([this, command, &hasCallbackFired] (const Data& response) {
+ this->node1.face.onSendData.connect([this, command, &hasCallbackFired] (const Data& response) {
if (!command->getName().isPrefixOf(response.getName())) {
return;
}
@@ -451,7 +452,7 @@
hasCallbackFired = true;
});
- this->node1.face->receive(*command);
+ this->node1.face.receive(*command);
this->advanceClocks(time::milliseconds(1), 10);
BOOST_CHECK(hasCallbackFired);
diff --git a/tests/manager-common-fixture.cpp b/tests/manager-common-fixture.cpp
index cdf818d..a491296 100644
--- a/tests/manager-common-fixture.cpp
+++ b/tests/manager-common-fixture.cpp
@@ -29,9 +29,9 @@
namespace tests {
ManagerCommonFixture::ManagerCommonFixture()
- : m_face(ndn::util::makeDummyClientFace(UnitTestTimeFixture::g_io, {true, true}))
- , m_dispatcher(*m_face, m_keyChain, ndn::security::SigningInfo())
- , m_responses(m_face->sentDatas)
+ : m_face(getGlobalIoService(), m_keyChain, {true, true})
+ , m_dispatcher(m_face, m_keyChain, ndn::security::SigningInfo())
+ , m_responses(m_face.sentData)
, m_identityName("/unit-test/ManagerCommonFixture/identity")
, m_certificate(m_keyChain.getCertificate(m_keyChain.createIdentity(m_identityName)))
{
@@ -63,7 +63,7 @@
void
ManagerCommonFixture::receiveInterest(shared_ptr<Interest> interest)
{
- m_face->receive<Interest>(*interest);
+ m_face.receive(*interest);
advanceClocks(time::milliseconds(1));
}
diff --git a/tests/manager-common-fixture.hpp b/tests/manager-common-fixture.hpp
index aaa06f8..a29c441 100644
--- a/tests/manager-common-fixture.hpp
+++ b/tests/manager-common-fixture.hpp
@@ -143,11 +143,11 @@
concatenateResponses(size_t startIndex = 0, size_t nResponses = 0);
protected:
- shared_ptr<ndn::util::DummyClientFace> m_face;
- ndn::mgmt::Dispatcher m_dispatcher;
- std::vector<Data>& m_responses; // a reference of m_face->sentDatas
- Name m_identityName; // the identity used to sign request
- shared_ptr<ndn::IdentityCertificate> m_certificate; // the certificate used to sign request
+ ndn::util::DummyClientFace m_face;
+ ndn::mgmt::Dispatcher m_dispatcher;
+ std::vector<Data>& m_responses; ///< a reference of m_face->sentData
+ Name m_identityName; ///< the identity used to sign request
+ shared_ptr<ndn::IdentityCertificate> m_certificate; ///< the certificate used to sign request
};
std::ostream&
diff --git a/tests/rib/auto-prefix-propagator.t.cpp b/tests/rib/auto-prefix-propagator.t.cpp
index 2429179..7db7510 100644
--- a/tests/rib/auto-prefix-propagator.t.cpp
+++ b/tests/rib/auto-prefix-propagator.t.cpp
@@ -33,20 +33,22 @@
namespace rib {
namespace tests {
+using namespace nfd::tests;
+
NFD_LOG_INIT("AutoPrefixPropagatorTest");
const Name TEST_LINK_LOCAL_NFD_PREFIX("/localhop/nfd");
const time::milliseconds TEST_PREFIX_PROPAGATION_TIMEOUT(1000);
-class AutoPrefixPropagatorFixture : public nfd::tests::IdentityManagementFixture
- , public nfd::tests::UnitTestTimeFixture
+class AutoPrefixPropagatorFixture : public IdentityManagementFixture
+ , public UnitTestTimeFixture
{
public:
AutoPrefixPropagatorFixture()
- : m_face(ndn::util::makeDummyClientFace(nfd::tests::UnitTestTimeFixture::g_io, {true, true}))
- , m_controller(*m_face, m_keyChain)
+ : m_face(getGlobalIoService(), m_keyChain, {true, true})
+ , m_controller(m_face, m_keyChain)
, m_propagator(m_controller, m_keyChain, m_rib)
- , m_requests(m_face->sentInterests)
+ , m_requests(m_face.sentInterests)
, m_entries(m_propagator.m_propagatedEntries)
{
m_propagator.enable();
@@ -173,12 +175,12 @@
}
protected:
- shared_ptr<ndn::util::DummyClientFace> m_face;
- ndn::nfd::Controller m_controller;
- Rib m_rib;
- AutoPrefixPropagator m_propagator;
- std::vector<Interest>& m_requests; // store sent out requests
- AutoPrefixPropagator::PropagatedEntryList& m_entries; // store propagated entries
+ ndn::util::DummyClientFace m_face;
+ ndn::nfd::Controller m_controller;
+ Rib m_rib;
+ AutoPrefixPropagator m_propagator;
+ std::vector<Interest>& m_requests; ///< store sent out requests
+ AutoPrefixPropagator::PropagatedEntryList& m_entries; ///< store propagated entries
};
std::ostream&
diff --git a/tests/rib/fib-updates-common.hpp b/tests/rib/fib-updates-common.hpp
index 34ae41d..1f293c6 100644
--- a/tests/rib/fib-updates-common.hpp
+++ b/tests/rib/fib-updates-common.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2015, Regents of the University of California,
+ * Copyright (c) 2014-2016, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -23,8 +23,9 @@
* NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "rib-test-common.hpp"
#include "rib/fib-updater.hpp"
+#include "rib-test-common.hpp"
+#include "tests/identity-management-fixture.hpp"
#include <ndn-cxx/util/dummy-client-face.hpp>
@@ -32,6 +33,8 @@
namespace rib {
namespace tests {
+using namespace nfd::tests;
+
inline bool
compareNameFaceIdCostAction(const FibUpdate& lhs, const FibUpdate& rhs)
{
@@ -55,12 +58,12 @@
return false;
}
-class FibUpdatesFixture : public nfd::tests::BaseFixture
+class FibUpdatesFixture : public IdentityManagementFixture
{
public:
FibUpdatesFixture()
- : face(ndn::util::makeDummyClientFace())
- , controller(*face, keyChain)
+ : face(getGlobalIoService(), m_keyChain)
+ , controller(face, m_keyChain)
, fibUpdater(rib, controller)
{
}
@@ -163,8 +166,7 @@
}
public:
- shared_ptr<ndn::util::DummyClientFace> face;
- ndn::KeyChain keyChain;
+ ndn::util::DummyClientFace face;
ndn::nfd::Controller controller;
rib::FibUpdater fibUpdater;
rib::Rib rib;
diff --git a/tests/rib/rib-manager.t.cpp b/tests/rib/rib-manager.t.cpp
index 610c61d..30d1e1e 100644
--- a/tests/rib/rib-manager.t.cpp
+++ b/tests/rib/rib-manager.t.cpp
@@ -49,9 +49,9 @@
explicit
RibManagerFixture(const ConfigurationStatus& status,
bool shouldClearRib)
- : m_commands(m_face->sentInterests)
+ : m_commands(m_face.sentInterests)
, m_status(status)
- , m_manager(m_dispatcher, *m_face, m_keyChain)
+ , m_manager(m_dispatcher, m_face, m_keyChain)
, m_rib(m_manager.m_rib)
{
m_rib.m_onSendBatchFromQueue = bind(&RibManagerFixture::onSendBatchFromQueue, this, _1);
@@ -112,7 +112,7 @@
m_keyChain.sign(*data, ndn::security::SigningInfo(ndn::security::SigningInfo::SIGNER_TYPE_SHA256));
- m_face->getIoService().post([this, data] { m_face->receive(*data); });
+ m_face.getIoService().post([this, data] { m_face.receive(*data); });
};
Name commandPrefix("/localhost/nfd/fib/add-nexthop");
diff --git a/tests/rib/rib-status-publisher-common.hpp b/tests/rib/rib-status-publisher-common.hpp
index eee9a5e..3fc7fad 100644
--- a/tests/rib/rib-status-publisher-common.hpp
+++ b/tests/rib/rib-status-publisher-common.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2015, Regents of the University of California,
+ * Copyright (c) 2014-2016, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -27,9 +27,10 @@
#define RIB_TESTS_UNIT_TESTS_RIB_STATUS_PUBLISHER_COMMON_HPP
#include "rib/rib-status-publisher.hpp"
+#include "rib/rib.hpp"
#include "tests/test-common.hpp"
-#include "rib/rib.hpp"
+#include "tests/identity-management-fixture.hpp"
#include <ndn-cxx/management/nfd-control-parameters.hpp>
#include <ndn-cxx/management/nfd-rib-entry.hpp>
@@ -40,9 +41,11 @@
namespace rib {
namespace tests {
+using namespace nfd::tests;
+
using ndn::nfd::ControlParameters;
-class RibStatusPublisherFixture : public nfd::tests::BaseFixture
+class RibStatusPublisherFixture : public IdentityManagementFixture
{
public:
static void
diff --git a/tests/rib/rib-status-publisher.t.cpp b/tests/rib/rib-status-publisher.t.cpp
index 55ba64f..9600d10 100644
--- a/tests/rib/rib-status-publisher.t.cpp
+++ b/tests/rib/rib-status-publisher.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2015, Regents of the University of California,
+ * Copyright (c) 2014-2016, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -47,15 +47,14 @@
route.flags = ndn::nfd::ROUTE_FLAG_CAPTURE;
rib.insert(name, route);
- ndn::KeyChain keyChain;
- shared_ptr<ndn::util::DummyClientFace> face = ndn::util::makeDummyClientFace();
- RibStatusPublisher publisher(rib, *face, "/localhost/nfd/rib/list", keyChain);
+ ndn::util::DummyClientFace face(getGlobalIoService(), m_keyChain);
+ RibStatusPublisher publisher(rib, face, "/localhost/nfd/rib/list", m_keyChain);
publisher.publish();
- face->processEvents(time::milliseconds(1));
+ face.processEvents(time::milliseconds(1));
- BOOST_REQUIRE_EQUAL(face->sentDatas.size(), 1);
- decodeRibEntryBlock(face->sentDatas[0], name, route);
+ BOOST_REQUIRE_EQUAL(face.sentData.size(), 1);
+ decodeRibEntryBlock(face.sentData[0], name, route);
}