util: make DummyClientFace public API

refs #2164

Change-Id: I4a21b70faab1fc1f5cde8430ef602f2425150df9
diff --git a/src/util/dummy-client-face.cpp b/src/util/dummy-client-face.cpp
new file mode 100644
index 0000000..a7ab505
--- /dev/null
+++ b/src/util/dummy-client-face.cpp
@@ -0,0 +1,185 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2014 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library 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 Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#include "dummy-client-face.hpp"
+#include "../transport/transport.hpp"
+#include "../management/nfd-controller.hpp"
+#include "../management/nfd-control-response.hpp"
+
+namespace ndn {
+namespace util {
+
+const DummyClientFace::Options DummyClientFace::DEFAULT_OPTIONS { true, false };
+
+class DummyClientFace::Transport : public ndn::Transport
+{
+public:
+  void
+  receive(const Block& block)
+  {
+    if (static_cast<bool>(m_receiveCallback))
+      m_receiveCallback(block);
+  }
+
+  virtual void
+  close()
+  {
+  }
+
+  virtual void
+  pause()
+  {
+  }
+
+  virtual void
+  resume()
+  {
+  }
+
+  virtual void
+  send(const Block& wire)
+  {
+    if (wire.type() == tlv::Interest) {
+      shared_ptr<Interest> interest = make_shared<Interest>(wire);
+      (*m_onInterest)(*interest);
+    }
+    else if (wire.type() == tlv::Data) {
+      shared_ptr<Data> data = make_shared<Data>(wire);
+      (*m_onData)(*data);
+    }
+  }
+
+  virtual void
+  send(const Block& header, const Block& payload)
+  {
+    this->send(payload);
+  }
+
+  boost::asio::io_service&
+  getIoService()
+  {
+    return *m_ioService;
+  }
+
+private:
+  friend class DummyClientFace;
+  EventEmitter<Interest>* m_onInterest;
+  EventEmitter<Data>* m_onData;
+};
+
+DummyClientFace::DummyClientFace(const Options& options, shared_ptr<Transport> transport)
+  : Face(transport)
+  , m_transport(transport)
+{
+  this->construct(options);
+}
+
+DummyClientFace::DummyClientFace(const Options& options, shared_ptr<Transport> transport,
+                                 boost::asio::io_service& ioService)
+  : Face(transport, ioService)
+  , m_transport(transport)
+{
+  this->construct(options);
+}
+
+void
+DummyClientFace::construct(const Options& options)
+{
+  m_transport->m_onInterest = &onInterest;
+  m_transport->m_onData     = &onData;
+
+  if (options.enablePacketLogging)
+    this->enablePacketLogging();
+
+  if (options.enableRegistrationReply)
+    this->enableRegistrationReply();
+}
+
+void
+DummyClientFace::enablePacketLogging()
+{
+  onInterest += [this] (const Interest& interest) { this->sentInterests.push_back(interest); };
+  onData     += [this] (const Data& data)         { this->sentDatas.push_back(data); };
+}
+
+void
+DummyClientFace::enableRegistrationReply()
+{
+  onInterest += [this] (const Interest& interest) {
+    static const Name localhostRegistration("/localhost/nfd/rib");
+    if (!localhostRegistration.isPrefixOf(interest.getName()))
+      return;
+
+    nfd::ControlParameters params(interest.getName().get(-5).blockFromValue());
+    params.setFaceId(1);
+    params.setOrigin(0);
+    if (interest.getName().get(3) == name::Component("register")) {
+      params.setCost(0);
+    }
+
+    nfd::ControlResponse resp;
+    resp.setCode(200);
+    resp.setBody(params.wireEncode());
+
+    shared_ptr<Data> data = make_shared<Data>(interest.getName());
+    data->setContent(resp.wireEncode());
+
+    KeyChain keyChain;
+    keyChain.signWithSha256(*data);
+
+    this->getIoService().post([this, data] { this->receive(*data); });
+  };
+}
+
+template<typename Packet>
+void
+DummyClientFace::receive(const Packet& packet)
+{
+  m_transport->receive(packet.wireEncode());
+}
+
+template void
+DummyClientFace::receive<Interest>(const Interest& packet);
+
+template void
+DummyClientFace::receive<Data>(const Data& packet);
+
+
+shared_ptr<DummyClientFace>
+makeDummyClientFace(const DummyClientFace::Options& options)
+{
+  // cannot use make_shared<DummyClientFace> before DummyClientFace constructor is private
+  return shared_ptr<DummyClientFace>(
+         new DummyClientFace(options, make_shared<DummyClientFace::Transport>()));
+}
+
+shared_ptr<DummyClientFace>
+makeDummyClientFace(boost::asio::io_service& ioService,
+                    const DummyClientFace::Options& options)
+{
+  // cannot use make_shared<DummyClientFace> before DummyClientFace constructor is private
+  return shared_ptr<DummyClientFace>(
+         new DummyClientFace(options, make_shared<DummyClientFace::Transport>(),
+                             ref(ioService)));
+}
+
+} // namespace util
+} // namespace ndn
diff --git a/src/util/dummy-client-face.hpp b/src/util/dummy-client-face.hpp
new file mode 100644
index 0000000..5ea9fab
--- /dev/null
+++ b/src/util/dummy-client-face.hpp
@@ -0,0 +1,133 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2013-2014 Regents of the University of California.
+ *
+ * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
+ *
+ * ndn-cxx library is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later version.
+ *
+ * ndn-cxx library 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 Lesser General Public License for more details.
+ *
+ * You should have received copies of the GNU General Public License and GNU Lesser
+ * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
+ */
+
+#ifndef NDN_UTIL_DUMMY_CLIENT_FACE_HPP
+#define NDN_UTIL_DUMMY_CLIENT_FACE_HPP
+
+#include "../face.hpp"
+#include "event-emitter.hpp"
+
+namespace ndn {
+namespace util {
+
+/** \brief a client-side face for unit testing
+ */
+class DummyClientFace : public ndn::Face
+{
+public:
+  /** \brief options for DummyClientFace
+   */
+  struct Options
+  {
+    /** \brief if true, packets sent out of DummyClientFace will be appended to a container
+     */
+    bool enablePacketLogging;
+
+    /** \brief if true, prefix registration command will be automatically
+     *         replied with a successful response
+     */
+    bool enableRegistrationReply;
+  };
+
+  /** \brief cause the Face to receive a packet
+   *  \tparam Packet either Interest or Data
+   */
+  template<typename Packet>
+  void
+  receive(const Packet& packet);
+
+private: // constructors
+  class Transport;
+
+  // constructors are private; use makeDummyClientFace to create DummyClientFace
+
+  DummyClientFace(const Options& options, shared_ptr<Transport> transport);
+
+  DummyClientFace(const Options& options, shared_ptr<Transport> transport,
+                  boost::asio::io_service& ioService);
+
+  void
+  construct(const Options& options);
+
+  friend shared_ptr<DummyClientFace>
+  makeDummyClientFace(const DummyClientFace::Options& options);
+
+  friend shared_ptr<DummyClientFace>
+  makeDummyClientFace(boost::asio::io_service& ioService, const DummyClientFace::Options& options);
+
+private:
+  void
+  enablePacketLogging();
+
+  void
+  enableRegistrationReply();
+
+public:
+  /** \brief default options
+   *
+   *  enablePacketLogging=true
+   *  enableRegistrationReply=false
+   */
+  static const Options DEFAULT_OPTIONS;
+
+  /** \brief Interests sent out of this DummyClientFace
+   *
+   *  Sent Interests are appended to this container if options.enablePacketLogger is true.
+   *  User of this class is responsible for cleaning up the container, if necessary.
+   *  After .expressInterest, .processEvents must be called before the Interest would show up here.
+   */
+  std::vector<Interest> sentInterests;
+
+  /** \brief Data sent out of this DummyClientFace
+   *
+   *  Sent Data are appended to this container if options.enablePacketLogger is true.
+   *  User of this class is responsible for cleaning up the container, if necessary.
+   *  After .put, .processEvents must be called before the Data would show up here.
+   */
+  std::vector<Data> sentDatas;
+
+  /** \brief Event to be called whenever an Interest is received
+   *
+   *  After .expressInterest, .processEvents must be called before this event would be triggered.
+   */
+  util::EventEmitter<Interest> onInterest;
+
+  /** \brief Event to be called whenever a Data packet is received
+   *
+   *  After .put, .processEvents must be called before this event would be triggered.
+   */
+  util::EventEmitter<Data> onData;
+
+private:
+  shared_ptr<Transport> m_transport;
+};
+
+shared_ptr<DummyClientFace>
+makeDummyClientFace(const DummyClientFace::Options& options = DummyClientFace::DEFAULT_OPTIONS);
+
+shared_ptr<DummyClientFace>
+makeDummyClientFace(boost::asio::io_service& ioService,
+                    const DummyClientFace::Options& options = DummyClientFace::DEFAULT_OPTIONS);
+
+} // namespace util
+} // namespace ndn
+
+#endif // NDN_UTIL_DUMMY_CLIENT_FACE_HPP
diff --git a/tests/unit-tests/dummy-client-face.hpp b/tests/unit-tests/dummy-client-face.hpp
deleted file mode 100644
index 82d9c7c..0000000
--- a/tests/unit-tests/dummy-client-face.hpp
+++ /dev/null
@@ -1,217 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2014 Regents of the University of California.
- *
- * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
- *
- * ndn-cxx library is free software: you can redistribute it and/or modify it under the
- * terms of the GNU Lesser General Public License as published by the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later version.
- *
- * ndn-cxx library 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 Lesser General Public License for more details.
- *
- * You should have received copies of the GNU General Public License and GNU Lesser
- * General Public License along with ndn-cxx, e.g., in COPYING.md file.  If not, see
- * <http://www.gnu.org/licenses/>.
- *
- * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
- */
-
-#ifndef NDN_TESTS_UNIT_TESTS_DUMMY_CLIENT_FACE_HPP
-#define NDN_TESTS_UNIT_TESTS_DUMMY_CLIENT_FACE_HPP
-
-#include "face.hpp"
-#include "transport/transport.hpp"
-#include "management/nfd-controller.hpp"
-#include "management/nfd-control-response.hpp"
-#include "util/event-emitter.hpp"
-
-namespace ndn {
-namespace tests {
-
-class DummyClientTransport : public ndn::Transport
-{
-public:
-  void
-  receive(const Block& block)
-  {
-    if (static_cast<bool>(m_receiveCallback))
-      m_receiveCallback(block);
-  }
-
-  virtual void
-  close()
-  {
-  }
-
-  virtual void
-  pause()
-  {
-  }
-
-  virtual void
-  resume()
-  {
-  }
-
-  virtual void
-  send(const Block& wire)
-  {
-    if (wire.type() == tlv::Interest) {
-      shared_ptr<Interest> interest = make_shared<Interest>(wire);
-      (*m_onInterest)(*interest, this);
-    }
-    else if (wire.type() == tlv::Data) {
-      shared_ptr<Data> data = make_shared<Data>(wire);
-      (*m_onData)(*data, this);
-    }
-  }
-
-  virtual void
-  send(const Block& header, const Block& payload)
-  {
-    this->send(payload);
-  }
-
-  boost::asio::io_service&
-  getIoService()
-  {
-    return *m_ioService;
-  }
-
-private:
-  friend class DummyClientFace;
-  util::EventEmitter<Interest, DummyClientTransport*>* m_onInterest;
-  util::EventEmitter<Data, DummyClientTransport*>* m_onData;
-};
-
-
-/** \brief Callback to connect
- */
-inline void
-replyNfdRibCommands(const Interest& interest, DummyClientTransport* transport)
-{
-  static const Name localhostRegistration("/localhost/nfd/rib");
-  if (localhostRegistration.isPrefixOf(interest.getName())) {
-    shared_ptr<Data> okResponse = make_shared<Data>(interest.getName());
-    nfd::ControlParameters params(interest.getName().get(-5).blockFromValue());
-    params.setFaceId(1);
-    params.setOrigin(0);
-    if (interest.getName().get(3) == name::Component("register")) {
-      params.setCost(0);
-    }
-    nfd::ControlResponse resp;
-    resp.setCode(200);
-    resp.setBody(params.wireEncode());
-    okResponse->setContent(resp.wireEncode());
-    KeyChain keyChain;
-    keyChain.signWithSha256(*okResponse);
-
-    transport->getIoService().post(bind(&DummyClientTransport::receive, transport,
-                                        okResponse->wireEncode()));
-  }
-}
-
-/** \brief a client-side face for unit testing
- */
-class DummyClientFace : public ndn::Face
-{
-public:
-  explicit
-  DummyClientFace(shared_ptr<DummyClientTransport> transport)
-    : Face(transport)
-    , m_transport(transport)
-  {
-    m_transport->m_onInterest = &onInterest;
-    m_transport->m_onData     = &onData;
-
-    enablePacketLogging();
-  }
-
-  DummyClientFace(shared_ptr<DummyClientTransport> transport, boost::asio::io_service& ioService)
-    : Face(transport, ioService)
-    , m_transport(transport)
-  {
-    m_transport->m_onInterest = &onInterest;
-    m_transport->m_onData     = &onData;
-
-    enablePacketLogging();
-  }
-
-  /** \brief cause the Face to receive a packet
-   */
-  template<typename Packet>
-  void
-  receive(const Packet& packet)
-  {
-    m_transport->receive(packet.wireEncode());
-  }
-
-  void
-  enablePacketLogging()
-  {
-    // @todo Replace with C++11 lambdas
-
-    onInterest += bind(static_cast<void(std::vector<Interest>::*)(const Interest&)>(
-                         &std::vector<Interest>::push_back),
-                       &m_sentInterests, _1);
-
-    onData += bind(static_cast<void(std::vector<Data>::*)(const Data&)>(
-                     &std::vector<Data>::push_back),
-                   &m_sentDatas, _1);
-  }
-
-  void
-  enableRegistrationReply()
-  {
-    onInterest += &replyNfdRibCommands;
-  }
-
-public:
-  /** \brief sent Interests
-   *  \note After .expressInterest, .processEvents must be called before
-   *        the Interest would show up here.
-   */
-  std::vector<Interest> m_sentInterests;
-  /** \brief sent Datas
-   *  \note After .put, .processEvents must be called before
-   *        the Interest would show up here.
-   */
-  std::vector<Data>     m_sentDatas;
-
-public:
-  /** \brief Event to be called whenever an Interest is received
-   *  \note After .expressInterest, .processEvents must be called before
-   *        the Interest would show up here.
-   */
-  util::EventEmitter<Interest, DummyClientTransport*> onInterest;
-
-  /** \brief Event to be called whenever a Data packet is received
-   *  \note After .put, .processEvents must be called before
-   *        the Interest would show up here.
-   */
-  util::EventEmitter<Data, DummyClientTransport*> onData;
-
-private:
-  shared_ptr<DummyClientTransport> m_transport;
-};
-
-inline shared_ptr<DummyClientFace>
-makeDummyClientFace()
-{
-  return make_shared<DummyClientFace>(make_shared<DummyClientTransport>());
-}
-
-inline shared_ptr<DummyClientFace>
-makeDummyClientFace(boost::asio::io_service& ioService)
-{
-  return make_shared<DummyClientFace>(make_shared<DummyClientTransport>(), ref(ioService));
-}
-
-
-} // namespace tests
-} // namespace ndn
-
-#endif // NDN_TESTS_UNIT_TESTS_DUMMY_CLIENT_FACE_HPP
diff --git a/tests/unit-tests/face.cpp b/tests/unit-tests/face.cpp
index dcbff0b..1d45910 100644
--- a/tests/unit-tests/face.cpp
+++ b/tests/unit-tests/face.cpp
@@ -21,13 +21,16 @@
 
 #include "face.hpp"
 #include "security/key-chain.hpp"
-#include "dummy-client-face.hpp"
 
 #include "boost-test.hpp"
+#include "util/dummy-client-face.hpp"
 
 namespace ndn {
 namespace tests {
 
+using ndn::util::DummyClientFace;
+using ndn::util::makeDummyClientFace;
+
 BOOST_AUTO_TEST_SUITE(TestsFace)
 
 class Fixture
@@ -65,8 +68,8 @@
                         bind(&Fixture::onTimeout, this));
   face->processEvents(time::milliseconds(100));
 
-  BOOST_CHECK_EQUAL(face->m_sentInterests.size(), 1);
-  BOOST_CHECK_EQUAL(face->m_sentDatas.size(), 0);
+  BOOST_CHECK_EQUAL(face->sentInterests.size(), 1);
+  BOOST_CHECK_EQUAL(face->sentDatas.size(), 0);
 }
 
 BOOST_FIXTURE_TEST_CASE(RemovePendingInterest, Fixture)
diff --git a/tests/unit-tests/management/test-nfd-controller.cpp b/tests/unit-tests/management/test-nfd-controller.cpp
index 478fdaa..b93149f 100644
--- a/tests/unit-tests/management/test-nfd-controller.cpp
+++ b/tests/unit-tests/management/test-nfd-controller.cpp
@@ -25,13 +25,14 @@
 #include <boost/tuple/tuple.hpp>
 
 #include "boost-test.hpp"
-#include "../dummy-client-face.hpp"
+#include "util/dummy-client-face.hpp"
 
 namespace ndn {
 namespace nfd {
 namespace tests {
 
-using namespace ::ndn::tests;
+using ndn::util::DummyClientFace;
+using ndn::util::makeDummyClientFace;
 
 BOOST_AUTO_TEST_SUITE(ManagementTestNfdController)
 
@@ -84,8 +85,8 @@
                        commandFailCallback));
   face->processEvents(time::milliseconds(1));
 
-  BOOST_REQUIRE_EQUAL(face->m_sentInterests.size(), 1);
-  const Interest& requestInterest = face->m_sentInterests[0];
+  BOOST_REQUIRE_EQUAL(face->sentInterests.size(), 1);
+  const Interest& requestInterest = face->sentInterests[0];
 
   FaceCreateCommand command;
   BOOST_CHECK(Name("/localhost/nfd/faces/create").isPrefixOf(requestInterest.getName()));
@@ -141,8 +142,8 @@
                          commandFailCallback));
   face->processEvents(time::milliseconds(1));
 
-  BOOST_REQUIRE_EQUAL(face->m_sentInterests.size(), 1);
-  const Interest& requestInterest = face->m_sentInterests[0];
+  BOOST_REQUIRE_EQUAL(face->sentInterests.size(), 1);
+  const Interest& requestInterest = face->sentInterests[0];
 
   ControlResponse responsePayload(401, "Not Authenticated");
 
@@ -168,8 +169,8 @@
                          commandFailCallback));
   face->processEvents(time::milliseconds(1));
 
-  BOOST_REQUIRE_EQUAL(face->m_sentInterests.size(), 1);
-  const Interest& requestInterest = face->m_sentInterests[0];
+  BOOST_REQUIRE_EQUAL(face->sentInterests.size(), 1);
+  const Interest& requestInterest = face->sentInterests[0];
 
   ControlParameters responseBody;
   responseBody.setUri("tcp4://192.0.2.1:6363")
@@ -204,8 +205,8 @@
                        options));
   face->processEvents(time::milliseconds(1));
 
-  BOOST_REQUIRE_EQUAL(face->m_sentInterests.size(), 1);
-  const Interest& requestInterest = face->m_sentInterests[0];
+  BOOST_REQUIRE_EQUAL(face->sentInterests.size(), 1);
+  const Interest& requestInterest = face->sentInterests[0];
 
   FaceCreateCommand command;
   BOOST_CHECK(Name("/localhop/net/example/router1/nfd/rib/register").isPrefixOf(
diff --git a/tests/unit-tests/test-faces.cpp b/tests/unit-tests/test-faces.cpp
index f5b45f1..3fcae2e 100644
--- a/tests/unit-tests/test-faces.cpp
+++ b/tests/unit-tests/test-faces.cpp
@@ -24,18 +24,19 @@
 #include "security/key-chain.hpp"
 
 #include "boost-test.hpp"
-
-#include "dummy-client-face.hpp"
+#include "util/dummy-client-face.hpp"
 
 namespace ndn {
 namespace tests {
 
+using ndn::util::DummyClientFace;
+using ndn::util::makeDummyClientFace;
+
 class FacesFixture
 {
 public:
-  FacesFixture()
-    : face(makeDummyClientFace(io))
-    , nData(0)
+  FacesFixture(bool enableRegistrationReply = true)
+    : nData(0)
     , nTimeouts(0)
     , nInInterests(0)
     , nInInterests2(0)
@@ -44,6 +45,8 @@
     , nUnregSuccesses(0)
     , nUnregFailures(0)
   {
+    DummyClientFace::Options options { true, enableRegistrationReply };
+    this->face = makeDummyClientFace(io, options);
   }
 
   void
@@ -133,12 +136,19 @@
   uint32_t nUnregFailures;
 };
 
+class FacesNoRegistrationReplyFixture : public FacesFixture
+{
+public:
+  FacesNoRegistrationReplyFixture()
+    : FacesFixture(false)
+  {
+  }
+};
+
 BOOST_FIXTURE_TEST_SUITE(TestFaces, FacesFixture)
 
 BOOST_AUTO_TEST_CASE(ExpressInterestData)
 {
-  face->enableRegistrationReply();
-
   face->expressInterest(Interest("/Hello/World", time::milliseconds(50)),
                         bind(&FacesFixture::onData, this),
                         bind(&FacesFixture::onTimeout, this));
@@ -154,8 +164,6 @@
 
 BOOST_AUTO_TEST_CASE(ExpressInterestTimeout)
 {
-  face->enableRegistrationReply();
-
   face->expressInterest(Interest("/Hello/World", time::milliseconds(50)),
                         bind(&FacesFixture::onData, this),
                         bind(&FacesFixture::onTimeout, this));
@@ -168,8 +176,6 @@
 
 BOOST_AUTO_TEST_CASE(SetFilter)
 {
-  face->enableRegistrationReply();
-
   face->setInterestFilter("/Hello/World",
                           bind(&FacesFixture::onInterest, this, ref(*face), _1, _2),
                           RegisterPrefixSuccessCallback(),
@@ -184,7 +190,7 @@
   BOOST_CHECK_EQUAL(nInInterests, 1);
 }
 
-BOOST_AUTO_TEST_CASE(SetFilterFail)
+BOOST_FIXTURE_TEST_CASE(SetFilterFail, FacesNoRegistrationReplyFixture)
 {
   // don't enable registration reply
 
@@ -200,8 +206,6 @@
 
 BOOST_AUTO_TEST_CASE(SetUnsetInterestFilter)
 {
-  face->enableRegistrationReply();
-
   const RegisteredPrefixId* regPrefixId =
     face->setInterestFilter(InterestFilter("/Hello/World"),
                             bind(&FacesFixture::onInterest, this,
@@ -234,8 +238,6 @@
 
 BOOST_AUTO_TEST_CASE(RegisterUnregisterPrefix)
 {
-  face->enableRegistrationReply();
-
   const RegisteredPrefixId* regPrefixId =
     face->registerPrefix("/Hello/World",
                          bind(&FacesFixture::onRegSucceeded, this),
@@ -257,8 +259,6 @@
 
 BOOST_AUTO_TEST_CASE(SeTwoSimilarFilters)
 {
-  face->enableRegistrationReply();
-
   face->setInterestFilter("/Hello/World",
                           bind(&FacesFixture::onInterest, this, ref(*face), _1, _2),
                           RegisterPrefixSuccessCallback(),
@@ -282,8 +282,6 @@
 
 BOOST_AUTO_TEST_CASE(SetTwoDifferentFilters)
 {
-  face->enableRegistrationReply();
-
   face->setInterestFilter("/Hello/World",
                           bind(&FacesFixture::onInterest, this, ref(*face), _1, _2),
                           RegisterPrefixSuccessCallback(),
@@ -307,8 +305,6 @@
 
 BOOST_AUTO_TEST_CASE(SetRegexFilterError)
 {
-  face->enableRegistrationReply();
-
   face->setInterestFilter(InterestFilter("/Hello/World", "<><b><c>?"),
                           bind(&FacesFixture::onInterestRegexError, this,
                                ref(*face), _1, _2),
@@ -322,8 +318,6 @@
 
 BOOST_AUTO_TEST_CASE(SetRegexFilter)
 {
-  face->enableRegistrationReply();
-
   face->setInterestFilter(InterestFilter("/Hello/World", "<><b><c>?"),
                           bind(&FacesFixture::onInterestRegex, this,
                                ref(*face), _1, _2),
@@ -348,8 +342,6 @@
 
 BOOST_AUTO_TEST_CASE(SetRegexFilterAndRegister)
 {
-  face->enableRegistrationReply();
-
   face->setInterestFilter(InterestFilter("/Hello/World", "<><b><c>?"),
                           bind(&FacesFixture::onInterestRegex, this,
                                ref(*face), _1, _2));
diff --git a/tests/unit-tests/util/notification-stream.cpp b/tests/unit-tests/util/notification-stream.cpp
index 0378bd1..adba5c7 100644
--- a/tests/unit-tests/util/notification-stream.cpp
+++ b/tests/unit-tests/util/notification-stream.cpp
@@ -49,9 +49,10 @@
 #include "simple-notification.hpp"
 
 #include "boost-test.hpp"
-#include "../dummy-client-face.hpp"
+#include "util/dummy-client-face.hpp"
 
 namespace ndn {
+namespace util {
 namespace tests {
 
 BOOST_AUTO_TEST_SUITE(UtilNotificationStream)
@@ -66,25 +67,26 @@
   SimpleNotification event1("msg1");
   notificationStream.postNotification(event1);
   face->processEvents();
-  BOOST_REQUIRE_EQUAL(face->m_sentDatas.size(), 1);
-  BOOST_CHECK_EQUAL(face->m_sentDatas[0].getName(),
+  BOOST_REQUIRE_EQUAL(face->sentDatas.size(), 1);
+  BOOST_CHECK_EQUAL(face->sentDatas[0].getName(),
                     "/localhost/nfd/NotificationStreamTest/%FE%00");
   SimpleNotification decoded1;
-  BOOST_CHECK_NO_THROW(decoded1.wireDecode(face->m_sentDatas[0].getContent().blockFromValue()));
+  BOOST_CHECK_NO_THROW(decoded1.wireDecode(face->sentDatas[0].getContent().blockFromValue()));
   BOOST_CHECK_EQUAL(decoded1.getMessage(), "msg1");
 
   SimpleNotification event2("msg2");
   notificationStream.postNotification(event2);
   face->processEvents();
-  BOOST_REQUIRE_EQUAL(face->m_sentDatas.size(), 2);
-  BOOST_CHECK_EQUAL(face->m_sentDatas[1].getName(),
+  BOOST_REQUIRE_EQUAL(face->sentDatas.size(), 2);
+  BOOST_CHECK_EQUAL(face->sentDatas[1].getName(),
                     "/localhost/nfd/NotificationStreamTest/%FE%01");
   SimpleNotification decoded2;
-  BOOST_CHECK_NO_THROW(decoded2.wireDecode(face->m_sentDatas[1].getContent().blockFromValue()));
+  BOOST_CHECK_NO_THROW(decoded2.wireDecode(face->sentDatas[1].getContent().blockFromValue()));
   BOOST_CHECK_EQUAL(decoded2.getMessage(), "msg2");
 }
 
 BOOST_AUTO_TEST_SUITE_END()
 
 } // namespace tests
+} // namespace util
 } // namespace ndn
diff --git a/tests/unit-tests/util/notification-subscriber.cpp b/tests/unit-tests/util/notification-subscriber.cpp
index 092a601..9d7ab65 100644
--- a/tests/unit-tests/util/notification-subscriber.cpp
+++ b/tests/unit-tests/util/notification-subscriber.cpp
@@ -50,9 +50,11 @@
 #include "simple-notification.hpp"
 
 #include "boost-test.hpp"
-#include "../dummy-client-face.hpp"
+#include <boost/asio.hpp>
+#include "util/dummy-client-face.hpp"
 
 namespace ndn {
+namespace util {
 namespace tests {
 
 BOOST_AUTO_TEST_SUITE(UtilNotificationSubscriber)
@@ -74,18 +76,18 @@
   void
   deliverNotification(const std::string& msg)
   {
-    publisherFace->m_sentDatas.clear();
+    publisherFace->sentDatas.clear();
     SimpleNotification notification(msg);
     notificationStream.postNotification(notification);
 
     publisherFace->processEvents(time::milliseconds(100));
 
-    BOOST_REQUIRE_EQUAL(publisherFace->m_sentDatas.size(), 1);
+    BOOST_REQUIRE_EQUAL(publisherFace->sentDatas.size(), 1);
 
-    lastDeliveredSeqNo = publisherFace->m_sentDatas[0].getName().at(-1).toSequenceNumber();
+    lastDeliveredSeqNo = publisherFace->sentDatas[0].getName().at(-1).toSequenceNumber();
 
     lastNotification.setMessage("");
-    subscriberFace->receive(publisherFace->m_sentDatas[0]);
+    subscriberFace->receive(publisherFace->sentDatas[0]);
   }
 
   void
@@ -117,10 +119,10 @@
   bool
   hasInitialRequest() const
   {
-    if (subscriberFace->m_sentInterests.empty())
+    if (subscriberFace->sentInterests.empty())
       return 0;
 
-    const Interest& interest = subscriberFace->m_sentInterests[0];
+    const Interest& interest = subscriberFace->sentInterests[0];
     return interest.getName() == streamPrefix &&
            interest.getChildSelector() == 1 &&
            interest.getMustBeFresh() &&
@@ -133,10 +135,10 @@
   uint64_t
   getRequestSeqNo() const
   {
-    if (subscriberFace->m_sentInterests.size() != 1)
+    if (subscriberFace->sentInterests.size() != 1)
       return 0;
 
-    const Interest& interest = subscriberFace->m_sentInterests[0];
+    const Interest& interest = subscriberFace->sentInterests[0];
     const Name& name = interest.getName();
     if (streamPrefix.isPrefixOf(name) &&
         name.size() == streamPrefix.size() + 1 &&
@@ -178,30 +180,30 @@
   this->deliverNotification("n1");
   subscriberFace->processEvents(time::milliseconds(100));
   BOOST_CHECK(lastNotification.getMessage().empty());
-  BOOST_CHECK_EQUAL(subscriberFace->m_sentInterests.size(), 0);
+  BOOST_CHECK_EQUAL(subscriberFace->sentInterests.size(), 0);
 
-  subscriberFace->m_sentInterests.clear();
+  subscriberFace->sentInterests.clear();
   subscriber.start();
   subscriberFace->processEvents(time::milliseconds(-100));
   BOOST_REQUIRE_EQUAL(subscriber.isRunning(), true);
   BOOST_CHECK(this->hasInitialRequest());
 
   // respond to initial request
-  subscriberFace->m_sentInterests.clear();
+  subscriberFace->sentInterests.clear();
   this->deliverNotification("n2");
   subscriberFace->processEvents(time::milliseconds(-100));
   BOOST_CHECK_EQUAL(lastNotification.getMessage(), "n2");
   BOOST_CHECK_EQUAL(this->getRequestSeqNo(), lastDeliveredSeqNo + 1);
 
   // respond to continuation request
-  subscriberFace->m_sentInterests.clear();
+  subscriberFace->sentInterests.clear();
   this->deliverNotification("n3");
   subscriberFace->processEvents(time::milliseconds(-100));
   BOOST_CHECK_EQUAL(lastNotification.getMessage(), "n3");
   BOOST_CHECK_EQUAL(this->getRequestSeqNo(), lastDeliveredSeqNo + 1);
 
   // timeout
-  subscriberFace->m_sentInterests.clear();
+  subscriberFace->sentInterests.clear();
   lastNotification.setMessage("");
   subscriberFace->processEvents(2 * subscriber.getInterestLifetime());
   BOOST_CHECK(lastNotification.getMessage().empty());
@@ -214,7 +216,7 @@
   Data wrongData(wrongName);
   publisherKeyChain.sign(wrongData);
   subscriberFace->receive(wrongData);
-  subscriberFace->m_sentInterests.clear();
+  subscriberFace->sentInterests.clear();
   lastNotification.setMessage("");
   subscriberFace->processEvents(time::milliseconds(-100));
   BOOST_CHECK(lastNotification.getMessage().empty());
@@ -222,7 +224,7 @@
   BOOST_CHECK(this->hasInitialRequest());
 
   // decode error in payload
-  subscriberFace->m_sentInterests.clear();
+  subscriberFace->sentInterests.clear();
   lastNotification.setMessage("");
   this->deliverNotification("\x07n4");
   subscriberFace->processEvents(time::milliseconds(-100));
@@ -231,13 +233,14 @@
 
   // stop if handlers are cleared
   subscriber.onNotification += bind(&EndToEndFixture::clearNotificationHandlers, this);
-  subscriberFace->m_sentInterests.clear();
+  subscriberFace->sentInterests.clear();
   this->deliverNotification("n5");
   subscriberFace->processEvents(time::milliseconds(-100));
-  BOOST_CHECK_EQUAL(subscriberFace->m_sentInterests.size(), 0);
+  BOOST_CHECK_EQUAL(subscriberFace->sentInterests.size(), 0);
 }
 
 BOOST_AUTO_TEST_SUITE_END()
 
 } // namespace tests
+} // namespace util
 } // namespace ndn
diff --git a/tests/unit-tests/util/segment-fetcher.cpp b/tests/unit-tests/util/segment-fetcher.cpp
index f5d274d..3a9fc5f 100644
--- a/tests/unit-tests/util/segment-fetcher.cpp
+++ b/tests/unit-tests/util/segment-fetcher.cpp
@@ -22,7 +22,7 @@
 #include "util/segment-fetcher.hpp"
 
 #include "boost-test.hpp"
-#include "../dummy-client-face.hpp"
+#include "util/dummy-client-face.hpp"
 #include "security/key-chain.hpp"
 
 namespace ndn {
@@ -35,7 +35,7 @@
 {
 public:
   Fixture()
-    : face(::ndn::tests::makeDummyClientFace())
+    : face(makeDummyClientFace())
     , nErrors(0)
     , nDatas(0)
     , dataSize(0)
@@ -73,7 +73,7 @@
 
 
 public:
-  shared_ptr<ndn::tests::DummyClientFace> face;
+  shared_ptr<DummyClientFace> face;
   KeyChain keyChain;
 
   uint32_t nErrors;
@@ -94,10 +94,10 @@
   BOOST_CHECK_EQUAL(nErrors, 1);
   BOOST_CHECK_EQUAL(lastError, static_cast<uint32_t>(SegmentFetcher::INTEREST_TIMEOUT));
   BOOST_CHECK_EQUAL(nDatas, 0);
-  BOOST_REQUIRE_EQUAL(face->m_sentInterests.size(), 1);
-  BOOST_CHECK_EQUAL(face->m_sentDatas.size(), 0);
+  BOOST_REQUIRE_EQUAL(face->sentInterests.size(), 1);
+  BOOST_CHECK_EQUAL(face->sentDatas.size(), 0);
 
-  const Interest& interest = face->m_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);
@@ -122,10 +122,10 @@
 
   BOOST_CHECK_EQUAL(dataSize, 14);
 
-  BOOST_REQUIRE_EQUAL(face->m_sentInterests.size(), 1);
-  BOOST_CHECK_EQUAL(face->m_sentDatas.size(), 0);
+  BOOST_REQUIRE_EQUAL(face->sentInterests.size(), 1);
+  BOOST_CHECK_EQUAL(face->sentDatas.size(), 0);
 
-  const Interest& interest = face->m_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);
@@ -204,25 +204,25 @@
 
   BOOST_CHECK_EQUAL(dataSize, 42);
 
-  BOOST_REQUIRE_EQUAL(face->m_sentInterests.size(), 3);
-  BOOST_CHECK_EQUAL(face->m_sentDatas.size(), 0);
+  BOOST_REQUIRE_EQUAL(face->sentInterests.size(), 3);
+  BOOST_CHECK_EQUAL(face->sentDatas.size(), 0);
 
   {
-    const Interest& interest = face->m_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->m_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->m_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);
@@ -257,32 +257,32 @@
 
   BOOST_CHECK_EQUAL(dataSize, 42);
 
-  BOOST_REQUIRE_EQUAL(face->m_sentInterests.size(), 4);
-  BOOST_CHECK_EQUAL(face->m_sentDatas.size(), 0);
+  BOOST_REQUIRE_EQUAL(face->sentInterests.size(), 4);
+  BOOST_CHECK_EQUAL(face->sentDatas.size(), 0);
 
   {
-    const Interest& interest = face->m_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->m_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->m_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->m_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);
diff --git a/tests/unit-tests/util/simple-notification.hpp b/tests/unit-tests/util/simple-notification.hpp
index 2def4bb..e90e374 100644
--- a/tests/unit-tests/util/simple-notification.hpp
+++ b/tests/unit-tests/util/simple-notification.hpp
@@ -54,6 +54,7 @@
 #include "security/key-chain.hpp"
 
 namespace ndn {
+namespace util {
 namespace tests {
 
 class SimpleNotification
@@ -118,6 +119,7 @@
 };
 
 } // namespace tests
+} // namespace util
 } // namespace ndn
 
 #endif // NDN_UNIT_TESTS_UTIL_CORE_SIMPLE_NOTIFICATION_HPP