face: ProtocolFactory::createFace with FacePersistency
Change-Id: If02510bd631e9aaa63b3cca89ced31a42e192ded
Refs: #2989
diff --git a/tests/daemon/face/ethernet.t.cpp b/tests/daemon/face/ethernet.t.cpp
index e0e08f8..a6faf06 100644
--- a/tests/daemon/face/ethernet.t.cpp
+++ b/tests/daemon/face/ethernet.t.cpp
@@ -99,6 +99,29 @@
BOOST_CHECK_NE(face1, face3);
}
+BOOST_AUTO_TEST_CASE(UnsupportedFaceCreate)
+{
+ EthernetFactory factory;
+
+ BOOST_CHECK_THROW(factory.createFace(FaceUri("ether://[08:00:27:01:01:01]"),
+ ndn::nfd::FACE_PERSISTENCY_PERMANENT,
+ bind([]{}),
+ bind([]{})),
+ ProtocolFactory::Error);
+
+ BOOST_CHECK_THROW(factory.createFace(FaceUri("ether://[08:00:27:01:01:01]"),
+ ndn::nfd::FACE_PERSISTENCY_ON_DEMAND,
+ bind([]{}),
+ bind([]{})),
+ ProtocolFactory::Error);
+
+ BOOST_CHECK_THROW(factory.createFace(FaceUri("ether://[08:00:27:01:01:01]"),
+ ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+ bind([]{}),
+ bind([]{})),
+ ProtocolFactory::Error);
+}
+
BOOST_AUTO_TEST_CASE(SendPacket)
{
if (m_interfaces.empty()) {
diff --git a/tests/daemon/face/tcp.t.cpp b/tests/daemon/face/tcp.t.cpp
index 2f85e37..bec87e1 100644
--- a/tests/daemon/face/tcp.t.cpp
+++ b/tests/daemon/face/tcp.t.cpp
@@ -79,11 +79,6 @@
{
public:
void
- ignore()
- {
- }
-
- void
checkError(const std::string& errorActual, const std::string& errorExpected)
{
BOOST_CHECK_EQUAL(errorActual, errorExpected);
@@ -98,20 +93,42 @@
BOOST_FIXTURE_TEST_CASE(FaceCreate, FaceCreateFixture)
{
- TcpFactory factory = TcpFactory();
+ TcpFactory factory;
factory.createFace(FaceUri("tcp4://127.0.0.1:6363"),
- bind(&FaceCreateFixture::ignore, this),
+ ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+ bind([]{}),
bind(&FaceCreateFixture::checkError, this, _1,
"No channels available to connect to 127.0.0.1:6363"));
factory.createChannel("127.0.0.1", "20071");
-
+
factory.createFace(FaceUri("tcp4://127.0.0.1:20070"),
- bind(&FaceCreateFixture::ignore, this),
+ ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+ bind([]{}),
bind(&FaceCreateFixture::failIfError, this, _1));
}
+BOOST_FIXTURE_TEST_CASE(UnsupportedFaceCreate, FaceCreateFixture)
+{
+ TcpFactory factory;
+
+ factory.createChannel("127.0.0.1", "20070");
+ factory.createChannel("127.0.0.1", "20071");
+
+ BOOST_CHECK_THROW(factory.createFace(FaceUri("tcp4://127.0.0.1:20070"),
+ ndn::nfd::FACE_PERSISTENCY_PERMANENT,
+ bind([]{}),
+ bind([]{})),
+ ProtocolFactory::Error);
+
+ BOOST_CHECK_THROW(factory.createFace(FaceUri("tcp4://127.0.0.1:20071"),
+ ndn::nfd::FACE_PERSISTENCY_ON_DEMAND,
+ bind([]{}),
+ bind([]{})),
+ ProtocolFactory::Error);
+}
+
class EndToEndFixture : protected BaseFixture
{
public:
@@ -266,6 +283,7 @@
factory2.createChannel("127.0.0.2", "20071");
factory2.createFace(FaceUri("tcp4://127.0.0.1:20070"),
+ ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
bind(&EndToEndFixture::channel2_onFaceCreated, this, _1),
bind(&EndToEndFixture::channel2_onConnectFailed, this, _1));
@@ -353,6 +371,7 @@
factory2.createChannel("::2", "20070");
factory2.createFace(FaceUri("tcp6://[::1]:20070"),
+ ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
bind(&EndToEndFixture::channel2_onFaceCreated, this, _1),
bind(&EndToEndFixture::channel2_onConnectFailed, this, _1));
@@ -630,6 +649,7 @@
shared_ptr<TcpChannel> channel = factory.createChannel("0.0.0.0", "20070");
factory.createFace(FaceUri("tcp4://192.0.2.1:20070"),
+ ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
bind(&FaceCreateTimeoutFixture::onFaceCreated, this, _1),
bind(&FaceCreateTimeoutFixture::onConnectFailed, this, _1));
@@ -659,6 +679,7 @@
factory2.createChannel("127.0.0.2", "20071");
factory2.createFace(FaceUri("tcp4://127.0.0.1:20070"),
+ ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
bind(&EndToEndFixture::channel2_onFaceCreated, this, _1),
bind(&EndToEndFixture::channel2_onConnectFailed, this, _1));
diff --git a/tests/daemon/face/udp.t.cpp b/tests/daemon/face/udp.t.cpp
index 4eaafb2..ff0c710 100644
--- a/tests/daemon/face/udp.t.cpp
+++ b/tests/daemon/face/udp.t.cpp
@@ -200,11 +200,6 @@
{
public:
void
- ignore()
- {
- }
-
- void
checkError(const std::string& errorActual, const std::string& errorExpected)
{
BOOST_CHECK_EQUAL(errorActual, errorExpected);
@@ -222,17 +217,39 @@
UdpFactory factory = UdpFactory();
factory.createFace(FaceUri("udp4://127.0.0.1:6363"),
- bind(&FaceCreateFixture::ignore, this),
+ ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+ bind([]{}),
bind(&FaceCreateFixture::checkError, this, _1,
"No channels available to connect to 127.0.0.1:6363"));
factory.createChannel("127.0.0.1", "20071");
factory.createFace(FaceUri("udp4://127.0.0.1:20070"),
- bind(&FaceCreateFixture::ignore, this),
+ ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+ bind([]{}),
bind(&FaceCreateFixture::failIfError, this, _1));
}
+BOOST_FIXTURE_TEST_CASE(UnsupportedFaceCreate, FaceCreateFixture)
+{
+ UdpFactory factory;
+
+ factory.createChannel("127.0.0.1", "20070");
+ factory.createChannel("127.0.0.1", "20071");
+
+ BOOST_CHECK_THROW(factory.createFace(FaceUri("udp4://127.0.0.1:20070"),
+ ndn::nfd::FACE_PERSISTENCY_PERMANENT,
+ bind([]{}),
+ bind([]{})),
+ ProtocolFactory::Error);
+
+ BOOST_CHECK_THROW(factory.createFace(FaceUri("udp4://127.0.0.1:20071"),
+ ndn::nfd::FACE_PERSISTENCY_ON_DEMAND,
+ bind([]{}),
+ bind([]{})),
+ ProtocolFactory::Error);
+}
+
class EndToEndIpv4
{
public:
@@ -351,6 +368,7 @@
shared_ptr<Face> face1;
unique_ptr<FaceHistory> history1;
factory.createFace(A::getFaceUri2(),
+ ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
[&] (shared_ptr<Face> newFace) {
face1 = newFace;
history1.reset(new FaceHistory(*face1, limitedIo));
@@ -516,6 +534,7 @@
shared_ptr<Face> face1;
unique_ptr<FaceHistory> history1;
factory.createFace(A::getFaceUri2(),
+ ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
[&] (shared_ptr<Face> newFace) {
face1 = newFace;
history1.reset(new FaceHistory(*face1, limitedIo));
diff --git a/tests/daemon/face/unix-stream.t.cpp b/tests/daemon/face/unix-stream.t.cpp
index 44df52d..c5f5221 100644
--- a/tests/daemon/face/unix-stream.t.cpp
+++ b/tests/daemon/face/unix-stream.t.cpp
@@ -74,6 +74,29 @@
BOOST_CHECK_EQUAL(expectedChannels.size(), 0);
}
+BOOST_AUTO_TEST_CASE(UnsupportedFaceCreate)
+{
+ UnixStreamFactory factory;
+
+ BOOST_CHECK_THROW(factory.createFace(FaceUri("unix:///var/run/nfd.sock"),
+ ndn::nfd::FACE_PERSISTENCY_PERMANENT,
+ bind([]{}),
+ bind([]{})),
+ ProtocolFactory::Error);
+
+ BOOST_CHECK_THROW(factory.createFace(FaceUri("unix:///var/run/nfd.sock"),
+ ndn::nfd::FACE_PERSISTENCY_ON_DEMAND,
+ bind([]{}),
+ bind([]{})),
+ ProtocolFactory::Error);
+
+ BOOST_CHECK_THROW(factory.createFace(FaceUri("unix:///var/run/nfd.sock"),
+ ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+ bind([]{}),
+ bind([]{})),
+ ProtocolFactory::Error);
+}
+
class EndToEndFixture : protected BaseFixture
{
public:
diff --git a/tests/daemon/face/websocket.t.cpp b/tests/daemon/face/websocket.t.cpp
index 7170e6c..d3da744 100644
--- a/tests/daemon/face/websocket.t.cpp
+++ b/tests/daemon/face/websocket.t.cpp
@@ -65,6 +65,29 @@
BOOST_CHECK_EQUAL(expectedChannels.size(), 0);
}
+BOOST_AUTO_TEST_CASE(UnsupportedFaceCreate)
+{
+ WebSocketFactory factory("19596");
+
+ BOOST_CHECK_THROW(factory.createFace(FaceUri("ws://127.0.0.1:20070"),
+ ndn::nfd::FACE_PERSISTENCY_PERMANENT,
+ bind([]{}),
+ bind([]{})),
+ ProtocolFactory::Error);
+
+ BOOST_CHECK_THROW(factory.createFace(FaceUri("ws://127.0.0.1:20070"),
+ ndn::nfd::FACE_PERSISTENCY_ON_DEMAND,
+ bind([]{}),
+ bind([]{})),
+ ProtocolFactory::Error);
+
+ BOOST_CHECK_THROW(factory.createFace(FaceUri("ws://127.0.0.1:20070"),
+ ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+ bind([]{}),
+ bind([]{})),
+ ProtocolFactory::Error);
+}
+
class EndToEndFixture : protected BaseFixture
{
public: