tests: Rewrite FaceController tests to not use DNS

refs: #2449

Change-Id: I5fe7537e171d60fbec2ecb3f3cd36cd625a0c324
diff --git a/tests/utility/test-face-controller.cpp b/tests/utility/test-face-controller.cpp
index 13a5526..684b97b 100644
--- a/tests/utility/test-face-controller.cpp
+++ b/tests/utility/test-face-controller.cpp
@@ -1,7 +1,8 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /**
- * Copyright (c) 2014  University of Memphis,
- *                     Regents of the University of California
+ * Copyright (c) 2014-2015,  The University of Memphis,
+ *                           Regents of the University of California,
+ *                           Arizona Board of Regents.
  *
  * This file is part of NLSR (Named-data Link State Routing).
  * See AUTHORS.md for complete list of NLSR authors and contributors.
@@ -16,7 +17,6 @@
  *
  * 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/>.
- *
  **/
 
 #include "tests/test-common.hpp"
@@ -42,24 +42,11 @@
     : face(ndn::makeDummyFace())
     , interests(face->m_sentInterests)
     , controller(*face, keyChain)
-    , faceManager(g_ioService, controller)
+    , faceController(g_ioService, controller)
   {
   }
 
   void
-  expectCanonizeSuccess(const std::string& request, const std::string expectedUri)
-  {
-    faceManager.createFace(request, 0, bind(&FaceControllerFixture::onFailure, this, _1, _2));
-    expectedUris.push_back(expectedUri);
-  }
-
-  void
-  expectCanonizeFailure(const std::string& request)
-  {
-    faceManager.createFace(request, 0, bind(&FaceControllerFixture::onFailure, this, _1, _2));
-  }
-
-  void
   onFailure(uint32_t code, const std::string& reason)
   {
     BOOST_CHECK_EQUAL(code, 408);
@@ -70,68 +57,36 @@
   ndn::KeyChain keyChain;
   std::vector<Interest>& interests;
   ndn::nfd::Controller controller;
-  util::FaceController faceManager;
-
-  std::list<std::string> expectedUris;
+  util::FaceController faceController;
 };
 
 BOOST_FIXTURE_TEST_SUITE(TestFaceController, FaceControllerFixture)
 
-BOOST_AUTO_TEST_CASE(FaceCreateCanonize)
+BOOST_AUTO_TEST_CASE(FaceCreateCanonizeSuccess)
 {
-  expectCanonizeSuccess("udp4://192.0.2.1:6363", "udp4://192.0.2.1:6363");
-  expectCanonizeSuccess("tcp4://192.0.2.1:6363", "tcp4://192.0.2.1:6363");
+  const std::string uri("udp4://192.0.2.1:6363");
+  faceController.createFace(uri, nullptr, nullptr);
 
-  expectCanonizeSuccess("udp://192.0.2.1", "udp4://192.0.2.1:6363");
-  expectCanonizeSuccess("udp://203.0.113.1:6363", "udp4://203.0.113.1:6363");
-  expectCanonizeSuccess("udp4://google-public-dns-a.google.com", "udp4://8.8.8.8:6363");
-
-  expectCanonizeSuccess("tcp://192.0.2.1", "tcp4://192.0.2.1:6363");
-  expectCanonizeSuccess("tcp://203.0.113.1:6363", "tcp4://203.0.113.1:6363");
-  expectCanonizeSuccess("tcp4://google-public-dns-a.google.com", "tcp4://8.8.8.8:6363");
-
-  expectCanonizeSuccess("udp6://[2001:4860:4860::8888]:6363", "udp6://[2001:4860:4860::8888]:6363");
-  expectCanonizeSuccess("tcp6://[2001:4860:4860::8888]:6363", "tcp6://[2001:4860:4860::8888]:6363");
-
-  expectCanonizeSuccess("udp://[2001:4860:4860::8888]", "udp6://[2001:4860:4860::8888]:6363");
-  expectCanonizeSuccess("udp://[2001:4860:4860::8888]:6363", "udp6://[2001:4860:4860::8888]:6363");
-  expectCanonizeSuccess("udp6://google-public-dns-a.google.com",
-                        "udp6://[2001:4860:4860::8888]:6363");
-
-  expectCanonizeSuccess("tcp://[2001:4860:4860::8888]", "tcp6://[2001:4860:4860::8888]:6363");
-  expectCanonizeSuccess("tcp://[2001:4860:4860::8888]:6363", "tcp6://[2001:4860:4860::8888]:6363");
-  expectCanonizeSuccess("tcp6://google-public-dns-a.google.com",
-                        "tcp6://[2001:4860:4860::8888]:6363");
-
-  g_ioService.run();
   face->processEvents(ndn::time::milliseconds(1));
 
-  BOOST_CHECK_EQUAL(interests.size(), expectedUris.size());
+  BOOST_REQUIRE_EQUAL(interests.size(), 1);
+  Interest interest = interests.front();
 
-  for (std::vector<ndn::Interest>::iterator it = interests.begin(); it != interests.end(); ++it) {
+  ndn::nfd::ControlParameters extractedParameters;
+  ndn::Name::Component verb;
 
-    ndn::nfd::ControlParameters extractedParameters;
-    ndn::Name::Component verb;
+  extractFaceCommandParameters(interest, verb, extractedParameters);
 
-    extractFaceCommandParameters(*it, verb, extractedParameters);
-
-    BOOST_CHECK_EQUAL(verb, ndn::Name::Component("create"));
-
-    std::list<std::string>::iterator uri = std::find(expectedUris.begin(),
-                                                     expectedUris.end(),
-                                                     extractedParameters.getUri());
-
-    BOOST_REQUIRE(uri != expectedUris.end());
-    expectedUris.erase(uri);
-  }
+  BOOST_CHECK_EQUAL(verb, ndn::Name::Component("create"));
+  BOOST_CHECK_EQUAL(uri, extractedParameters.getUri());
 }
 
-BOOST_AUTO_TEST_CASE(FaceCreateFailure)
+BOOST_AUTO_TEST_CASE(FaceCreateCanonizeFailure)
 {
-  expectCanonizeFailure("udp4://not-a-valid.uri");
-  expectCanonizeFailure("udp4://256.0.0.1:6363");
+  faceController.createFace("invalid://256.0.0.1:6363",
+                            nullptr,
+                            bind(&FaceControllerFixture::onFailure, this, _1, _2));
 
-  g_ioService.run();
   face->processEvents(ndn::time::milliseconds(1));
 
   BOOST_CHECK_EQUAL(interests.size(), 0);