face: Allow trailing slash for UDP and TCP FaceUri's
Change-Id: I472bfdaf1e032f70dbba24a0d5a3117f198a526d
Refs: #1944
diff --git a/tests/daemon/face/tcp.cpp b/tests/daemon/face/tcp.cpp
index fa527e9..80e357d 100644
--- a/tests/daemon/face/tcp.cpp
+++ b/tests/daemon/face/tcp.cpp
@@ -79,6 +79,45 @@
BOOST_CHECK_EQUAL(expectedChannels.size(), 0);
}
+class FaceCreateFixture : protected BaseFixture
+{
+public:
+ void
+ ignore()
+ {
+ }
+
+ void
+ checkError(const std::string& errorActual, const std::string& errorExpected)
+ {
+ BOOST_CHECK_EQUAL(errorActual, errorExpected);
+ }
+
+ void
+ failIfError(const std::string& errorActual)
+ {
+ BOOST_FAIL("No error expected, but got: [" << errorActual << "]");
+ }
+};
+
+BOOST_FIXTURE_TEST_CASE(FaceCreate, FaceCreateFixture)
+{
+ TcpFactory factory = TcpFactory();
+
+ factory.createFace(FaceUri("tcp4://127.0.0.1"),
+ bind(&FaceCreateFixture::ignore, this),
+ bind(&FaceCreateFixture::failIfError, this, _1));
+
+ factory.createFace(FaceUri("tcp4://127.0.0.1/"),
+ bind(&FaceCreateFixture::ignore, this),
+ bind(&FaceCreateFixture::failIfError, this, _1));
+
+ factory.createFace(FaceUri("tcp4://127.0.0.1/path"),
+ bind(&FaceCreateFixture::ignore, this),
+ bind(&FaceCreateFixture::checkError, this, _1, "Invalid URI"));
+
+}
+
class EndToEndFixture : protected BaseFixture
{
public:
diff --git a/tests/daemon/face/udp.cpp b/tests/daemon/face/udp.cpp
index 40485ca..503ec74 100644
--- a/tests/daemon/face/udp.cpp
+++ b/tests/daemon/face/udp.cpp
@@ -61,25 +61,29 @@
class FactoryErrorCheck : protected BaseFixture
{
public:
- bool isTheSameMulticastEndpoint(const UdpFactory::Error& e) {
+ bool
+ isTheSameMulticastEndpoint(const UdpFactory::Error& e) {
return strcmp(e.what(),
"Cannot create the requested UDP unicast channel, local "
"endpoint is already allocated for a UDP multicast face") == 0;
}
- bool isNotMulticastAddress(const UdpFactory::Error& e) {
+ bool
+ isNotMulticastAddress(const UdpFactory::Error& e) {
return strcmp(e.what(),
"Cannot create the requested UDP multicast face, "
"the multicast group given as input is not a multicast address") == 0;
}
- bool isTheSameUnicastEndpoint(const UdpFactory::Error& e) {
+ bool
+ isTheSameUnicastEndpoint(const UdpFactory::Error& e) {
return strcmp(e.what(),
"Cannot create the requested UDP multicast face, local "
"endpoint is already allocated for a UDP unicast channel") == 0;
}
- bool isLocalEndpointOnDifferentGroup(const UdpFactory::Error& e) {
+ bool
+ isLocalEndpointOnDifferentGroup(const UdpFactory::Error& e) {
return strcmp(e.what(),
"Cannot create the requested UDP multicast face, local "
"endpoint is already allocated for a UDP multicast face "
@@ -201,6 +205,45 @@
// UdpFactory::Error);
}
+class FaceCreateFixture : protected BaseFixture
+{
+public:
+ void
+ ignore()
+ {
+ }
+
+ void
+ checkError(const std::string& errorActual, const std::string& errorExpected)
+ {
+ BOOST_CHECK_EQUAL(errorActual, errorExpected);
+ }
+
+ void
+ failIfError(const std::string& errorActual)
+ {
+ BOOST_FAIL("No error expected, but got: [" << errorActual << "]");
+ }
+};
+
+BOOST_FIXTURE_TEST_CASE(FaceCreate, FaceCreateFixture)
+{
+ UdpFactory factory = UdpFactory();
+
+ factory.createFace(FaceUri("udp4://127.0.0.1"),
+ bind(&FaceCreateFixture::ignore, this),
+ bind(&FaceCreateFixture::failIfError, this, _1));
+
+ factory.createFace(FaceUri("udp4://127.0.0.1/"),
+ bind(&FaceCreateFixture::ignore, this),
+ bind(&FaceCreateFixture::failIfError, this, _1));
+
+ factory.createFace(FaceUri("udp4://127.0.0.1/path"),
+ bind(&FaceCreateFixture::ignore, this),
+ bind(&FaceCreateFixture::checkError, this, _1, "Invalid URI"));
+
+}
+
class EndToEndFixture : protected BaseFixture
{
public: