face: Face::getLocalUri

refs #1396

Change-Id: Icf02ae0a4136b6da3f6388cdce2f861bec44e940
diff --git a/tests/face/tcp.cpp b/tests/face/tcp.cpp
index 6fe74e4..b98107e 100644
--- a/tests/face/tcp.cpp
+++ b/tests/face/tcp.cpp
@@ -38,16 +38,16 @@
   void
   channel1_onFaceCreated(const shared_ptr<Face>& newFace)
   {
-    BOOST_CHECK(!static_cast<bool>(m_face1));
-    m_face1 = newFace;
-    m_face1->onReceiveInterest +=
+    BOOST_CHECK(!static_cast<bool>(face1));
+    face1 = newFace;
+    face1->onReceiveInterest +=
       bind(&EndToEndFixture::face1_onReceiveInterest, this, _1);
-    m_face1->onReceiveData +=
+    face1->onReceiveData +=
       bind(&EndToEndFixture::face1_onReceiveData, this, _1);
-    m_face1->onFail +=
+    face1->onFail +=
       bind(&EndToEndFixture::face1_onFail, this);
 
-    m_limitedIo.afterOp();
+    limitedIo.afterOp();
   }
 
   void
@@ -55,45 +55,45 @@
   {
     BOOST_CHECK_MESSAGE(false, reason);
 
-    m_limitedIo.afterOp();
+    limitedIo.afterOp();
   }
 
   void
   face1_onReceiveInterest(const Interest& interest)
   {
-    m_face1_receivedInterests.push_back(interest);
+    face1_receivedInterests.push_back(interest);
 
-    m_limitedIo.afterOp();
+    limitedIo.afterOp();
   }
 
   void
   face1_onReceiveData(const Data& data)
   {
-    m_face1_receivedDatas.push_back(data);
+    face1_receivedDatas.push_back(data);
 
-    m_limitedIo.afterOp();
+    limitedIo.afterOp();
   }
 
   void
   face1_onFail()
   {
-    m_face1.reset();
-    m_limitedIo.afterOp();
+    face1.reset();
+    limitedIo.afterOp();
   }
 
   void
   channel2_onFaceCreated(const shared_ptr<Face>& newFace)
   {
-    BOOST_CHECK(!static_cast<bool>(m_face2));
-    m_face2 = newFace;
-    m_face2->onReceiveInterest +=
+    BOOST_CHECK(!static_cast<bool>(face2));
+    face2 = newFace;
+    face2->onReceiveInterest +=
       bind(&EndToEndFixture::face2_onReceiveInterest, this, _1);
-    m_face2->onReceiveData +=
+    face2->onReceiveData +=
       bind(&EndToEndFixture::face2_onReceiveData, this, _1);
-    m_face2->onFail +=
+    face2->onFail +=
       bind(&EndToEndFixture::face2_onFail, this);
 
-    m_limitedIo.afterOp();
+    limitedIo.afterOp();
   }
 
   void
@@ -101,37 +101,37 @@
   {
     BOOST_CHECK_MESSAGE(false, reason);
 
-    m_limitedIo.afterOp();
+    limitedIo.afterOp();
   }
 
   void
   face2_onReceiveInterest(const Interest& interest)
   {
-    m_face2_receivedInterests.push_back(interest);
+    face2_receivedInterests.push_back(interest);
 
-    m_limitedIo.afterOp();
+    limitedIo.afterOp();
   }
 
   void
   face2_onReceiveData(const Data& data)
   {
-    m_face2_receivedDatas.push_back(data);
+    face2_receivedDatas.push_back(data);
 
-    m_limitedIo.afterOp();
+    limitedIo.afterOp();
   }
 
   void
   face2_onFail()
   {
-    m_face2.reset();
-    m_limitedIo.afterOp();
+    face2.reset();
+    limitedIo.afterOp();
   }
 
   void
   channel_onFaceCreated(const shared_ptr<Face>& newFace)
   {
-    m_faces.push_back(newFace);
-    m_limitedIo.afterOp();
+    faces.push_back(newFace);
+    limitedIo.afterOp();
   }
 
   void
@@ -139,26 +139,26 @@
   {
     BOOST_CHECK_MESSAGE(false, reason);
 
-    m_limitedIo.afterOp();
+    limitedIo.afterOp();
   }
 
   void
   checkFaceList(size_t shouldBe)
   {
-    BOOST_CHECK_EQUAL(m_faces.size(), shouldBe);
+    BOOST_CHECK_EQUAL(faces.size(), shouldBe);
   }
 
 public:
-  LimitedIo m_limitedIo;
+  LimitedIo limitedIo;
 
-  shared_ptr<Face> m_face1;
-  std::vector<Interest> m_face1_receivedInterests;
-  std::vector<Data> m_face1_receivedDatas;
-  shared_ptr<Face> m_face2;
-  std::vector<Interest> m_face2_receivedInterests;
-  std::vector<Data> m_face2_receivedDatas;
+  shared_ptr<Face> face1;
+  std::vector<Interest> face1_receivedInterests;
+  std::vector<Data> face1_receivedDatas;
+  shared_ptr<Face> face2;
+  std::vector<Interest> face2_receivedInterests;
+  std::vector<Data> face2_receivedDatas;
 
-  std::list< shared_ptr<Face> > m_faces;
+  std::list< shared_ptr<Face> > faces;
 };
 
 
@@ -180,23 +180,24 @@
                      bind(&EndToEndFixture::channel2_onFaceCreated, this, _1),
                      bind(&EndToEndFixture::channel2_onConnectFailed, this, _1));
 
-  BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(10)) == LimitedIo::EXCEED_OPS,
+  BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(10)) == LimitedIo::EXCEED_OPS,
                       "TcpChannel error: cannot connect or cannot accept connection");
 
-  BOOST_REQUIRE(static_cast<bool>(m_face1));
-  BOOST_REQUIRE(static_cast<bool>(m_face2));
+  BOOST_REQUIRE(static_cast<bool>(face1));
+  BOOST_REQUIRE(static_cast<bool>(face2));
 
-  BOOST_CHECK(m_face1->isOnDemand());
-  BOOST_CHECK(!m_face2->isOnDemand());
+  BOOST_CHECK(face1->isOnDemand());
+  BOOST_CHECK(!face2->isOnDemand());
 
-  BOOST_CHECK_EQUAL(m_face2->getUri().toString(), "tcp4://127.0.0.1:20070");
-  // face1 has an unknown URI, since the source port is automatically chosen by OS
+  BOOST_CHECK_EQUAL(face2->getRemoteUri().toString(), "tcp4://127.0.0.1:20070");
+  BOOST_CHECK_EQUAL(face1->getLocalUri().toString(), "tcp4://127.0.0.1:20070");
+  // face1 has an unknown remoteUri, since the source port is automatically chosen by OS
 
-  BOOST_CHECK_EQUAL(m_face1->isLocal(), true);
-  BOOST_CHECK_EQUAL(m_face2->isLocal(), true);
+  BOOST_CHECK_EQUAL(face1->isLocal(), true);
+  BOOST_CHECK_EQUAL(face2->isLocal(), true);
 
-  BOOST_CHECK_EQUAL(static_cast<bool>(dynamic_pointer_cast<LocalFace>(m_face1)), true);
-  BOOST_CHECK_EQUAL(static_cast<bool>(dynamic_pointer_cast<LocalFace>(m_face2)), true);
+  BOOST_CHECK_EQUAL(static_cast<bool>(dynamic_pointer_cast<LocalFace>(face1)), true);
+  BOOST_CHECK_EQUAL(static_cast<bool>(dynamic_pointer_cast<LocalFace>(face2)), true);
 
   // integrated tests needs to check that TcpFace for non-loopback fails these tests...
 
@@ -214,36 +215,36 @@
   data1.setSignature(fakeSignature);
   data2.setSignature(fakeSignature);
 
-  m_face1->sendInterest(interest1);
-  m_face1->sendInterest(interest1);
-  m_face1->sendInterest(interest1);
-  m_face1->sendData    (data1    );
-  m_face2->sendInterest(interest2);
-  m_face2->sendData    (data2    );
-  m_face2->sendData    (data2    );
-  m_face2->sendData    (data2    );
+  face1->sendInterest(interest1);
+  face1->sendInterest(interest1);
+  face1->sendInterest(interest1);
+  face1->sendData    (data1    );
+  face2->sendInterest(interest2);
+  face2->sendData    (data2    );
+  face2->sendData    (data2    );
+  face2->sendData    (data2    );
 
-  BOOST_CHECK_MESSAGE(m_limitedIo.run(8, time::seconds(10)) == LimitedIo::EXCEED_OPS,
+  BOOST_CHECK_MESSAGE(limitedIo.run(8, time::seconds(10)) == LimitedIo::EXCEED_OPS,
                       "TcpChannel error: cannot send or receive Interest/Data packets");
 
 
-  BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 1);
-  BOOST_REQUIRE_EQUAL(m_face1_receivedDatas    .size(), 3);
-  BOOST_REQUIRE_EQUAL(m_face2_receivedInterests.size(), 3);
-  BOOST_REQUIRE_EQUAL(m_face2_receivedDatas    .size(), 1);
+  BOOST_REQUIRE_EQUAL(face1_receivedInterests.size(), 1);
+  BOOST_REQUIRE_EQUAL(face1_receivedDatas    .size(), 3);
+  BOOST_REQUIRE_EQUAL(face2_receivedInterests.size(), 3);
+  BOOST_REQUIRE_EQUAL(face2_receivedDatas    .size(), 1);
 
-  BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getName(), interest2.getName());
-  BOOST_CHECK_EQUAL(m_face1_receivedDatas    [0].getName(), data2.getName());
-  BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getName(), interest1.getName());
-  BOOST_CHECK_EQUAL(m_face2_receivedDatas    [0].getName(), data1.getName());
+  BOOST_CHECK_EQUAL(face1_receivedInterests[0].getName(), interest2.getName());
+  BOOST_CHECK_EQUAL(face1_receivedDatas    [0].getName(), data2.getName());
+  BOOST_CHECK_EQUAL(face2_receivedInterests[0].getName(), interest1.getName());
+  BOOST_CHECK_EQUAL(face2_receivedDatas    [0].getName(), data1.getName());
 
-  const FaceCounters& counters1 = m_face1->getCounters();
+  const FaceCounters& counters1 = face1->getCounters();
   BOOST_CHECK_EQUAL(counters1.getInInterest() , 1);
   BOOST_CHECK_EQUAL(counters1.getInData()     , 3);
   BOOST_CHECK_EQUAL(counters1.getOutInterest(), 3);
   BOOST_CHECK_EQUAL(counters1.getOutData()    , 1);
 
-  const FaceCounters& counters2 = m_face2->getCounters();
+  const FaceCounters& counters2 = face2->getCounters();
   BOOST_CHECK_EQUAL(counters2.getInInterest() , 3);
   BOOST_CHECK_EQUAL(counters2.getInData()     , 1);
   BOOST_CHECK_EQUAL(counters2.getOutInterest(), 1);
@@ -264,20 +265,21 @@
                      bind(&EndToEndFixture::channel2_onFaceCreated, this, _1),
                      bind(&EndToEndFixture::channel2_onConnectFailed, this, _1));
 
-  BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(10)) == LimitedIo::EXCEED_OPS,
+  BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(10)) == LimitedIo::EXCEED_OPS,
                       "TcpChannel error: cannot connect or cannot accept connection");
 
-  BOOST_REQUIRE(static_cast<bool>(m_face1));
-  BOOST_REQUIRE(static_cast<bool>(m_face2));
+  BOOST_REQUIRE(static_cast<bool>(face1));
+  BOOST_REQUIRE(static_cast<bool>(face2));
 
-  BOOST_CHECK_EQUAL(m_face2->getUri().toString(), "tcp6://[::1]:20070");
-  // face1 has an unknown URI, since the source port is automatically chosen by OS
+  BOOST_CHECK_EQUAL(face2->getRemoteUri().toString(), "tcp6://[::1]:20070");
+  BOOST_CHECK_EQUAL(face1->getLocalUri().toString(), "tcp6://[::1]:20070");
+  // face1 has an unknown remoteUri, since the source port is automatically chosen by OS
 
-  BOOST_CHECK_EQUAL(m_face1->isLocal(), true);
-  BOOST_CHECK_EQUAL(m_face2->isLocal(), true);
+  BOOST_CHECK_EQUAL(face1->isLocal(), true);
+  BOOST_CHECK_EQUAL(face2->isLocal(), true);
 
-  BOOST_CHECK_EQUAL(static_cast<bool>(dynamic_pointer_cast<LocalFace>(m_face1)), true);
-  BOOST_CHECK_EQUAL(static_cast<bool>(dynamic_pointer_cast<LocalFace>(m_face2)), true);
+  BOOST_CHECK_EQUAL(static_cast<bool>(dynamic_pointer_cast<LocalFace>(face1)), true);
+  BOOST_CHECK_EQUAL(static_cast<bool>(dynamic_pointer_cast<LocalFace>(face2)), true);
 
   // integrated tests needs to check that TcpFace for non-loopback fails these tests...
 
@@ -295,24 +297,24 @@
   data1.setSignature(fakeSignature);
   data2.setSignature(fakeSignature);
 
-  m_face1->sendInterest(interest1);
-  m_face1->sendData    (data1    );
-  m_face2->sendInterest(interest2);
-  m_face2->sendData    (data2    );
+  face1->sendInterest(interest1);
+  face1->sendData    (data1    );
+  face2->sendInterest(interest2);
+  face2->sendData    (data2    );
 
-  BOOST_CHECK_MESSAGE(m_limitedIo.run(4, time::seconds(10)) == LimitedIo::EXCEED_OPS,
+  BOOST_CHECK_MESSAGE(limitedIo.run(4, time::seconds(10)) == LimitedIo::EXCEED_OPS,
                       "TcpChannel error: cannot send or receive Interest/Data packets");
 
 
-  BOOST_REQUIRE_EQUAL(m_face1_receivedInterests.size(), 1);
-  BOOST_REQUIRE_EQUAL(m_face1_receivedDatas    .size(), 1);
-  BOOST_REQUIRE_EQUAL(m_face2_receivedInterests.size(), 1);
-  BOOST_REQUIRE_EQUAL(m_face2_receivedDatas    .size(), 1);
+  BOOST_REQUIRE_EQUAL(face1_receivedInterests.size(), 1);
+  BOOST_REQUIRE_EQUAL(face1_receivedDatas    .size(), 1);
+  BOOST_REQUIRE_EQUAL(face2_receivedInterests.size(), 1);
+  BOOST_REQUIRE_EQUAL(face2_receivedDatas    .size(), 1);
 
-  BOOST_CHECK_EQUAL(m_face1_receivedInterests[0].getName(), interest2.getName());
-  BOOST_CHECK_EQUAL(m_face1_receivedDatas    [0].getName(), data2.getName());
-  BOOST_CHECK_EQUAL(m_face2_receivedInterests[0].getName(), interest1.getName());
-  BOOST_CHECK_EQUAL(m_face2_receivedDatas    [0].getName(), data1.getName());
+  BOOST_CHECK_EQUAL(face1_receivedInterests[0].getName(), interest2.getName());
+  BOOST_CHECK_EQUAL(face1_receivedDatas    [0].getName(), data2.getName());
+  BOOST_CHECK_EQUAL(face2_receivedInterests[0].getName(), interest1.getName());
+  BOOST_CHECK_EQUAL(face2_receivedDatas    [0].getName(), data1.getName());
 }
 
 BOOST_FIXTURE_TEST_CASE(MultipleAccepts, EndToEndFixture)
@@ -330,11 +332,11 @@
                     bind(&EndToEndFixture::channel_onConnectFailed, this, _1),
                     time::seconds(4)); // very short timeout
 
-  BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(10)) == LimitedIo::EXCEED_OPS,
+  BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(10)) == LimitedIo::EXCEED_OPS,
                       "TcpChannel error: cannot connect or cannot accept connection");
 
 
-  BOOST_CHECK_EQUAL(m_faces.size(), 2);
+  BOOST_CHECK_EQUAL(faces.size(), 2);
 
   shared_ptr<TcpChannel> channel3 = factory.createChannel("127.0.0.1", "20072");
   channel3->connect("127.0.0.1", "20070",
@@ -359,11 +361,11 @@
   scheduler::schedule(time::milliseconds(500),
                       bind(&EndToEndFixture::checkFaceList, this, 4));
 
-  BOOST_CHECK_MESSAGE(m_limitedIo.run(4,// 2 connects and 2 accepts
+  BOOST_CHECK_MESSAGE(limitedIo.run(4,// 2 connects and 2 accepts
                       time::seconds(10)) == LimitedIo::EXCEED_OPS,
                       "TcpChannel error: cannot connect or cannot accept multiple connections");
 
-  BOOST_CHECK_EQUAL(m_faces.size(), 6);
+  BOOST_CHECK_EQUAL(faces.size(), 6);
 }
 
 
@@ -382,24 +384,24 @@
                     bind(&EndToEndFixture::channel2_onConnectFailed, this, _1),
                     time::seconds(4)); // very short timeout
 
-  BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(10)) == LimitedIo::EXCEED_OPS,
+  BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(10)) == LimitedIo::EXCEED_OPS,
                       "TcpChannel error: cannot connect or cannot accept connection");
 
   BOOST_CHECK_EQUAL(channel1->size(), 1);
   BOOST_CHECK_EQUAL(channel2->size(), 1);
 
-  BOOST_REQUIRE(static_cast<bool>(m_face1));
-  BOOST_CHECK(static_cast<bool>(m_face2));
+  BOOST_REQUIRE(static_cast<bool>(face1));
+  BOOST_CHECK(static_cast<bool>(face2));
 
   // Face::close must be invoked during io run to be counted as an op
-  scheduler::schedule(time::milliseconds(100), bind(&Face::close, m_face1));
+  scheduler::schedule(time::milliseconds(100), bind(&Face::close, face1));
 
-  BOOST_CHECK_MESSAGE(m_limitedIo.run(2, time::seconds(10)) == LimitedIo::EXCEED_OPS,
+  BOOST_CHECK_MESSAGE(limitedIo.run(2, time::seconds(10)) == LimitedIo::EXCEED_OPS,
                       "FaceClosing error: cannot properly close faces");
 
   // both faces should get closed
-  BOOST_CHECK(!static_cast<bool>(m_face1));
-  BOOST_CHECK(!static_cast<bool>(m_face2));
+  BOOST_CHECK(!static_cast<bool>(face1));
+  BOOST_CHECK(!static_cast<bool>(face2));
 
   BOOST_CHECK_EQUAL(channel1->size(), 0);
   BOOST_CHECK_EQUAL(channel2->size(), 0);