tests: Replace usage of deprecated elements of ndn::util::DummyClientFace
Change-Id: I4aea29af101df1f9f63b16d1c49142deb89f182a
Refs: #3146
diff --git a/tests/unit-tests/util/notification-stream.t.cpp b/tests/unit-tests/util/notification-stream.t.cpp
index fb91f5e..0b15e61 100644
--- a/tests/unit-tests/util/notification-stream.t.cpp
+++ b/tests/unit-tests/util/notification-stream.t.cpp
@@ -60,9 +60,9 @@
BOOST_AUTO_TEST_CASE(Post)
{
- shared_ptr<DummyClientFace> face = makeDummyClientFace(io);
+ DummyClientFace face(io);
ndn::KeyChain keyChain;
- util::NotificationStream<SimpleNotification> notificationStream(*face,
+ util::NotificationStream<SimpleNotification> notificationStream(face,
"/localhost/nfd/NotificationStreamTest", keyChain);
SimpleNotification event1("msg1");
@@ -70,11 +70,11 @@
advanceClocks(time::milliseconds(1));
- BOOST_REQUIRE_EQUAL(face->sentDatas.size(), 1);
- BOOST_CHECK_EQUAL(face->sentDatas[0].getName(),
+ BOOST_REQUIRE_EQUAL(face.sentData.size(), 1);
+ BOOST_CHECK_EQUAL(face.sentData[0].getName(),
"/localhost/nfd/NotificationStreamTest/%FE%00");
SimpleNotification decoded1;
- BOOST_CHECK_NO_THROW(decoded1.wireDecode(face->sentDatas[0].getContent().blockFromValue()));
+ BOOST_CHECK_NO_THROW(decoded1.wireDecode(face.sentData[0].getContent().blockFromValue()));
BOOST_CHECK_EQUAL(decoded1.getMessage(), "msg1");
SimpleNotification event2("msg2");
@@ -82,11 +82,11 @@
advanceClocks(time::milliseconds(1));
- BOOST_REQUIRE_EQUAL(face->sentDatas.size(), 2);
- BOOST_CHECK_EQUAL(face->sentDatas[1].getName(),
+ BOOST_REQUIRE_EQUAL(face.sentData.size(), 2);
+ BOOST_CHECK_EQUAL(face.sentData[1].getName(),
"/localhost/nfd/NotificationStreamTest/%FE%01");
SimpleNotification decoded2;
- BOOST_CHECK_NO_THROW(decoded2.wireDecode(face->sentDatas[1].getContent().blockFromValue()));
+ BOOST_CHECK_NO_THROW(decoded2.wireDecode(face.sentData[1].getContent().blockFromValue()));
BOOST_CHECK_EQUAL(decoded2.getMessage(), "msg2");
}
diff --git a/tests/unit-tests/util/notification-subscriber.t.cpp b/tests/unit-tests/util/notification-subscriber.t.cpp
index 4fa222b..8dc1e60 100644
--- a/tests/unit-tests/util/notification-subscriber.t.cpp
+++ b/tests/unit-tests/util/notification-subscriber.t.cpp
@@ -44,10 +44,10 @@
public:
EndToEndFixture()
: streamPrefix("ndn:/NotificationSubscriberTest")
- , publisherFace(makeDummyClientFace(io))
- , notificationStream(*publisherFace, streamPrefix, publisherKeyChain)
- , subscriberFace(makeDummyClientFace(io))
- , subscriber(*subscriberFace, streamPrefix, time::seconds(1))
+ , publisherFace(io)
+ , notificationStream(publisherFace, streamPrefix, publisherKeyChain)
+ , subscriberFace(io)
+ , subscriber(subscriberFace, streamPrefix, time::seconds(1))
{
}
@@ -56,18 +56,18 @@
void
deliverNotification(const std::string& msg)
{
- publisherFace->sentDatas.clear();
+ publisherFace.sentData.clear();
SimpleNotification notification(msg);
notificationStream.postNotification(notification);
advanceClocks(time::milliseconds(1));
- BOOST_REQUIRE_EQUAL(publisherFace->sentDatas.size(), 1);
+ BOOST_REQUIRE_EQUAL(publisherFace.sentData.size(), 1);
- lastDeliveredSeqNo = publisherFace->sentDatas[0].getName().at(-1).toSequenceNumber();
+ lastDeliveredSeqNo = publisherFace.sentData[0].getName().at(-1).toSequenceNumber();
lastNotification.setMessage("");
- subscriberFace->receive(publisherFace->sentDatas[0]);
+ subscriberFace.receive(publisherFace.sentData[0]);
}
void
@@ -93,10 +93,10 @@
bool
hasInitialRequest() const
{
- if (subscriberFace->sentInterests.empty())
+ if (subscriberFace.sentInterests.empty())
return 0;
- const Interest& interest = subscriberFace->sentInterests[0];
+ const Interest& interest = subscriberFace.sentInterests[0];
return interest.getName() == streamPrefix &&
interest.getChildSelector() == 1 &&
interest.getMustBeFresh() &&
@@ -109,10 +109,10 @@
uint64_t
getRequestSeqNo() const
{
- if (subscriberFace->sentInterests.size() != 1)
+ if (subscriberFace.sentInterests.size() != 1)
return 0;
- const Interest& interest = subscriberFace->sentInterests[0];
+ const Interest& interest = subscriberFace.sentInterests[0];
const Name& name = interest.getName();
if (streamPrefix.isPrefixOf(name) &&
name.size() == streamPrefix.size() + 1 &&
@@ -124,10 +124,10 @@
protected:
Name streamPrefix;
- shared_ptr<DummyClientFace> publisherFace;
+ DummyClientFace publisherFace;
ndn::KeyChain publisherKeyChain;
util::NotificationStream<SimpleNotification> notificationStream;
- shared_ptr<DummyClientFace> subscriberFace;
+ DummyClientFace subscriberFace;
util::NotificationSubscriber<SimpleNotification> subscriber;
util::signal::Connection notificationConn;
@@ -155,30 +155,30 @@
this->deliverNotification("n1");
advanceClocks(time::milliseconds(1));
BOOST_CHECK(lastNotification.getMessage().empty());
- BOOST_CHECK_EQUAL(subscriberFace->sentInterests.size(), 0);
+ BOOST_CHECK_EQUAL(subscriberFace.sentInterests.size(), 0);
- subscriberFace->sentInterests.clear();
+ subscriberFace.sentInterests.clear();
subscriber.start();
advanceClocks(time::milliseconds(1));
BOOST_REQUIRE_EQUAL(subscriber.isRunning(), true);
BOOST_CHECK(this->hasInitialRequest());
// respond to initial request
- subscriberFace->sentInterests.clear();
+ subscriberFace.sentInterests.clear();
this->deliverNotification("n2");
advanceClocks(time::milliseconds(1));
BOOST_CHECK_EQUAL(lastNotification.getMessage(), "n2");
BOOST_CHECK_EQUAL(this->getRequestSeqNo(), lastDeliveredSeqNo + 1);
// respond to continuation request
- subscriberFace->sentInterests.clear();
+ subscriberFace.sentInterests.clear();
this->deliverNotification("n3");
advanceClocks(time::milliseconds(1));
BOOST_CHECK_EQUAL(lastNotification.getMessage(), "n3");
BOOST_CHECK_EQUAL(this->getRequestSeqNo(), lastDeliveredSeqNo + 1);
// timeout
- subscriberFace->sentInterests.clear();
+ subscriberFace.sentInterests.clear();
lastNotification.setMessage("");
advanceClocks(subscriber.getInterestLifetime(), 2);
BOOST_CHECK(lastNotification.getMessage().empty());
@@ -190,8 +190,8 @@
wrongName.append("%07%07");
Data wrongData(wrongName);
publisherKeyChain.sign(wrongData);
- subscriberFace->receive(wrongData);
- subscriberFace->sentInterests.clear();
+ subscriberFace.receive(wrongData);
+ subscriberFace.sentInterests.clear();
lastNotification.setMessage("");
advanceClocks(time::milliseconds(1));
BOOST_CHECK(lastNotification.getMessage().empty());
@@ -199,7 +199,7 @@
BOOST_CHECK(this->hasInitialRequest());
// decode error in payload
- subscriberFace->sentInterests.clear();
+ subscriberFace.sentInterests.clear();
lastNotification.setMessage("");
this->deliverNotification("\x07n4");
advanceClocks(time::milliseconds(1));
@@ -208,10 +208,10 @@
// stop if handlers are cleared
notificationConn.disconnect();
- subscriberFace->sentInterests.clear();
+ subscriberFace.sentInterests.clear();
this->deliverNotification("n5");
advanceClocks(time::milliseconds(1));
- BOOST_CHECK_EQUAL(subscriberFace->sentInterests.size(), 0);
+ BOOST_CHECK_EQUAL(subscriberFace.sentInterests.size(), 0);
}
BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/unit-tests/util/segment-fetcher.t.cpp b/tests/unit-tests/util/segment-fetcher.t.cpp
index e53cc0f..4cccc80 100644
--- a/tests/unit-tests/util/segment-fetcher.t.cpp
+++ b/tests/unit-tests/util/segment-fetcher.t.cpp
@@ -66,7 +66,7 @@
{
public:
Fixture()
- : face(makeDummyClientFace(io))
+ : face(io)
, nErrors(0)
, nDatas(0)
, dataSize(0)
@@ -107,14 +107,14 @@
void
nackLastInterest(lp::NackReason nackReason)
{
- const Interest& lastInterest = face->sentInterests.back();
+ const Interest& lastInterest = face.sentInterests.back();
lp::Nack nack = makeNack(lastInterest, nackReason);
- face->receive(nack);
+ face.receive(nack);
advanceClocks(time::milliseconds(1), 10);
}
public:
- shared_ptr<DummyClientFace> face;
+ DummyClientFace face;
KeyChain keyChain;
uint32_t nErrors;
@@ -127,7 +127,7 @@
BOOST_FIXTURE_TEST_CASE(Timeout, Fixture)
{
ValidatorNull nullValidator;
- SegmentFetcher::fetch(*face, Interest("/hello/world", time::milliseconds(100)),
+ SegmentFetcher::fetch(face, Interest("/hello/world", time::milliseconds(100)),
nullValidator,
bind(&Fixture::onComplete, this, _1),
bind(&Fixture::onError, this, _1));
@@ -136,10 +136,10 @@
BOOST_CHECK_EQUAL(nErrors, 0);
BOOST_CHECK_EQUAL(nDatas, 0);
- BOOST_REQUIRE_EQUAL(face->sentInterests.size(), 1);
- BOOST_CHECK_EQUAL(face->sentDatas.size(), 0);
+ BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
+ BOOST_CHECK_EQUAL(face.sentData.size(), 0);
- const Interest& interest = face->sentInterests[0];
+ const Interest& interest = face.sentInterests[0];
BOOST_CHECK_EQUAL(interest.getName(), "/hello/world");
BOOST_CHECK_EQUAL(interest.getMustBeFresh(), true);
BOOST_CHECK_EQUAL(interest.getChildSelector(), 1);
@@ -148,22 +148,22 @@
BOOST_CHECK_EQUAL(nErrors, 1);
BOOST_CHECK_EQUAL(lastError, static_cast<uint32_t>(SegmentFetcher::INTEREST_TIMEOUT));
- BOOST_REQUIRE_EQUAL(face->sentInterests.size(), 1);
- BOOST_CHECK_EQUAL(face->sentDatas.size(), 0);
+ BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
+ BOOST_CHECK_EQUAL(face.sentData.size(), 0);
}
BOOST_FIXTURE_TEST_CASE(Basic, Fixture)
{
ValidatorNull nullValidator;
- SegmentFetcher::fetch(*face, Interest("/hello/world", time::seconds(1000)),
+ SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
nullValidator,
bind(&Fixture::onComplete, this, _1),
bind(&Fixture::onError, this, _1));
advanceClocks(time::milliseconds(1), 10);
- face->receive(*makeDataSegment("/hello/world/version0", 0, true));
+ face.receive(*makeDataSegment("/hello/world/version0", 0, true));
advanceClocks(time::milliseconds(1), 10);
BOOST_CHECK_EQUAL(nErrors, 0);
@@ -176,10 +176,10 @@
BOOST_CHECK_EQUAL(dataString, bufferString);
- BOOST_REQUIRE_EQUAL(face->sentInterests.size(), 1);
- BOOST_CHECK_EQUAL(face->sentDatas.size(), 0);
+ BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
+ BOOST_CHECK_EQUAL(face.sentData.size(), 0);
- const Interest& interest = face->sentInterests[0];
+ const Interest& interest = face.sentInterests[0];
BOOST_CHECK_EQUAL(interest.getName(), "/hello/world");
BOOST_CHECK_EQUAL(interest.getMustBeFresh(), true);
BOOST_CHECK_EQUAL(interest.getChildSelector(), 1);
@@ -188,7 +188,7 @@
BOOST_FIXTURE_TEST_CASE(NoSegmentInData, Fixture)
{
ValidatorNull nullValidator;
- SegmentFetcher::fetch(*face, Interest("/hello/world", time::seconds(1000)),
+ SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
nullValidator,
bind(&Fixture::onComplete, this, _1),
bind(&Fixture::onError, this, _1));
@@ -201,7 +201,7 @@
data->setContent(buffer, sizeof(buffer));
- face->receive(*data);
+ face.receive(*data);
advanceClocks(time::milliseconds(1), 10);
BOOST_CHECK_EQUAL(nErrors, 1);
@@ -212,13 +212,13 @@
BOOST_FIXTURE_TEST_CASE(SegmentValidationFailure, Fixture)
{
ValidatorFailed failedValidator;
- SegmentFetcher::fetch(*face, Interest("/hello/world", time::seconds(1000)),
+ SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
failedValidator,
bind(&Fixture::onComplete, this, _1),
bind(&Fixture::onError, this, _1));
advanceClocks(time::milliseconds(1), 10);
- face->receive(*makeDataSegment("/hello/world/version0", 0, true));
+ face.receive(*makeDataSegment("/hello/world/version0", 0, true));
advanceClocks(time::milliseconds(1), 10);
BOOST_CHECK_EQUAL(nErrors, 1);
@@ -229,19 +229,19 @@
BOOST_FIXTURE_TEST_CASE(Triple, Fixture)
{
ValidatorNull nullValidator;
- SegmentFetcher::fetch(*face, Interest("/hello/world", time::seconds(1000)),
+ SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
nullValidator,
bind(&Fixture::onComplete, this, _1),
bind(&Fixture::onError, this, _1));
advanceClocks(time::milliseconds(1), 10);
- face->receive(*makeDataSegment("/hello/world/version0", 0, false));
+ face.receive(*makeDataSegment("/hello/world/version0", 0, false));
advanceClocks(time::milliseconds(1), 10);
- face->receive(*makeDataSegment("/hello/world/version0", 1, false));
+ face.receive(*makeDataSegment("/hello/world/version0", 1, false));
advanceClocks(time::milliseconds(1), 10);
- face->receive(*makeDataSegment("/hello/world/version0", 2, true));
+ face.receive(*makeDataSegment("/hello/world/version0", 2, true));
advanceClocks(time::milliseconds(1), 10);
@@ -250,25 +250,25 @@
BOOST_CHECK_EQUAL(dataSize, 42);
- BOOST_REQUIRE_EQUAL(face->sentInterests.size(), 3);
- BOOST_CHECK_EQUAL(face->sentDatas.size(), 0);
+ BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 3);
+ BOOST_CHECK_EQUAL(face.sentData.size(), 0);
{
- const Interest& interest = face->sentInterests[0];
+ const Interest& interest = face.sentInterests[0];
BOOST_CHECK_EQUAL(interest.getName(), "/hello/world");
BOOST_CHECK_EQUAL(interest.getMustBeFresh(), true);
BOOST_CHECK_EQUAL(interest.getChildSelector(), 1);
}
{
- const Interest& interest = face->sentInterests[1];
+ const Interest& interest = face.sentInterests[1];
BOOST_CHECK_EQUAL(interest.getName(), "/hello/world/version0/%00%01");
BOOST_CHECK_EQUAL(interest.getMustBeFresh(), false);
BOOST_CHECK_EQUAL(interest.getChildSelector(), 0);
}
{
- const Interest& interest = face->sentInterests[2];
+ const Interest& interest = face.sentInterests[2];
BOOST_CHECK_EQUAL(interest.getName(), "/hello/world/version0/%00%02");
BOOST_CHECK_EQUAL(interest.getMustBeFresh(), false);
BOOST_CHECK_EQUAL(interest.getChildSelector(), 0);
@@ -278,22 +278,22 @@
BOOST_FIXTURE_TEST_CASE(TripleWithInitialSegmentFetching, Fixture)
{
ValidatorNull nullValidator;
- SegmentFetcher::fetch(*face, Interest("/hello/world", time::seconds(1000)),
+ SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
nullValidator,
bind(&Fixture::onComplete, this, _1),
bind(&Fixture::onError, this, _1));
advanceClocks(time::milliseconds(1), 10);
- face->receive(*makeDataSegment("/hello/world/version0", 1, false));
+ face.receive(*makeDataSegment("/hello/world/version0", 1, false));
advanceClocks(time::milliseconds(1), 10);
- face->receive(*makeDataSegment("/hello/world/version0", 0, false));
+ face.receive(*makeDataSegment("/hello/world/version0", 0, false));
advanceClocks(time::milliseconds(1), 10);
- face->receive(*makeDataSegment("/hello/world/version0", 1, false));
+ face.receive(*makeDataSegment("/hello/world/version0", 1, false));
advanceClocks(time::milliseconds(1), 10);
- face->receive(*makeDataSegment("/hello/world/version0", 2, true));
+ face.receive(*makeDataSegment("/hello/world/version0", 2, true));
advanceClocks(time::milliseconds(1), 10);
@@ -302,32 +302,32 @@
BOOST_CHECK_EQUAL(dataSize, 42);
- BOOST_REQUIRE_EQUAL(face->sentInterests.size(), 4);
- BOOST_CHECK_EQUAL(face->sentDatas.size(), 0);
+ BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 4);
+ BOOST_CHECK_EQUAL(face.sentData.size(), 0);
{
- const Interest& interest = face->sentInterests[0];
+ const Interest& interest = face.sentInterests[0];
BOOST_CHECK_EQUAL(interest.getName(), "/hello/world");
BOOST_CHECK_EQUAL(interest.getMustBeFresh(), true);
BOOST_CHECK_EQUAL(interest.getChildSelector(), 1);
}
{
- const Interest& interest = face->sentInterests[1];
+ const Interest& interest = face.sentInterests[1];
BOOST_CHECK_EQUAL(interest.getName(), "/hello/world/version0/%00%00");
BOOST_CHECK_EQUAL(interest.getMustBeFresh(), false);
BOOST_CHECK_EQUAL(interest.getChildSelector(), 0);
}
{
- const Interest& interest = face->sentInterests[2];
+ const Interest& interest = face.sentInterests[2];
BOOST_CHECK_EQUAL(interest.getName(), "/hello/world/version0/%00%01");
BOOST_CHECK_EQUAL(interest.getMustBeFresh(), false);
BOOST_CHECK_EQUAL(interest.getChildSelector(), 0);
}
{
- const Interest& interest = face->sentInterests[3];
+ const Interest& interest = face.sentInterests[3];
BOOST_CHECK_EQUAL(interest.getName(), "/hello/world/version0/%00%02");
BOOST_CHECK_EQUAL(interest.getMustBeFresh(), false);
BOOST_CHECK_EQUAL(interest.getChildSelector(), 0);
@@ -337,7 +337,7 @@
BOOST_FIXTURE_TEST_CASE(MultipleSegmentFetching, Fixture)
{
ValidatorNull nullValidator;
- SegmentFetcher::fetch(*face, Interest("/hello/world", time::seconds(1000)),
+ SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
nullValidator,
bind(&Fixture::onComplete, this, _1),
bind(&Fixture::onError, this, _1));
@@ -346,10 +346,10 @@
for (uint64_t i = 0; i < 400; i++) {
advanceClocks(time::milliseconds(1), 10);
- face->receive(*makeDataSegment("/hello/world/version0", i, false));
+ face.receive(*makeDataSegment("/hello/world/version0", i, false));
}
advanceClocks(time::milliseconds(1), 10);
- face->receive(*makeDataSegment("/hello/world/version0", 400, true));
+ face.receive(*makeDataSegment("/hello/world/version0", 400, true));
advanceClocks(time::milliseconds(1), 10);
@@ -359,7 +359,7 @@
BOOST_FIXTURE_TEST_CASE(SegmentFetcherDuplicateNack, Fixture)
{
- SegmentFetcher::fetch(*face, Interest("/hello/world", time::seconds(1000)),
+ SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
make_shared<ValidatorNull>(),
bind(&Fixture::onComplete, this, _1),
bind(&Fixture::onError, this, _1));
@@ -373,13 +373,13 @@
nackLastInterest(lp::NackReason::DUPLICATE);
}
- BOOST_CHECK_EQUAL(face->sentInterests.size(), (SegmentFetcher::MAX_INTEREST_REEXPRESS + 1));
+ BOOST_CHECK_EQUAL(face.sentInterests.size(), (SegmentFetcher::MAX_INTEREST_REEXPRESS + 1));
BOOST_CHECK_EQUAL(lastError, static_cast<uint32_t>(SegmentFetcher::NACK_ERROR));
}
BOOST_FIXTURE_TEST_CASE(SegmentFetcherCongestionNack, Fixture)
{
- SegmentFetcher::fetch(*face, Interest("/hello/world", time::seconds(1000)),
+ SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
make_shared<ValidatorNull>(),
bind(&Fixture::onComplete, this, _1),
bind(&Fixture::onError, this, _1));
@@ -393,7 +393,7 @@
nackLastInterest(lp::NackReason::CONGESTION);
}
- BOOST_CHECK_EQUAL(face->sentInterests.size(), (SegmentFetcher::MAX_INTEREST_REEXPRESS + 1));
+ BOOST_CHECK_EQUAL(face.sentInterests.size(), (SegmentFetcher::MAX_INTEREST_REEXPRESS + 1));
BOOST_CHECK_EQUAL(lastError, static_cast<uint32_t>(SegmentFetcher::NACK_ERROR));
}