nlsr: refactor Adjacent to use FaceUri objects

Change-Id: Ib46f70570669c381572182eeea5c047a38a05104
refs: #4063
diff --git a/src/adjacency-list.cpp b/src/adjacency-list.cpp
index 56807c7..ccbea1b 100644
--- a/src/adjacency-list.cpp
+++ b/src/adjacency-list.cpp
@@ -258,8 +258,18 @@
                                 _1, faceId));
 }
 
+AdjacencyList::iterator
+AdjacencyList::findAdjacent(const ndn::util::FaceUri& faceUri)
+{
+  return std::find_if(m_adjList.begin(),
+                      m_adjList.end(),
+                      [&faceUri] (const Adjacent& adj) {
+                        return faceUri == adj.getFaceUri();
+                      });
+}
+
 uint64_t
-AdjacencyList::getFaceId(const std::string& faceUri)
+AdjacencyList::getFaceId(const ndn::util::FaceUri& faceUri)
 {
   std::list<Adjacent>::iterator it = std::find_if(m_adjList.begin(),
                                                   m_adjList.end(),
diff --git a/src/adjacency-list.hpp b/src/adjacency-list.hpp
index c9553de..daceae1 100644
--- a/src/adjacency-list.hpp
+++ b/src/adjacency-list.hpp
@@ -145,8 +145,11 @@
   AdjacencyList::iterator
   findAdjacent(uint64_t faceId);
 
+  AdjacencyList::iterator
+  findAdjacent(const ndn::util::FaceUri& faceUri);
+
   uint64_t
-  getFaceId(const std::string& faceUri);
+  getFaceId(const ndn::util::FaceUri& faceUri);
 
   void
   writeLog();
diff --git a/src/adjacent.cpp b/src/adjacent.cpp
index fb22ed3..55ddff5 100644
--- a/src/adjacent.cpp
+++ b/src/adjacent.cpp
@@ -16,9 +16,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/>.
- *
- * \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
- *
  **/
 #include <iostream>
 #include <string>
@@ -33,13 +30,11 @@
 
 INIT_LOGGER("Adjacent");
 
-using namespace std;
-
 const float Adjacent::DEFAULT_LINK_COST = 10.0;
 
 Adjacent::Adjacent()
     : m_name()
-    , m_connectingFaceUri()
+    , m_faceUri()
     , m_linkCost(DEFAULT_LINK_COST)
     , m_status(STATUS_INACTIVE)
     , m_interestTimedOutNo(0)
@@ -49,7 +44,7 @@
 
 Adjacent::Adjacent(const ndn::Name& an)
     : m_name(an)
-    , m_connectingFaceUri()
+    , m_faceUri()
     , m_linkCost(DEFAULT_LINK_COST)
     , m_status(STATUS_INACTIVE)
     , m_interestTimedOutNo(0)
@@ -57,32 +52,31 @@
   {
   }
 
-Adjacent::Adjacent(const ndn::Name& an, const std::string& cfu,  double lc,
+Adjacent::Adjacent(const ndn::Name& an, const ndn::util::FaceUri& faceUri,  double lc,
                    Status s, uint32_t iton, uint64_t faceId)
     : m_name(an)
-    , m_connectingFaceUri(cfu)
+    , m_faceUri(faceUri)
     , m_linkCost(lc)
     , m_status(s)
     , m_interestTimedOutNo(iton)
     , m_faceId(faceId)
   {
-
   }
 
 bool
 Adjacent::operator==(const Adjacent& adjacent) const
 {
   return (m_name == adjacent.getName()) &&
-         (m_connectingFaceUri == adjacent.getConnectingFaceUri()) &&
+         (m_faceUri == adjacent.getFaceUri()) &&
          (std::abs(m_linkCost - adjacent.getLinkCost()) <
-          std::numeric_limits<double>::epsilon()) ;
+          std::numeric_limits<double>::epsilon());
 }
 
 void
 Adjacent::writeLog()
 {
   _LOG_DEBUG("Adjacent : " << m_name);
-  _LOG_DEBUG("Connecting FaceUri: " << m_connectingFaceUri);
+  _LOG_DEBUG("Connecting FaceUri: " << m_faceUri);
   _LOG_DEBUG("Link Cost: " << m_linkCost);
   _LOG_DEBUG("Status: " << m_status);
   _LOG_DEBUG("Interest Timed out: " << m_interestTimedOutNo);
diff --git a/src/adjacent.hpp b/src/adjacent.hpp
index d1995cf..4aded01 100644
--- a/src/adjacent.hpp
+++ b/src/adjacent.hpp
@@ -16,14 +16,13 @@
  *
  * 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/>.
- *
- * \author A K M Mahmudul Hoque <ahoque1@memphis.edu>
- *
  **/
 #include <string>
 #include <cmath>
 #include <boost/cstdint.hpp>
+
 #include <ndn-cxx/face.hpp>
+#include <ndn-cxx/util/face-uri.hpp>
 
 #ifndef NLSR_ADJACENT_HPP
 #define NLSR_ADJACENT_HPP
@@ -45,7 +44,7 @@
 
   Adjacent(const ndn::Name& an);
 
-  Adjacent(const ndn::Name& an, const std::string& cfu,  double lc,
+  Adjacent(const ndn::Name& an, const ndn::util::FaceUri& faceUri, double lc,
            Status s, uint32_t iton, uint64_t faceId);
 
   const ndn::Name&
@@ -60,16 +59,16 @@
     m_name = an;
   }
 
-  const std::string&
-  getConnectingFaceUri() const
+  const ndn::util::FaceUri&
+  getFaceUri() const
   {
-    return m_connectingFaceUri;
+    return m_faceUri;
   }
 
   void
-  setConnectingFaceUri(const std::string& cfu)
+  setFaceUri(const ndn::util::FaceUri& faceUri)
   {
-    m_connectingFaceUri = cfu;
+    m_faceUri = faceUri;
   }
 
   uint64_t
@@ -131,15 +130,15 @@
   }
 
   inline bool
-  compareFaceId(uint64_t faceId)
+  compareFaceId(const uint64_t faceId)
   {
     return m_faceId == faceId;
   }
 
   inline bool
-  compareFaceUri(std::string& faceUri)
+  compareFaceUri(const ndn::util::FaceUri& faceUri)
   {
-    return m_connectingFaceUri == faceUri;
+    return m_faceUri == faceUri;
   }
 
   void
@@ -150,7 +149,7 @@
 
 private:
   ndn::Name m_name;
-  std::string m_connectingFaceUri;
+  ndn::util::FaceUri m_faceUri;
   double m_linkCost;
   Status m_status;
   uint32_t m_interestTimedOutNo;
@@ -159,4 +158,4 @@
 
 } // namespace nlsr
 
-#endif //NLSR_ADJACENT_HPP
+#endif // NLSR_ADJACENT_HPP
diff --git a/src/conf-file-processor.cpp b/src/conf-file-processor.cpp
index 70600fb..211609a 100644
--- a/src/conf-file-processor.cpp
+++ b/src/conf-file-processor.cpp
@@ -474,12 +474,13 @@
       try {
         ConfigSection CommandAttriTree = tn->second;
         std::string name = CommandAttriTree.get<std::string>("name");
-        std::string faceUri = CommandAttriTree.get<std::string>("face-uri");
+        std::string uriString = CommandAttriTree.get<std::string>("face-uri");
 
-        ndn::util::FaceUri uri;
-
-        if (!uri.parse(faceUri)) {
-          std::cerr << "Malformed face-uri <" << faceUri << "> for " << name << std::endl;
+        ndn::util::FaceUri faceUri;
+        try {
+          faceUri = ndn::util::FaceUri(uriString);
+        } catch (ndn::util::FaceUri::Error e) {
+          std::cerr << "Malformed face-uri <" << uriString << "> for " << name << std::endl;
           return false;
         }
 
diff --git a/src/hello-protocol.cpp b/src/hello-protocol.cpp
index 2f27020..52e8997 100644
--- a/src/hello-protocol.cpp
+++ b/src/hello-protocol.cpp
@@ -72,7 +72,7 @@
     // successful registration prompts a callback that sends the hello
     // Interest to the new Face.
     else {
-      registerPrefixes((*it).getName(), (*it).getConnectingFaceUri(),
+      registerPrefixes((*it).getName(), (*it).getFaceUri().toString(),
                        (*it).getLinkCost(), ndn::time::milliseconds::max());
     }
   }
@@ -129,7 +129,7 @@
       // If the originator of the Interest currently lacks a Face, we
       // need to give it one.
       else {
-        registerPrefixes(adjacent->getName(), adjacent->getConnectingFaceUri(),
+        registerPrefixes(adjacent->getName(), adjacent->getFaceUri().toString(),
                          adjacent->getLinkCost(), ndn::time::milliseconds::max());
       }
     }
@@ -262,7 +262,7 @@
     adjacent->setFaceId(commandSuccessResult.getFaceId());
     ndn::Name broadcastKeyPrefix = DEFAULT_BROADCAST_PREFIX;
     broadcastKeyPrefix.append("KEYS");
-    std::string faceUri = adjacent->getConnectingFaceUri();
+    std::string faceUri = adjacent->getFaceUri().toString();
     double linkCost = adjacent->getLinkCost();
     m_nlsr.getFib().registerPrefix(m_nlsr.getConfParameter().getChronosyncPrefix(),
                                  faceUri, linkCost, timeout,
diff --git a/src/lsa.cpp b/src/lsa.cpp
index 46dc1c4..78e5837 100644
--- a/src/lsa.cpp
+++ b/src/lsa.cpp
@@ -253,7 +253,7 @@
   os << m_origRouter << "|" << AdjLsa::TYPE_STRING << "|" << m_lsSeqNo << "|"
      << ndn::time::toIsoString(m_expirationTimePoint) << "|" << m_adl.getSize();
   for (const auto& adjacent : m_adl.getAdjList()) {
-    os << "|" << adjacent.getName() << "|" << adjacent.getConnectingFaceUri()
+    os << "|" << adjacent.getName() << "|" << adjacent.getFaceUri()
        << "|" << adjacent.getLinkCost();
   }
   os << "|";
@@ -290,7 +290,8 @@
       ndn::Name adjName(*tok_iter++);
       std::string connectingFaceUri(*tok_iter++);
       double linkCost = boost::lexical_cast<double>(*tok_iter++);
-      Adjacent adjacent(adjName, connectingFaceUri, linkCost, Adjacent::STATUS_INACTIVE, 0, 0);
+      Adjacent adjacent(adjName, ndn::util::FaceUri(connectingFaceUri), linkCost,
+                        Adjacent::STATUS_INACTIVE, 0, 0);
       addAdjacent(adjacent);
     }
     catch (const std::exception& e) {
@@ -342,7 +343,7 @@
   for (const Adjacent& adjacency : adjLsa) {
   os << "    Adjacent " << adjacencyIndex++ << ":\n"
      << "      Adjacent Name: " << adjacency.getName() << "\n"
-     << "      Connecting FaceUri: " << adjacency.getConnectingFaceUri() << "\n"
+     << "      Connecting FaceUri: " << adjacency.getFaceUri() << "\n"
      << "      Link Cost: " << adjacency.getLinkCost() << "\n";
   }
   os << "adj_lsa_end";
diff --git a/src/nlsr.cpp b/src/nlsr.cpp
index f00bbe1..02df4aa 100644
--- a/src/nlsr.cpp
+++ b/src/nlsr.cpp
@@ -198,15 +198,15 @@
                            std::function<void(std::list<Adjacent>::iterator)> then)
 {
   if (currentNeighbor != m_adjacencyList.getAdjList().end()) {
-    ndn::util::FaceUri uri(currentNeighbor->getConnectingFaceUri());
+    ndn::util::FaceUri uri(currentNeighbor->getFaceUri());
     uri.canonize([this, then, currentNeighbor] (ndn::util::FaceUri canonicalUri) {
-        _LOG_DEBUG("Canonized URI: " << currentNeighbor->getConnectingFaceUri()
+        _LOG_DEBUG("Canonized URI: " << currentNeighbor->getFaceUri()
                    << " to: " << canonicalUri);
-        currentNeighbor->setConnectingFaceUri(canonicalUri.toString());
+        currentNeighbor->setFaceUri(canonicalUri);
         then(std::next(currentNeighbor));
       },
       [this, then, currentNeighbor] (const std::string& reason) {
-        _LOG_ERROR("Could not canonize URI: " << currentNeighbor->getConnectingFaceUri()
+        _LOG_ERROR("Could not canonize URI: " << currentNeighbor->getFaceUri()
                    << " because: " << reason);
         then(std::next(currentNeighbor));
       },
@@ -388,7 +388,7 @@
   std::list<Adjacent>& adjacents = m_adjacencyList.getAdjList();
   for (std::list<Adjacent>::iterator it = adjacents.begin();
        it != adjacents.end(); it++) {
-    m_fib.destroyFace((*it).getConnectingFaceUri(),
+    m_fib.destroyFace((*it).getFaceUri().toString(),
                       std::bind(&Nlsr::onDestroyFaceSuccess, this, _1),
                       std::bind(&Nlsr::onDestroyFaceFailure, this, _1));
   }
diff --git a/src/publisher/lsa-publisher.cpp b/src/publisher/lsa-publisher.cpp
index 3d16581..7060c05 100644
--- a/src/publisher/lsa-publisher.cpp
+++ b/src/publisher/lsa-publisher.cpp
@@ -52,7 +52,7 @@
     for (const Adjacent& adj : lsa.getAdl().getAdjList()) {
       tlv::Adjacency tlvAdj;
       tlvAdj.setName(adj.getName());
-      tlvAdj.setUri(adj.getConnectingFaceUri());
+      tlvAdj.setUri(adj.getFaceUri().toString());
       tlvAdj.setCost(adj.getLinkCost());
       tlvLsa.addAdjacency(tlvAdj);
     }
diff --git a/src/route/fib.cpp b/src/route/fib.cpp
index 777ab1b..c4ddad8 100644
--- a/src/route/fib.cpp
+++ b/src/route/fib.cpp
@@ -266,7 +266,7 @@
                     uint64_t faceCost, const ndn::time::milliseconds& timeout,
                     uint64_t flags, uint8_t times)
 {
-  uint64_t faceId = m_adjacencyList.getFaceId(faceUri);
+  uint64_t faceId = m_adjacencyList.getFaceId(ndn::util::FaceUri(faceUri));
   if (faceId != 0) {
     ndn::nfd::ControlParameters faceParameters;
     faceParameters
diff --git a/src/route/routing-table-calculator.cpp b/src/route/routing-table-calculator.cpp
index e464c49..54d486d 100644
--- a/src/route/routing-table-calculator.cpp
+++ b/src/route/routing-table-calculator.cpp
@@ -252,7 +252,7 @@
   int v, u;
   int* Q = new int[m_nRouters]; // Each cell represents the router with that mapping no.
   int head = 0;
-  /* Initiate the Parent */
+  // Initiate the Parent
   for (i = 0 ; i < static_cast<int>(m_nRouters); i++) {
     m_parent[i] = EMPTY_PARENT;
     // Array where the ith element is the distance to the router with mapping no i.
@@ -318,7 +318,7 @@
         // Fetch its actual name
         ndn::Name nextHopRouterName = pMap.getRouterNameByMappingNo(nextHopRouter);
         std::string nextHopFace =
-          pnlsr.getAdjacencyList().getAdjacent(nextHopRouterName).getConnectingFaceUri();
+          pnlsr.getAdjacencyList().getAdjacent(nextHopRouterName).getFaceUri().toString();
         // Add next hop to routing table
         NextHop nh(nextHopFace, routeCost);
         rt.addNextHop(pMap.getRouterNameByMappingNo(i), nh);
@@ -426,7 +426,7 @@
       continue;
     }
 
-    std::string srcFaceUri = adj->getConnectingFaceUri();
+    std::string srcFaceUri = adj->getFaceUri().toString();
 
     // Install nexthops for this router to the neighbor; direct neighbors have a 0 cost link
     addNextHop(srcRouterName, srcFaceUri, 0, rt);
@@ -479,7 +479,7 @@
   CoordinateLsa* destLsa = lsdb.findCoordinateLsa(destLsaKey);
 
   // Coordinate LSAs do not exist for these routers
-  if (srcLsa == NULL || destLsa == NULL) {
+  if (srcLsa == nullptr || destLsa == nullptr) {
     return UNKNOWN_DISTANCE;
   }
 
diff --git a/tests/publisher/publisher-fixture.hpp b/tests/publisher/publisher-fixture.hpp
index eae6486..eba000d 100644
--- a/tests/publisher/publisher-fixture.hpp
+++ b/tests/publisher/publisher-fixture.hpp
@@ -45,8 +45,8 @@
   void
   addAdjacency(AdjLsa& lsa, const std::string& name, const std::string& faceUri, double cost)
   {
-    Adjacent adjacency(name, faceUri, cost, Adjacent::STATUS_ACTIVE, 0, 0);
-    lsa.addAdjacent(adjacency);
+    Adjacent adjacency(name, ndn::util::FaceUri(faceUri), cost, Adjacent::STATUS_ACTIVE, 0, 0);
+    lsa.addAdjacent(std::move(adjacency));
   }
 
   void
@@ -77,7 +77,7 @@
 
     for (const Adjacent& adjacency : lsa.getAdl().getAdjList()) {
       BOOST_CHECK_EQUAL(it->getName(), adjacency.getName());
-      BOOST_CHECK_EQUAL(it->getUri(), adjacency.getConnectingFaceUri());
+      BOOST_CHECK_EQUAL(it->getUri(), adjacency.getFaceUri().toString());
       BOOST_CHECK_EQUAL(it->getCost(), adjacency.getLinkCost());
       ++it;
     }
diff --git a/tests/test-adjacency-list.cpp b/tests/test-adjacency-list.cpp
index 8e436ee..9a46a1c 100644
--- a/tests/test-adjacency-list.cpp
+++ b/tests/test-adjacency-list.cpp
@@ -29,14 +29,12 @@
 namespace nlsr {
 namespace test {
 
-using namespace std;
-
 BOOST_AUTO_TEST_SUITE(TestAdjacencyList)
 
 BOOST_AUTO_TEST_CASE(Basic)
 {
-  const string ADJ_NAME_1 = "testname";
-  const string ADJ_NAME_2 = "testname2";
+  const std::string ADJ_NAME_1 = "testname";
+  const std::string ADJ_NAME_2 = "testname2";
 
 //adjacent needed to test adjacency list.
   Adjacent adjacent1(ADJ_NAME_1);
@@ -57,13 +55,24 @@
   BOOST_CHECK(adjacentList1.isNeighbor("testname"));
   BOOST_CHECK_EQUAL(adjacentList1.isNeighbor("adjacent"), false);
 
-  string n1 = "testname";
+  std::string n1 = "testname";
   BOOST_CHECK_EQUAL(adjacentList1.getStatusOfNeighbor(n1), Adjacent::STATUS_INACTIVE);
 
   adjacentList1.setStatusOfNeighbor(n1, Adjacent::STATUS_ACTIVE);
   BOOST_CHECK_EQUAL(adjacentList1.getStatusOfNeighbor(n1), Adjacent::STATUS_ACTIVE);
 }
 
+BOOST_AUTO_TEST_CASE(findAdjacentByFaceUri)
+{
+  ndn::util::FaceUri faceUri("udp4://10.0.0.1:6363");
+  Adjacent adj1("/ndn/test/1", faceUri, 10, Adjacent::STATUS_INACTIVE, 0, 0);
+  AdjacencyList adjList;
+  adjList.insert(adj1);
+
+  std::list<Adjacent>::iterator adjIter = adjList.findAdjacent(faceUri);
+  BOOST_CHECK(adjIter != adjList.end());
+}
+
 BOOST_AUTO_TEST_CASE(AdjLsaIsBuildableWithOneNodeActive)
 {
   Adjacent adjacencyA("/router/A");
@@ -124,5 +133,5 @@
 
 BOOST_AUTO_TEST_SUITE_END()
 
-} // namespace tests
+} // namespace test
 } // namespace nlsr
diff --git a/tests/test-adjacent.cpp b/tests/test-adjacent.cpp
index 623023e..e494682 100644
--- a/tests/test-adjacent.cpp
+++ b/tests/test-adjacent.cpp
@@ -29,22 +29,60 @@
 
 using namespace std;
 
-BOOST_AUTO_TEST_SUITE(TestAdjacenct)
+BOOST_AUTO_TEST_SUITE(TestAdjacent)
 
-BOOST_AUTO_TEST_CASE(AdjacenctBasic)
+BOOST_AUTO_TEST_CASE(OperatorEquals)
 {
-  const string ADJ_NAME_1 = "testname";
-  const string ADJ_NAME_2 = "testname";
+  const ndn::Name ADJ_NAME_1 = "name1";
+  const ndn::util::FaceUri ADJ_URI_1 = ndn::util::FaceUri("udp4://10.0.0.1:8000");
+  const double ADJ_LINK_COST_1 = 1;
+  Adjacent adjacent1(ADJ_NAME_1);
+  Adjacent adjacent2(ADJ_NAME_1);
+  adjacent1.setFaceUri(ADJ_URI_1);
+  adjacent2.setFaceUri(ADJ_URI_1);
+  adjacent1.setLinkCost(ADJ_LINK_COST_1);
+  adjacent2.setLinkCost(ADJ_LINK_COST_1);
 
+  BOOST_CHECK(adjacent1 == adjacent2);
+}
+
+BOOST_AUTO_TEST_CASE(Accessors)
+{
+  const ndn::Name ADJ_NAME_1 = "name1";
+  Adjacent adjacent1(ADJ_NAME_1);
+
+  // Link cost should always be rounded up to the nearest integer.
+  // The library only acceps integral values for prefix registration.
+  adjacent1.setLinkCost(10.1);
+
+  BOOST_CHECK_EQUAL(adjacent1.getName(), "name1");
+  BOOST_CHECK_EQUAL(adjacent1.getLinkCost(), 11);
+}
+
+BOOST_AUTO_TEST_CASE(compareFaceUri)
+{
+  const ndn::Name ADJ_NAME_1 = "name1";
+  const ndn::Name ADJ_NAME_2 = "name2";
+  const ndn::util::FaceUri ADJ_URI_1 = ndn::util::FaceUri("udp4://10.0.0.1:8000");
   Adjacent adjacent1(ADJ_NAME_1);
   Adjacent adjacent2(ADJ_NAME_2);
-  BOOST_CHECK(adjacent1 == adjacent2);
+  adjacent1.setFaceUri(ADJ_URI_1);
+  adjacent2.setFaceUri(ADJ_URI_1);
 
-  adjacent1.setLinkCost(10.1);
-  BOOST_CHECK_EQUAL(adjacent1.getLinkCost(), 11);
+  BOOST_CHECK(adjacent1.compareFaceUri(adjacent2.getFaceUri()));
+}
 
-  BOOST_CHECK_EQUAL(adjacent1.getName(), "testname");
+BOOST_AUTO_TEST_CASE(compareFaceId)
+{
+  const ndn::Name ADJ_NAME_1 = "name1";
+  const ndn::Name ADJ_NAME_2 = "name2";
+  const uint64_t ADJ_FACEID_1 = 1;
+  Adjacent adjacent1(ADJ_NAME_1);
+  Adjacent adjacent2(ADJ_NAME_2);
+  adjacent1.setFaceId(ADJ_FACEID_1);
+  adjacent2.setFaceId(ADJ_FACEID_1);
 
+  BOOST_CHECK(adjacent1.compareFaceId(adjacent2.getFaceId()));
 }
 
 BOOST_AUTO_TEST_SUITE_END()
diff --git a/tests/test-fib.cpp b/tests/test-fib.cpp
index 4b2229a..993a7a6 100644
--- a/tests/test-fib.cpp
+++ b/tests/test-fib.cpp
@@ -43,13 +43,13 @@
   {
     INIT_LOGGERS("/tmp", "DEBUG");
 
-    Adjacent neighbor1(router1Name, router1FaceUri, 0, Adjacent::STATUS_ACTIVE, 0, router1FaceId);
+    Adjacent neighbor1(router1Name, ndn::util::FaceUri(router1FaceUri), 0, Adjacent::STATUS_ACTIVE, 0, router1FaceId);
     adjacencies.insert(neighbor1);
 
-    Adjacent neighbor2(router2Name, router2FaceUri, 0, Adjacent::STATUS_ACTIVE, 0, router2FaceId);
+    Adjacent neighbor2(router2Name, ndn::util::FaceUri(router2FaceUri), 0, Adjacent::STATUS_ACTIVE, 0, router2FaceId);
     adjacencies.insert(neighbor2);
 
-    Adjacent neighbor3(router3Name, router3FaceUri, 0, Adjacent::STATUS_ACTIVE, 0, router3FaceId);
+    Adjacent neighbor3(router3Name, ndn::util::FaceUri(router3FaceUri), 0, Adjacent::STATUS_ACTIVE, 0, router3FaceId);
     adjacencies.insert(neighbor3);
 
     conf.setMaxFacesPerPrefix(2);
@@ -88,9 +88,9 @@
 const ndn::Name FibFixture::router2Name = "/ndn/router2";
 const ndn::Name FibFixture::router3Name = "/ndn/router3";
 
-const std::string FibFixture::router1FaceUri = "uri://face1";
-const std::string FibFixture::router2FaceUri = "uri://face2";
-const std::string FibFixture::router3FaceUri = "uri://face3";
+const std::string FibFixture::router1FaceUri = "udp4://10.0.0.1";
+const std::string FibFixture::router2FaceUri = "udp4://10.0.0.2";
+const std::string FibFixture::router3FaceUri = "udp4://10.0.0.3";
 
 const uint32_t FibFixture::router1FaceId = 1;
 const uint32_t FibFixture::router2FaceId = 2;
diff --git a/tests/test-hyperbolic-calculator.cpp b/tests/test-hyperbolic-calculator.cpp
index 84cfbf6..0001ae4 100644
--- a/tests/test-hyperbolic-calculator.cpp
+++ b/tests/test-hyperbolic-calculator.cpp
@@ -59,9 +59,9 @@
   {
     INIT_LOGGERS("/tmp", "TRACE");
 
-    Adjacent a(ROUTER_A_NAME, ROUTER_A_FACE, 0, Adjacent::STATUS_ACTIVE, 0, 0);
-    Adjacent b(ROUTER_B_NAME, ROUTER_B_FACE, 0, Adjacent::STATUS_ACTIVE, 0, 0);
-    Adjacent c(ROUTER_C_NAME, ROUTER_C_FACE, 0, Adjacent::STATUS_ACTIVE, 0, 0);
+    Adjacent a(ROUTER_A_NAME, ndn::util::FaceUri(ROUTER_A_FACE), 0, Adjacent::STATUS_ACTIVE, 0, 0);
+    Adjacent b(ROUTER_B_NAME, ndn::util::FaceUri(ROUTER_B_FACE), 0, Adjacent::STATUS_ACTIVE, 0, 0);
+    Adjacent c(ROUTER_C_NAME, ndn::util::FaceUri(ROUTER_C_FACE), 0, Adjacent::STATUS_ACTIVE, 0, 0);
 
     // Router A
     adjacencies.insert(b);
@@ -126,9 +126,9 @@
 const ndn::Name HyperbolicCalculatorFixture::ROUTER_B_NAME = "/ndn/router/b";
 const ndn::Name HyperbolicCalculatorFixture::ROUTER_C_NAME = "/ndn/router/c";
 
-const std::string HyperbolicCalculatorFixture::ROUTER_A_FACE = "face-a";
-const std::string HyperbolicCalculatorFixture::ROUTER_B_FACE = "face-b";
-const std::string HyperbolicCalculatorFixture::ROUTER_C_FACE = "face-c";
+const std::string HyperbolicCalculatorFixture::ROUTER_A_FACE = "udp4://10.0.0.1";
+const std::string HyperbolicCalculatorFixture::ROUTER_B_FACE = "udp4://10.0.0.2";
+const std::string HyperbolicCalculatorFixture::ROUTER_C_FACE = "udp4://10.0.0.3";
 
 uint64_t
 applyHyperbolicFactorAndRound(double d)
diff --git a/tests/test-link-state-calculator.cpp b/tests/test-link-state-calculator.cpp
index 6bbf472..50063a2 100644
--- a/tests/test-link-state-calculator.cpp
+++ b/tests/test-link-state-calculator.cpp
@@ -60,9 +60,9 @@
     conf.setRouterName("/a");
     conf.buildRouterPrefix();
 
-    Adjacent a(ROUTER_A_NAME, ROUTER_A_FACE, 0, Adjacent::STATUS_ACTIVE, 0, 0);
-    Adjacent b(ROUTER_B_NAME, ROUTER_B_FACE, 0, Adjacent::STATUS_ACTIVE, 0, 0);
-    Adjacent c(ROUTER_C_NAME, ROUTER_C_FACE, 0, Adjacent::STATUS_ACTIVE, 0, 0);
+    Adjacent a(ROUTER_A_NAME, ndn::util::FaceUri(ROUTER_A_FACE), 0, Adjacent::STATUS_ACTIVE, 0, 0);
+    Adjacent b(ROUTER_B_NAME, ndn::util::FaceUri(ROUTER_B_FACE), 0, Adjacent::STATUS_ACTIVE, 0, 0);
+    Adjacent c(ROUTER_C_NAME, ndn::util::FaceUri(ROUTER_C_FACE), 0, Adjacent::STATUS_ACTIVE, 0, 0);
 
     // Router A
     b.setLinkCost(LINK_AB_COST);
@@ -125,9 +125,9 @@
 const ndn::Name LinkStateCalculatorFixture::ROUTER_B_NAME = "/ndn/router/b";
 const ndn::Name LinkStateCalculatorFixture::ROUTER_C_NAME = "/ndn/router/c";
 
-const std::string LinkStateCalculatorFixture::ROUTER_A_FACE = "face-a";
-const std::string LinkStateCalculatorFixture::ROUTER_B_FACE = "face-b";
-const std::string LinkStateCalculatorFixture::ROUTER_C_FACE = "face-c";
+const std::string LinkStateCalculatorFixture::ROUTER_A_FACE = "udp4://10.0.0.1";
+const std::string LinkStateCalculatorFixture::ROUTER_B_FACE = "udp4://10.0.0.2";
+const std::string LinkStateCalculatorFixture::ROUTER_C_FACE = "udp4://10.0.0.3";
 
 const double LinkStateCalculatorFixture::LINK_AB_COST = 5;
 const double LinkStateCalculatorFixture::LINK_AC_COST = 10;
diff --git a/tests/test-lsa.cpp b/tests/test-lsa.cpp
index 642a317..d7c97f9 100644
--- a/tests/test-lsa.cpp
+++ b/tests/test-lsa.cpp
@@ -141,11 +141,11 @@
     "  Adjacents: \n"
     "    Adjacent 1:\n"
     "      Adjacent Name: /adjacent1\n"
-    "      Connecting FaceUri: \n"
+    "      Connecting FaceUri: ://\n"
     "      Link Cost: 10\n"
     "    Adjacent 2:\n"
     "      Adjacent Name: /adjacent2\n"
-    "      Connecting FaceUri: \n"
+    "      Connecting FaceUri: ://\n"
     "      Link Cost: 10\n"
     "adj_lsa_end";
 
@@ -167,8 +167,8 @@
   //If we don't do this the test will fail
   //Adjacent has default cost of 10 but no default
   //connecting face URI, so initializeFromContent fails
-  adj1.setConnectingFaceUri("10.0.0.1");
-  adj2.setConnectingFaceUri("10.0.0.2");
+  adj1.setFaceUri(ndn::util::FaceUri("udp://10.0.0.1"));
+  adj2.setFaceUri(ndn::util::FaceUri("udp://10.0.0.2"));
 
   AdjacencyList adjList;
   adjList.insert(adj1);
diff --git a/tests/test-name-prefix-table.cpp b/tests/test-name-prefix-table.cpp
index daaafe9..eca19f6 100644
--- a/tests/test-name-prefix-table.cpp
+++ b/tests/test-name-prefix-table.cpp
@@ -63,10 +63,10 @@
 
   NamePrefixTable& npt = nlsr.getNamePrefixTable();
 
-  Adjacent thisRouter(conf.getRouterPrefix(), "udp://face", 0, Adjacent::STATUS_ACTIVE, 0, 0);
+  Adjacent thisRouter(conf.getRouterPrefix(), ndn::util::FaceUri("udp4://10.0.0.1"), 0, Adjacent::STATUS_ACTIVE, 0, 0);
 
   ndn::Name buptRouterName("/ndn/cn/edu/bupt/%C1.Router/bupthub");
-  Adjacent bupt(buptRouterName, "udp://bupt", 0, Adjacent::STATUS_ACTIVE, 0, 0);
+  Adjacent bupt(buptRouterName, ndn::util::FaceUri("udp4://10.0.0.2"), 0, Adjacent::STATUS_ACTIVE, 0, 0);
 
   // This router's Adjacency LSA
   nlsr.getAdjacencyList().insert(bupt);
diff --git a/tests/test-nlsr.cpp b/tests/test-nlsr.cpp
index 3760289..78e0fb9 100644
--- a/tests/test-nlsr.cpp
+++ b/tests/test-nlsr.cpp
@@ -66,13 +66,13 @@
 BOOST_AUTO_TEST_CASE(HyperbolicOn_ZeroCostNeighbors)
 {
   // Simulate loading configuration file
-  Adjacent neighborA("/ndn/neighborA", "uri://faceA", 25, Adjacent::STATUS_INACTIVE, 0, 0);
+  Adjacent neighborA("/ndn/neighborA", ndn::util::FaceUri("udp4://10.0.0.1"), 25, Adjacent::STATUS_INACTIVE, 0, 0);
   neighbors.insert(neighborA);
 
-  Adjacent neighborB("/ndn/neighborB", "uri://faceB", 10, Adjacent::STATUS_INACTIVE, 0, 0);
+  Adjacent neighborB("/ndn/neighborB", ndn::util::FaceUri("udp4://10.0.0.2"), 10, Adjacent::STATUS_INACTIVE, 0, 0);
   neighbors.insert(neighborB);
 
-  Adjacent neighborC("/ndn/neighborC", "uri://faceC", 17, Adjacent::STATUS_INACTIVE, 0, 0);
+  Adjacent neighborC("/ndn/neighborC", ndn::util::FaceUri("udp4://10.0.0.3"), 17, Adjacent::STATUS_INACTIVE, 0, 0);
   neighbors.insert(neighborC);
 
   nlsr.getConfParameter().setHyperbolicState(HYPERBOLIC_STATE_ON);
@@ -89,13 +89,13 @@
 BOOST_AUTO_TEST_CASE(HyperbolicOff_LinkStateCost)
 {
   // Simulate loading configuration file
-  Adjacent neighborA("/ndn/neighborA", "uri://faceA", 25, Adjacent::STATUS_INACTIVE, 0, 0);
+  Adjacent neighborA("/ndn/neighborA", ndn::util::FaceUri("udp4://10.0.0.1"), 25, Adjacent::STATUS_INACTIVE, 0, 0);
   neighbors.insert(neighborA);
 
-  Adjacent neighborB("/ndn/neighborB", "uri://faceB", 10, Adjacent::STATUS_INACTIVE, 0, 0);
+  Adjacent neighborB("/ndn/neighborB", ndn::util::FaceUri("udp4://10.0.0.2"), 10, Adjacent::STATUS_INACTIVE, 0, 0);
   neighbors.insert(neighborB);
 
-  Adjacent neighborC("/ndn/neighborC", "uri://faceC", 17, Adjacent::STATUS_INACTIVE, 0, 0);
+  Adjacent neighborC("/ndn/neighborC", ndn::util::FaceUri("udp4://10.0.0.3"), 17, Adjacent::STATUS_INACTIVE, 0, 0);
   neighbors.insert(neighborC);
 
   nlsr.initialize();
@@ -143,12 +143,12 @@
   uint64_t destroyFaceId = 128;
 
   // Create a neighbor whose Face will be destroyed
-  Adjacent failNeighbor("/ndn/neighborA", "uri://faceA", 10, Adjacent::STATUS_ACTIVE, 0,
+  Adjacent failNeighbor("/ndn/neighborA", ndn::util::FaceUri("udp4://10.0.0.1"), 10, Adjacent::STATUS_ACTIVE, 0,
                         destroyFaceId);
   neighbors.insert(failNeighbor);
 
   // Create an additional neighbor so an adjacency LSA can be built after the face is destroyed
-  Adjacent otherNeighbor("/ndn/neighborB", "uri://faceB", 10, Adjacent::STATUS_ACTIVE, 0, 256);
+  Adjacent otherNeighbor("/ndn/neighborB", ndn::util::FaceUri("udp4://10.0.0.2"), 10, Adjacent::STATUS_ACTIVE, 0, 256);
   neighbors.insert(otherNeighbor);
 
   nlsr.initialize();
@@ -158,7 +158,7 @@
 
   // Set up adjacency LSAs
   // This router
-  Adjacent thisRouter(conf.getRouterPrefix(), "uri://faceB", 10, Adjacent::STATUS_ACTIVE, 0, 256);
+  Adjacent thisRouter(conf.getRouterPrefix(), ndn::util::FaceUri("udp4://10.0.0.3"), 10, Adjacent::STATUS_ACTIVE, 0, 256);
 
   AdjLsa ownAdjLsa(conf.getRouterPrefix(), 10, ndn::time::system_clock::now(), 1, neighbors);
   lsdb.installAdjLsa(ownAdjLsa);
@@ -256,12 +256,12 @@
   uint64_t destroyFaceId = 128;
 
   // Create an inactive neighbor whose Face will be destroyed
-  Adjacent failNeighbor("/ndn/neighborA", "uri://faceA", 10, Adjacent::STATUS_INACTIVE, 3,
+  Adjacent failNeighbor("/ndn/neighborA", ndn::util::FaceUri("udp4://10.0.0.1"), 10, Adjacent::STATUS_INACTIVE, 3,
                         destroyFaceId);
   neighbors.insert(failNeighbor);
 
   // Create an additional active neighbor so an adjacency LSA can be built
-  Adjacent otherNeighbor("/ndn/neighborB", "uri://faceB", 25, Adjacent::STATUS_ACTIVE, 0, 256);
+  Adjacent otherNeighbor("/ndn/neighborB", ndn::util::FaceUri("udp4://10.0.0.2"), 25, Adjacent::STATUS_ACTIVE, 0, 256);
   neighbors.insert(otherNeighbor);
 
   // Add a name for the neighbor to advertise
@@ -279,7 +279,7 @@
 
   // Set up adjacency LSAs
   // This router
-  Adjacent thisRouter(conf.getRouterPrefix(), "uri://faceB", 25, Adjacent::STATUS_ACTIVE, 0, 256);
+  Adjacent thisRouter(conf.getRouterPrefix(), ndn::util::FaceUri("udp4://10.0.0.2"), 25, Adjacent::STATUS_ACTIVE, 0, 256);
 
   AdjLsa ownAdjLsa(conf.getRouterPrefix(), 10, ndn::time::system_clock::now(), 1, neighbors);
   lsdb.installAdjLsa(ownAdjLsa);
@@ -398,12 +398,12 @@
   // Add neighbors
   // Router A
   ndn::Name neighborAName("/ndn/site/%C1.router/routerA");
-  Adjacent neighborA(neighborAName, "uri://faceA", 0, Adjacent::STATUS_INACTIVE, 0, 0);
+  Adjacent neighborA(neighborAName, ndn::util::FaceUri("udp4://10.0.0.1"), 0, Adjacent::STATUS_INACTIVE, 0, 0);
   neighbors.insert(neighborA);
 
   // Router B
   ndn::Name neighborBName("/ndn/site/%C1.router/routerB");
-  Adjacent neighborB(neighborBName, "uri://faceA", 0, Adjacent::STATUS_INACTIVE, 0, 0);
+  Adjacent neighborB(neighborBName, ndn::util::FaceUri("udp4://10.0.0.1"), 0, Adjacent::STATUS_INACTIVE, 0, 0);
   neighbors.insert(neighborB);
 
   nlsr.initialize();
@@ -450,11 +450,13 @@
 BOOST_AUTO_TEST_CASE(CanonizeUris)
 {
   ndn::Name neighborAName("/ndn/site/%C1.router/routerA");
-  Adjacent neighborA(neighborAName, "udp://10.0.0.1", 0, Adjacent::STATUS_INACTIVE, 0, 0);
+  ndn::util::FaceUri faceUriA("udp://10.0.0.1");
+  Adjacent neighborA(neighborAName, faceUriA, 0, Adjacent::STATUS_INACTIVE, 0, 0);
   neighbors.insert(neighborA);
 
   ndn::Name neighborBName("/ndn/site/%C1.router/routerB");
-  Adjacent neighborB(neighborBName, "udp://10.0.0.2", 0, Adjacent::STATUS_INACTIVE, 0, 0);
+  ndn::util::FaceUri faceUriB("udp://10.0.0.2");
+  Adjacent neighborB(neighborBName, faceUriB, 0, Adjacent::STATUS_INACTIVE, 0, 0);
   neighbors.insert(neighborB);
 
   int nCanonizationsLeft = nlsr.getAdjacencyList().getAdjList().size();
@@ -471,11 +473,11 @@
     this->advanceClocks(ndn::time::milliseconds(1));
   }
 
-  BOOST_CHECK_EQUAL(nlsr.getAdjacencyList().getAdjacent(neighborAName).getConnectingFaceUri(),
-                    "udp4://10.0.0.1:6363");
+  BOOST_CHECK_EQUAL(nlsr.getAdjacencyList().getAdjacent(neighborAName).getFaceUri(),
+                    ndn::util::FaceUri("udp4://10.0.0.1:6363"));
 
-  BOOST_CHECK_EQUAL(nlsr.getAdjacencyList().getAdjacent(neighborBName).getConnectingFaceUri(),
-                    "udp4://10.0.0.2:6363");
+  BOOST_CHECK_EQUAL(nlsr.getAdjacencyList().getAdjacent(neighborBName).getFaceUri(),
+                    ndn::util::FaceUri("udp4://10.0.0.2:6363"));
 }
 
 BOOST_AUTO_TEST_SUITE_END()