tests: Use ndn-cxx/DummyClientFace

refs: #2637

Change-Id: Ife16a81d08e538b4b0a82f1f5d4cc819fc764257
diff --git a/tests/dummy-face.hpp b/tests/dummy-face.hpp
deleted file mode 100644
index 56ef8ca..0000000
--- a/tests/dummy-face.hpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014  University of Memphis,
- *                     Regents of the University of California
- *
- * This file is part of NLSR (Named-data Link State Routing).
- * See AUTHORS.md for complete list of NLSR authors and contributors.
- *
- * NLSR is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE.  See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- *
- **/
-
-#ifndef NLSR_TEST_DUMMY_FACE_HPP
-#define NLSR_TEST_DUMMY_FACE_HPP
-
-#include <ndn-cxx/face.hpp>
-#include <ndn-cxx/transport/transport.hpp>
-
-namespace ndn {
-
-class DummyTransport : public Transport
-{
-public:
-  void
-  receive(const Block& block)
-  {
-    m_receiveCallback(block);
-  }
-
-  virtual void
-  close()
-  {
-  }
-
-  virtual void
-  pause()
-  {
-  }
-
-  virtual void
-  resume()
-  {
-  }
-
-  virtual void
-  send(const Block& wire)
-  {
-    if (wire.type() == tlv::Interest) {
-      m_sentInterests->push_back(Interest(wire));
-    }
-    else if (wire.type() == tlv::Data) {
-      m_sentDatas->push_back(Data(wire));
-    }
-  }
-
-  virtual void
-  send(const Block& header, const Block& payload)
-  {
-    this->send(payload);
-  }
-
-public:
-  std::vector<Interest>* m_sentInterests;
-  std::vector<Data>*     m_sentDatas;
-};
-
-
-/** \brief a Face for unit testing
- */
-class DummyFace : public Face
-{
-public:
-  explicit
-  DummyFace(shared_ptr<DummyTransport> transport)
-    : Face(transport)
-    , m_transport(transport)
-  {
-    m_transport->m_sentInterests = &m_sentInterests;
-    m_transport->m_sentDatas     = &m_sentDatas;
-  }
-
-  /** \brief cause the Face to receive a packet
-   */
-  template<typename Packet>
-  void
-  receive(const Packet& packet)
-  {
-    m_transport->receive(packet.wireEncode());
-  }
-
-public:
-  std::vector<Interest> m_sentInterests;
-  std::vector<Data>     m_sentDatas;
-
-private:
-  shared_ptr<DummyTransport> m_transport;
-};
-
-inline shared_ptr<DummyFace>
-makeDummyFace()
-{
-  return make_shared<DummyFace>(make_shared<DummyTransport>());
-}
-
-} // namespace ndn
-
-#endif // NLSR_TEST_DUMMY_FACE_HPP
diff --git a/tests/publisher/publisher-fixture.hpp b/tests/publisher/publisher-fixture.hpp
index 2edb668..df299e3 100644
--- a/tests/publisher/publisher-fixture.hpp
+++ b/tests/publisher/publisher-fixture.hpp
@@ -33,7 +33,7 @@
 {
 public:
   PublisherFixture()
-    : face(ndn::util::makeDummyClientFace())
+    : face(make_shared<ndn::util::DummyClientFace>())
     , nlsr(g_ioService, g_scheduler, ndn::ref(*face))
     , lsdb(nlsr, g_scheduler, nlsr.getSyncLogicHandler())
   {
diff --git a/tests/publisher/test-segment-publisher.cpp b/tests/publisher/test-segment-publisher.cpp
index 7f34747..035f5e2 100644
--- a/tests/publisher/test-segment-publisher.cpp
+++ b/tests/publisher/test-segment-publisher.cpp
@@ -89,7 +89,7 @@
 {
 public:
   SegmentPublisherFixture()
-    : m_face(ndn::util::makeDummyClientFace())
+    : m_face(std::make_shared<ndn::util::DummyClientFace>())
     , m_expectedFreshnessPeriod(ndn::time::milliseconds(111))
     , m_publisher(*m_face, m_keyChain, m_expectedFreshnessPeriod)
     , m_publishingPrefix("/localhost/nfd/SegmentPublisherFixture")
diff --git a/tests/test-conf-file-processor.cpp b/tests/test-conf-file-processor.cpp
index 01950d2..2c23823 100644
--- a/tests/test-conf-file-processor.cpp
+++ b/tests/test-conf-file-processor.cpp
@@ -20,7 +20,6 @@
  **/
 
 #include "test-common.hpp"
-#include "dummy-face.hpp"
 #include "logger.hpp"
 
 #include <fstream>
@@ -31,10 +30,11 @@
 #include <boost/filesystem.hpp>
 #include <boost/algorithm/string.hpp>
 
+#include <ndn-cxx/util/dummy-client-face.hpp>
+
 namespace nlsr {
 namespace test {
 
-using ndn::DummyFace;
 using ndn::shared_ptr;
 
 const std::string SECTION_GENERAL =
@@ -132,7 +132,7 @@
 {
 public:
   ConfFileProcessorFixture()
-    : face(ndn::makeDummyFace())
+    : face(make_shared<ndn::util::DummyClientFace>())
     , nlsr(g_ioService, g_scheduler, ndn::ref(*face))
     , CONFIG_FILE("unit-test-nlsr.conf")
     , m_logConfigFileName(boost::filesystem::unique_path().native())
@@ -200,7 +200,7 @@
   }
 
 public:
-  shared_ptr<ndn::DummyFace> face;
+  shared_ptr<ndn::util::DummyClientFace> face;
   Nlsr nlsr;
 
 private:
diff --git a/tests/test-fib.cpp b/tests/test-fib.cpp
index acb2c7b..2fe7bb4 100644
--- a/tests/test-fib.cpp
+++ b/tests/test-fib.cpp
@@ -21,25 +21,25 @@
 
 #include "test-common.hpp"
 #include "control-commands.hpp"
-#include "dummy-face.hpp"
 
 #include "route/fib.hpp"
 
 #include "adjacency-list.hpp"
 #include "conf-parameter.hpp"
 
+#include <ndn-cxx/util/dummy-client-face.hpp>
+
 namespace nlsr {
 namespace test {
 
-using ndn::DummyFace;
 using ndn::shared_ptr;
 
 class FibFixture : public BaseFixture
 {
 public:
   FibFixture()
-    : face(ndn::makeDummyFace())
-    , interests(face->m_sentInterests)
+    : face(make_shared<ndn::util::DummyClientFace>())
+    , interests(face->sentInterests)
   {
     INIT_LOGGERS("/tmp", "DEBUG");
 
@@ -63,7 +63,7 @@
   }
 
 public:
-  shared_ptr<ndn::DummyFace> face;
+  shared_ptr<ndn::util::DummyClientFace> face;
   ndn::KeyChain keyChain;
   shared_ptr<Fib> fib;
 
diff --git a/tests/test-hyperbolic-calculator.cpp b/tests/test-hyperbolic-calculator.cpp
index f16fe36..9bf354c 100644
--- a/tests/test-hyperbolic-calculator.cpp
+++ b/tests/test-hyperbolic-calculator.cpp
@@ -20,7 +20,6 @@
  **/
 
 #include "test-common.hpp"
-#include "dummy-face.hpp"
 
 #include "route/routing-table-calculator.hpp"
 
@@ -33,10 +32,11 @@
 
 #include <boost/test/unit_test.hpp>
 
+#include <ndn-cxx/util/dummy-client-face.hpp>
+
 namespace nlsr {
 namespace test {
 
-using ndn::DummyFace;
 using ndn::shared_ptr;
 using ndn::time::system_clock;
 static const system_clock::TimePoint MAX_TIME = system_clock::TimePoint::max();
@@ -45,7 +45,7 @@
 {
 public:
   HyperbolicCalculatorFixture()
-    : face(ndn::makeDummyFace())
+    : face(make_shared<ndn::util::DummyClientFace>())
     , nlsr(g_ioService, g_scheduler, ndn::ref(*face))
     , routingTable(nlsr.getRoutingTable())
     , adjacencies(nlsr.getAdjacencyList())
@@ -105,7 +105,7 @@
   }
 
 public:
-  shared_ptr<DummyFace> face;
+  shared_ptr<ndn::util::DummyClientFace> face;
   Nlsr nlsr;
   Map map;
 
diff --git a/tests/test-link-state-calculator.cpp b/tests/test-link-state-calculator.cpp
index df61cdb..f50001e 100644
--- a/tests/test-link-state-calculator.cpp
+++ b/tests/test-link-state-calculator.cpp
@@ -41,7 +41,7 @@
 {
 public:
   LinkStateCalculatorFixture()
-    : face(ndn::util::makeDummyClientFace(g_ioService))
+    : face(make_shared<ndn::util::DummyClientFace>(g_ioService))
     , nlsr(g_ioService, g_scheduler, ndn::ref(*face))
     , routingTable(nlsr.getRoutingTable())
     , lsdb(nlsr.getLsdb())
diff --git a/tests/test-lsdb.cpp b/tests/test-lsdb.cpp
index 2991967..c44b4a7 100644
--- a/tests/test-lsdb.cpp
+++ b/tests/test-lsdb.cpp
@@ -20,7 +20,6 @@
  **/
 
 #include "test-common.hpp"
-#include "dummy-face.hpp"
 
 #include "lsdb.hpp"
 #include "nlsr.hpp"
@@ -28,17 +27,18 @@
 #include "name-prefix-list.hpp"
 #include <boost/test/unit_test.hpp>
 
+#include <ndn-cxx/util/dummy-client-face.hpp>
+
 namespace nlsr {
 namespace test {
 
-using ndn::DummyFace;
 using ndn::shared_ptr;
 
 class LsdbFixture : public BaseFixture
 {
 public:
   LsdbFixture()
-    : face(ndn::makeDummyFace())
+    : face(make_shared<ndn::util::DummyClientFace>())
     , nlsr(g_ioService, g_scheduler, ndn::ref(*face))
     , sync(*face, nlsr.getLsdb(), nlsr.getConfParameter(), nlsr.getSequencingManager())
     , lsdb(nlsr.getLsdb())
@@ -53,7 +53,7 @@
     nlsr.initialize();
 
     face->processEvents(ndn::time::milliseconds(1));
-    face->m_sentInterests.clear();
+    face->sentInterests.clear();
 
     INIT_LOGGERS("/tmp", "DEBUG");
   }
@@ -89,7 +89,7 @@
   }
 
 public:
-  shared_ptr<DummyFace> face;
+  shared_ptr<ndn::util::DummyClientFace> face;
   Nlsr nlsr;
   SyncLogicHandler sync;
 
@@ -113,7 +113,7 @@
   lsdb.expressInterest(oldInterestName, 0);
   face->processEvents(ndn::time::milliseconds(1));
 
-  std::vector<ndn::Interest>& interests = face->m_sentInterests;
+  std::vector<ndn::Interest>& interests = face->sentInterests;
 
   BOOST_REQUIRE(interests.size() > 0);
   std::vector<ndn::Interest>::iterator it = interests.begin();
diff --git a/tests/test-name-prefix-table.cpp b/tests/test-name-prefix-table.cpp
index c7c64b7..8392102 100644
--- a/tests/test-name-prefix-table.cpp
+++ b/tests/test-name-prefix-table.cpp
@@ -31,7 +31,7 @@
 {
 public:
   NamePrefixTableFixture()
-    : face(ndn::util::makeDummyClientFace(g_ioService))
+    : face(make_shared<ndn::util::DummyClientFace>(g_ioService))
     , nlsr(g_ioService, g_scheduler, ndn::ref(*face))
     , lsdb(nlsr.getLsdb())
     , npt(nlsr.getNamePrefixTable())
diff --git a/tests/test-nlsr.cpp b/tests/test-nlsr.cpp
index 4407a55..c0dfc47 100644
--- a/tests/test-nlsr.cpp
+++ b/tests/test-nlsr.cpp
@@ -21,7 +21,6 @@
 
 #include "test-common.hpp"
 #include "control-commands.hpp"
-#include "dummy-face.hpp"
 
 #include "nlsr.hpp"
 
@@ -31,14 +30,13 @@
 namespace nlsr {
 namespace test {
 
-using ndn::DummyFace;
 using ndn::shared_ptr;
 
 BOOST_FIXTURE_TEST_SUITE(TestNlsr, BaseFixture)
 
 BOOST_AUTO_TEST_CASE(HyperbolicOn_ZeroCostNeighbors)
 {
-  shared_ptr<DummyFace> face = ndn::makeDummyFace();
+  shared_ptr<ndn::util::DummyClientFace> face = make_shared<ndn::util::DummyClientFace>();
   Nlsr nlsr(g_ioService, g_scheduler, ndn::ref(*face));
 
   // Simulate loading configuration file
@@ -65,7 +63,7 @@
 
 BOOST_AUTO_TEST_CASE(HyperbolicOff_LinkStateCost)
 {
-  shared_ptr<DummyFace> face = ndn::makeDummyFace();
+  shared_ptr<ndn::util::DummyClientFace> face = make_shared<ndn::util::DummyClientFace>();
   Nlsr nlsr(g_ioService, g_scheduler, ndn::ref(*face));
 
   // Simulate loading configuration file
@@ -90,7 +88,7 @@
 
 BOOST_AUTO_TEST_CASE(SetEventIntervals)
 {
-  shared_ptr<DummyFace> face = ndn::makeDummyFace();
+  shared_ptr<ndn::util::DummyClientFace> face = make_shared<ndn::util::DummyClientFace>();
   Nlsr nlsr(g_ioService, g_scheduler, ndn::ref(*face));
 
   // Simulate loading configuration file
@@ -111,7 +109,7 @@
 
 BOOST_FIXTURE_TEST_CASE(FaceDestroyEvent, UnitTestTimeFixture)
 {
-  shared_ptr<ndn::util::DummyClientFace> face = ndn::util::makeDummyClientFace(g_ioService);
+  shared_ptr<ndn::util::DummyClientFace> face = make_shared<ndn::util::DummyClientFace>(g_ioService);
   Nlsr nlsr(g_ioService, g_scheduler, ndn::ref(*face));
   Lsdb& lsdb = nlsr.getLsdb();
 
@@ -224,7 +222,7 @@
 // refresh will not cause RIB entries for other nodes' name prefixes to be refreshed.
 BOOST_FIXTURE_TEST_CASE(FaceDestroyEventInactive, UnitTestTimeFixture)
 {
-  shared_ptr<ndn::util::DummyClientFace> face = ndn::util::makeDummyClientFace(g_ioService);
+  shared_ptr<ndn::util::DummyClientFace> face = make_shared<ndn::util::DummyClientFace>(g_ioService);
   Nlsr nlsr(g_ioService, g_scheduler, ndn::ref(*face));
   Lsdb& lsdb = nlsr.getLsdb();
 
@@ -329,7 +327,7 @@
 
 BOOST_FIXTURE_TEST_CASE(GetCertificate, UnitTestTimeFixture)
 {
-  shared_ptr<ndn::util::DummyClientFace> face = ndn::util::makeDummyClientFace(g_ioService);
+  shared_ptr<ndn::util::DummyClientFace> face = make_shared<ndn::util::DummyClientFace>(g_ioService);
   Nlsr nlsr(g_ioService, g_scheduler, ndn::ref(*face));
 
   // Create certificate
diff --git a/tests/test-sync-logic-handler.cpp b/tests/test-sync-logic-handler.cpp
index 2595e41..56a990f 100644
--- a/tests/test-sync-logic-handler.cpp
+++ b/tests/test-sync-logic-handler.cpp
@@ -20,22 +20,22 @@
  **/
 
 #include "test-common.hpp"
-#include "dummy-face.hpp"
 
 #include "nlsr.hpp"
 #include "communication/sync-logic-handler.hpp"
 
+#include <ndn-cxx/util/dummy-client-face.hpp>
+
 namespace nlsr {
 namespace test {
 
-using ndn::DummyFace;
 using ndn::shared_ptr;
 
 class SyncLogicFixture : public BaseFixture
 {
 public:
   SyncLogicFixture()
-    : face(ndn::makeDummyFace())
+    : face(make_shared<ndn::util::DummyClientFace>())
     , nlsr(g_ioService, g_scheduler, ndn::ref(*face))
     , sync(nlsr.getSyncLogicHandler())
     , CONFIG_NETWORK("/ndn")
@@ -57,7 +57,7 @@
     updates.push_back(info);
 
     face->processEvents(ndn::time::milliseconds(1));
-    face->m_sentInterests.clear();
+    face->sentInterests.clear();
 
     sync.onNsyncUpdate(updates, NULL);
 
@@ -65,7 +65,7 @@
   }
 
 public:
-  shared_ptr<DummyFace> face;
+  shared_ptr<ndn::util::DummyClientFace> face;
   Nlsr nlsr;
   SyncLogicHandler& sync;
 
@@ -83,7 +83,7 @@
 
   receiveUpdate(updateName, 1);
 
-  std::vector<ndn::Interest>& interests = face->m_sentInterests;
+  std::vector<ndn::Interest>& interests = face->sentInterests;
   BOOST_REQUIRE_EQUAL(interests.size(), 3);
 
   std::vector<ndn::Interest>::iterator it = interests.begin();
@@ -103,7 +103,7 @@
 
   receiveUpdate(updateName, 1);
 
-  std::vector<ndn::Interest>& interests = face->m_sentInterests;
+  std::vector<ndn::Interest>& interests = face->sentInterests;
   BOOST_CHECK_EQUAL(interests.size(), 0);
 }
 
@@ -112,7 +112,7 @@
   std::string updateName = CONFIG_SITE + nlsr.getConfParameter().getLsaPrefix().toUri() +
                            CONFIG_ROUTER_NAME;
 
-  std::vector<ndn::Interest>& interests = face->m_sentInterests;
+  std::vector<ndn::Interest>& interests = face->sentInterests;
   BOOST_CHECK_EQUAL(interests.size(), 0);
 }
 
@@ -145,21 +145,21 @@
   uint64_t lowerSeqNo = static_cast<uint64_t>(998) << 40;
   receiveUpdate(updateName, lowerSeqNo);
 
-  std::vector<ndn::Interest>& interests = face->m_sentInterests;
+  std::vector<ndn::Interest>& interests = face->sentInterests;
   BOOST_REQUIRE_EQUAL(interests.size(), 0);
 
   // Same NameLSA sequence number
   uint64_t sameSeqNo = static_cast<uint64_t>(999) << 40;
   receiveUpdate(updateName, sameSeqNo);
 
-  interests = face->m_sentInterests;
+  interests = face->sentInterests;
   BOOST_REQUIRE_EQUAL(interests.size(), 0);
 
   // Higher NameLSA sequence number
   uint64_t higherSeqNo = static_cast<uint64_t>(1000) << 40;
   receiveUpdate(updateName, higherSeqNo);
 
-  interests = face->m_sentInterests;
+  interests = face->sentInterests;
   BOOST_REQUIRE_EQUAL(interests.size(), 1);
 
   std::vector<ndn::Interest>::iterator it = interests.begin();
diff --git a/tests/update/test-prefix-update-processor.cpp b/tests/update/test-prefix-update-processor.cpp
index 9a12931..f93ee75 100644
--- a/tests/update/test-prefix-update-processor.cpp
+++ b/tests/update/test-prefix-update-processor.cpp
@@ -43,7 +43,7 @@
 {
 public:
   PrefixUpdateFixture()
-    : face(ndn::util::makeDummyClientFace(g_ioService))
+    : face(make_shared<ndn::util::DummyClientFace>(g_ioService))
     , siteIdentity(ndn::Name("/ndn/edu/test-site").appendVersion())
     , opIdentity(ndn::Name(siteIdentity).append(ndn::Name("%C1.Operator")).appendVersion())
     , nlsr(g_ioService, g_scheduler, *face)
diff --git a/tests/utility/test-face-controller.cpp b/tests/utility/test-face-controller.cpp
index 684b97b..4ad1eb4 100644
--- a/tests/utility/test-face-controller.cpp
+++ b/tests/utility/test-face-controller.cpp
@@ -21,12 +21,12 @@
 
 #include "tests/test-common.hpp"
 #include "tests/control-commands.hpp"
-#include "tests/dummy-face.hpp"
 
 #include "utility/face-controller.hpp"
 
 #include <ndn-cxx/security/key-chain.hpp>
 #include <ndn-cxx/management/nfd-controller.hpp>
+#include <ndn-cxx/util/dummy-client-face.hpp>
 
 namespace nlsr {
 namespace test {
@@ -39,8 +39,8 @@
 {
 public:
   FaceControllerFixture()
-    : face(ndn::makeDummyFace())
-    , interests(face->m_sentInterests)
+    : face(make_shared<ndn::util::DummyClientFace>())
+    , interests(face->sentInterests)
     , controller(*face, keyChain)
     , faceController(g_ioService, controller)
   {
@@ -53,7 +53,7 @@
   }
 
 public:
-  shared_ptr<ndn::DummyFace> face;
+  shared_ptr<ndn::util::DummyClientFace> face;
   ndn::KeyChain keyChain;
   std::vector<Interest>& interests;
   ndn::nfd::Controller controller;