face: Adding new 'createFace' method in all Factories
This method accepts parsed URI object and attempts to create Face on the
right channel (e.g., if hostname in URI resolved to IPv6, IPv6 TCP channel
will be used).
Factories that do not support 'createFace' operation will throw an exception.
As of this commit, *Factory::create methods are renamed to more explicit
*Factory::createChannel, and *Factory::connect to *Factory::createFace.
All other Factory-specific methods should denote what exactly is
created: channel, face, or multicast face.
Change-Id: I6396dc84c4cd8bbcdde9f55cfac90635d99e93e9
Refs: #1195
diff --git a/tests/face/ethernet.cpp b/tests/face/ethernet.cpp
index f2e7134..9322d4c 100644
--- a/tests/face/ethernet.cpp
+++ b/tests/face/ethernet.cpp
@@ -22,18 +22,21 @@
if (interfaces.size() > 0)
{
shared_ptr<EthernetFace> face1;
- BOOST_REQUIRE_NO_THROW(face1 = factory.createMulticast(interfaces[0],
- ethernet::getBroadcastAddress()));
+ BOOST_REQUIRE_NO_THROW(face1 =
+ factory.createMulticastFace(interfaces[0],
+ ethernet::getBroadcastAddress()));
shared_ptr<EthernetFace> face1bis;
- BOOST_REQUIRE_NO_THROW(face1bis = factory.createMulticast(interfaces[0],
- ethernet::getBroadcastAddress()));
+ BOOST_REQUIRE_NO_THROW(face1bis =
+ factory.createMulticastFace(interfaces[0],
+ ethernet::getBroadcastAddress()));
BOOST_CHECK_EQUAL(face1, face1bis);
if (interfaces.size() > 1)
{
shared_ptr<EthernetFace> face2;
- BOOST_REQUIRE_NO_THROW(face2 = factory.createMulticast(interfaces[1],
- ethernet::getBroadcastAddress()));
+ BOOST_REQUIRE_NO_THROW(face2 =
+ factory.createMulticastFace(interfaces[1],
+ ethernet::getBroadcastAddress()));
BOOST_CHECK_NE(face1, face2);
}
else
@@ -43,8 +46,9 @@
}
shared_ptr<EthernetFace> face3;
- BOOST_REQUIRE_NO_THROW(face3 = factory.createMulticast(interfaces[0],
- ethernet::getDefaultMulticastAddress()));
+ BOOST_REQUIRE_NO_THROW(face3 =
+ factory.createMulticastFace(interfaces[0],
+ ethernet::getDefaultMulticastAddress()));
BOOST_CHECK_NE(face1, face3);
}
else
@@ -67,7 +71,7 @@
}
shared_ptr<EthernetFace> face =
- factory.createMulticast(interfaces[0], ethernet::getDefaultMulticastAddress());
+ factory.createMulticastFace(interfaces[0], ethernet::getDefaultMulticastAddress());
BOOST_REQUIRE(static_cast<bool>(face));
BOOST_CHECK_EQUAL(face->isLocal(), false);
diff --git a/tests/face/tcp.cpp b/tests/face/tcp.cpp
index bc65c8b..b601be2 100644
--- a/tests/face/tcp.cpp
+++ b/tests/face/tcp.cpp
@@ -19,11 +19,11 @@
{
TcpFactory factory;
- shared_ptr<TcpChannel> channel1 = factory.create("127.0.0.1", "20070");
- shared_ptr<TcpChannel> channel1a = factory.create("127.0.0.1", "20070");
+ shared_ptr<TcpChannel> channel1 = factory.createChannel("127.0.0.1", "20070");
+ shared_ptr<TcpChannel> channel1a = factory.createChannel("127.0.0.1", "20070");
BOOST_CHECK_EQUAL(channel1, channel1a);
- shared_ptr<TcpChannel> channel2 = factory.create("127.0.0.1", "20071");
+ shared_ptr<TcpChannel> channel2 = factory.createChannel("127.0.0.1", "20071");
BOOST_CHECK_NE(channel1, channel2);
}
@@ -181,8 +181,8 @@
bind(&EndToEndFixture::abortTestCase, this,
"TcpChannel error: cannot connect or cannot accept connection"));
- shared_ptr<TcpChannel> channel1 = factory.create("127.0.0.1", "20070");
- shared_ptr<TcpChannel> channel2 = factory.create("127.0.0.1", "20071");
+ shared_ptr<TcpChannel> channel1 = factory.createChannel("127.0.0.1", "20070");
+ shared_ptr<TcpChannel> channel2 = factory.createChannel("127.0.0.1", "20071");
channel1->listen(bind(&EndToEndFixture::channel1_onFaceCreated, this, _1),
bind(&EndToEndFixture::channel1_onConnectFailed, this, _1));
@@ -257,8 +257,8 @@
bind(&EndToEndFixture::abortTestCase, this,
"TcpChannel error: cannot connect or cannot accept connection"));
- shared_ptr<TcpChannel> channel1 = factory.create("127.0.0.1", "20070");
- shared_ptr<TcpChannel> channel2 = factory.create("127.0.0.1", "20071");
+ shared_ptr<TcpChannel> channel1 = factory.createChannel("127.0.0.1", "20070");
+ shared_ptr<TcpChannel> channel2 = factory.createChannel("127.0.0.1", "20071");
channel1->listen(bind(&EndToEndFixture::channel_onFaceCreated, this, _1),
bind(&EndToEndFixture::channel_onConnectFailed, this, _1));
@@ -275,14 +275,14 @@
BOOST_CHECK_EQUAL(m_faces.size(), 2);
- shared_ptr<TcpChannel> channel3 = factory.create("127.0.0.1", "20072");
+ shared_ptr<TcpChannel> channel3 = factory.createChannel("127.0.0.1", "20072");
channel3->connect("127.0.0.1", "20070",
bind(&EndToEndFixture::channel_onFaceCreated, this, _1),
bind(&EndToEndFixture::channel_onConnectFailed, this, _1),
time::seconds(4)); // very short timeout
- shared_ptr<TcpChannel> channel4 = factory.create("127.0.0.1", "20073");
+ shared_ptr<TcpChannel> channel4 = factory.createChannel("127.0.0.1", "20073");
BOOST_CHECK_NE(channel3, channel4);
@@ -324,8 +324,8 @@
bind(&EndToEndFixture::abortTestCase, this,
"TcpChannel error: cannot connect or cannot accept connection"));
- shared_ptr<TcpChannel> channel1 = factory.create("127.0.0.1", "20070");
- shared_ptr<TcpChannel> channel2 = factory.create("127.0.0.1", "20071");
+ shared_ptr<TcpChannel> channel1 = factory.createChannel("127.0.0.1", "20070");
+ shared_ptr<TcpChannel> channel2 = factory.createChannel("127.0.0.1", "20071");
channel1->listen(bind(&EndToEndFixture::channel1_onFaceCreated, this, _1),
bind(&EndToEndFixture::channel1_onConnectFailed, this, _1));
diff --git a/tests/face/unix-stream.cpp b/tests/face/unix-stream.cpp
index c7cec87..beed83e 100644
--- a/tests/face/unix-stream.cpp
+++ b/tests/face/unix-stream.cpp
@@ -21,11 +21,11 @@
{
UnixStreamFactory factory;
- shared_ptr<UnixStreamChannel> channel1 = factory.create("foo");
- shared_ptr<UnixStreamChannel> channel1a = factory.create("foo");
+ shared_ptr<UnixStreamChannel> channel1 = factory.createChannel("foo");
+ shared_ptr<UnixStreamChannel> channel1a = factory.createChannel("foo");
BOOST_CHECK_EQUAL(channel1, channel1a);
- shared_ptr<UnixStreamChannel> channel2 = factory.create("bar");
+ shared_ptr<UnixStreamChannel> channel2 = factory.createChannel("bar");
BOOST_CHECK_NE(channel1, channel2);
}
@@ -147,7 +147,7 @@
bind(&EndToEndFixture::abortTestCase, this,
"UnixStreamChannel error: cannot connect or cannot accept connection"));
- shared_ptr<UnixStreamChannel> channel1 = factory.create("foo");
+ shared_ptr<UnixStreamChannel> channel1 = factory.createChannel("foo");
channel1->listen(bind(&EndToEndFixture::channel1_onFaceCreated, this, _1),
bind(&EndToEndFixture::channel1_onConnectFailed, this, _1));
@@ -217,7 +217,7 @@
bind(&EndToEndFixture::abortTestCase, this,
"UnixStreamChannel error: cannot connect or cannot accept connection"));
- shared_ptr<UnixStreamChannel> channel = factory.create("foo");
+ shared_ptr<UnixStreamChannel> channel = factory.createChannel("foo");
channel->listen(bind(&EndToEndFixture::channel_onFaceCreated, this, _1),
bind(&EndToEndFixture::channel_onConnectFailed, this, _1));
@@ -319,7 +319,7 @@
bind(&EndToEndFixture::abortTestCase, this,
"UnixStreamChannel error: cannot connect or cannot accept connection"));
- shared_ptr<UnixStreamChannel> channel1 = factory.create("foo");
+ shared_ptr<UnixStreamChannel> channel1 = factory.createChannel("foo");
channel1->listen(bind(&EndToEndFixture::channel1_onFaceCreated, this, _1),
bind(&EndToEndFixture::channel1_onConnectFailed, this, _1));