tests: use Signals from DummyClientFace
refs #2319
Change-Id: I688816fc58828a4f2d8fbad4936cc064816ab123
diff --git a/tests/unit/clients/iterative-query-controller.cpp b/tests/unit/clients/iterative-query-controller.cpp
index 7713a5b..116c6a1 100644
--- a/tests/unit/clients/iterative-query-controller.cpp
+++ b/tests/unit/clients/iterative-query-controller.cpp
@@ -44,10 +44,18 @@
, ndnsim(m_ndnsim.getName(), m_certName, *producerFace, m_session, m_keyChain, validator)
{
run();
- producerFace->onInterest += [&] (const Interest& interest) { consumerFace->receive(interest); };
- consumerFace->onInterest += [&] (const Interest& interest) { producerFace->receive(interest); };
- producerFace->onData += [&] (const Data& data) { consumerFace->receive(data); };
- consumerFace->onData += [&] (const Data& data) { producerFace->receive(data); };
+ producerFace->onSendInterest.connect([this] (const Interest& interest) {
+ io.post([=] { consumerFace->receive(interest); });
+ });
+ consumerFace->onSendInterest.connect([this] (const Interest& interest) {
+ io.post([=] { producerFace->receive(interest); });
+ });
+ producerFace->onSendData.connect([this] (const Data& data) {
+ io.post([=] { consumerFace->receive(data); });
+ });
+ consumerFace->onSendData.connect([this] (const Data& data) {
+ io.post([=] { producerFace->receive(data); });
+ });
}
void
diff --git a/tests/unit/daemon/name-server.cpp b/tests/unit/daemon/name-server.cpp
index 09d192f..0e5f302 100644
--- a/tests/unit/daemon/name-server.cpp
+++ b/tests/unit/daemon/name-server.cpp
@@ -74,7 +74,7 @@
bool hasDataBack = false;
- face->onData += [&] (const Data& data) {
+ face->onSendData.connectSingleShot([&] (const Data& data) {
hasDataBack = true;
NDNS_LOG_TRACE("get Data back");
BOOST_CHECK_EQUAL(data.getName().getPrefix(-1), q.toInterest().getName());
@@ -82,7 +82,7 @@
Response resp;
BOOST_CHECK_NO_THROW(resp.fromData(hint, zone, data));
BOOST_CHECK_EQUAL(resp.getNdnsType(), NDNS_RESP);
- };
+ });
face->receive(q.toInterest());
@@ -100,7 +100,7 @@
size_t nDataBack = 0;
// will ask for non-existing record
- face->onData += [&] (const Data& data) {
+ face->onSendData.connectSingleShot([&] (const Data& data) {
++nDataBack;
NDNS_LOG_TRACE("get Data back");
BOOST_CHECK_EQUAL(data.getName().getPrefix(-1), q.toInterest().getName());
@@ -108,14 +108,13 @@
Response resp;
BOOST_CHECK_NO_THROW(resp.fromData(hint, zone, data));
BOOST_CHECK_EQUAL(resp.getNdnsType(), NDNS_NACK);
- };
+ });
face->receive(q.toInterest());
run();
// will ask for the existing record (will have type NDNS_RAW, as it is certificate)
- face->onData.clear();
- face->onData += [&] (const Data& data) {
+ face->onSendData.connectSingleShot([&] (const Data& data) {
++nDataBack;
NDNS_LOG_TRACE("get Data back");
BOOST_CHECK_EQUAL(data.getName().getPrefix(-1), q.toInterest().getName());
@@ -123,7 +122,7 @@
Response resp;
BOOST_CHECK_NO_THROW(resp.fromData(hint, zone, data));
BOOST_CHECK_EQUAL(resp.getNdnsType(), NDNS_RAW);
- };
+ });
q.setRrLabel("dsk-1");
@@ -160,7 +159,7 @@
bool hasDataBack = false;
- face->onData += [&] (const Data& data) {
+ face->onSendData.connectSingleShot([&] (const Data& data) {
hasDataBack = true;
NDNS_LOG_TRACE("get Data back");
BOOST_CHECK_EQUAL(data.getName().getPrefix(-1), q.toInterest().getName());
@@ -177,7 +176,7 @@
BOOST_CHECK_EQUAL(val->type(), ndns::tlv::UpdateReturnCode); // the first must be return code
ret = readNonNegativeInteger(*val);
BOOST_CHECK_EQUAL(ret, 0);
- };
+ });
face->receive(q.toInterest());
run();
@@ -212,7 +211,7 @@
bool hasDataBack = false;
- face->onData += [&] (const Data& data) {
+ face->onSendData.connectSingleShot([&] (const Data& data) {
hasDataBack = true;
NDNS_LOG_TRACE("get Data back");
BOOST_CHECK_EQUAL(data.getName().getPrefix(-1), q.toInterest().getName());
@@ -229,7 +228,7 @@
BOOST_CHECK_EQUAL(val->type(), ndns::tlv::UpdateReturnCode); // the first must be return code
ret = readNonNegativeInteger(*val);
BOOST_CHECK_EQUAL(ret, 0);
- };
+ });
face->receive(q.toInterest());
run();
@@ -289,10 +288,10 @@
bool hasDataBack = false;
// no data back, since the Update cannot pass verification
- face->onData += [&] (const Data& data) {
+ face->onSendData.connectSingleShot([&] (const Data& data) {
hasDataBack = true;
BOOST_FAIL("UNEXPECTED");
- };
+ });
face->receive(q.toInterest());
run();
@@ -312,10 +311,10 @@
{
// ensure prefix is registered
run();
- validatorFace->onInterest += [&] (const Interest& interest) {
+ validatorFace->onSendInterest.connect([&] (const Interest& interest) {
NDNS_LOG_TRACE("validatorFace get Interest: " << interest.getName());
face->receive(interest);
- };
+ });
}
void
@@ -387,7 +386,7 @@
bool hasDataBack = false;
shared_ptr<Regex> regex = make_shared<Regex>("(<>*)<KEY>(<>+)<ID-CERT><>");
- face->onData += [&] (const Data& data) {
+ face->onSendData.connectSingleShot([&] (const Data& data) {
if (regex->match(data.getName())) {
validatorFace->receive(data); // It's data requested by validator
}
@@ -410,7 +409,7 @@
ret = readNonNegativeInteger(*val);
BOOST_CHECK_EQUAL(ret, 0);
}
- };
+ });
face->receive(q.toInterest());
run();
diff --git a/tests/unit/validator.cpp b/tests/unit/validator.cpp
index cda5e06..e51782b 100644
--- a/tests/unit/validator.cpp
+++ b/tests/unit/validator.cpp
@@ -59,7 +59,7 @@
m_keyChain.addCertificate(*cert);
NDNS_LOG_TRACE("add cert: " << cert->getName() << " to KeyChain");
- m_face->onInterest += bind(&Fixture::respondInterest, this, _1);
+ m_face->onSendInterest.connect(bind(&Fixture::respondInterest, this, _1));
}
~Fixture()