mgmt+face: move protocol-specific face creation checks into protocol factories
Also brought implementation of faces/create in line with design
refs #3731
Change-Id: I4f48079136b42c7fdbd4fdfba37116d2565f9dc1
diff --git a/tests/daemon/face/udp-factory.t.cpp b/tests/daemon/face/udp-factory.t.cpp
index be7a73b..eb27f3a 100644
--- a/tests/daemon/face/udp-factory.t.cpp
+++ b/tests/daemon/face/udp-factory.t.cpp
@@ -25,8 +25,8 @@
#include "face/udp-factory.hpp"
+#include "factory-test-common.hpp"
#include "core/network-interface.hpp"
-#include "tests/test-common.hpp"
#include "tests/limited-io.hpp"
namespace nfd {
@@ -144,61 +144,44 @@
});
}
-class FaceCreateFixture : protected BaseFixture
-{
-public:
- 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)
+BOOST_AUTO_TEST_CASE(FaceCreate)
{
UdpFactory factory = UdpFactory();
- factory.createFace(FaceUri("udp4://127.0.0.1:6363"),
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- bind([]{}),
- bind(&FaceCreateFixture::checkError, this, _1,
- "No channels available to connect to 127.0.0.1:6363"));
+ createFace(factory,
+ FaceUri("udp4://127.0.0.1:6363"),
+ ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+ {CreateFaceExpectedResult::FAILURE, 504, "No channels available to connect"});
factory.createChannel("127.0.0.1", "20071");
- factory.createFace(FaceUri("udp4://127.0.0.1:20070"),
- ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
- bind([]{}),
- bind(&FaceCreateFixture::failIfError, this, _1));
+ createFace(factory,
+ FaceUri("udp4://127.0.0.1:20070"),
+ ndn::nfd::FACE_PERSISTENCY_PERSISTENT,
+ {CreateFaceExpectedResult::SUCCESS, 0, ""});
//test the upgrade
- factory.createFace(FaceUri("udp4://127.0.0.1:20070"),
- ndn::nfd::FACE_PERSISTENCY_PERMANENT,
- bind([]{}),
- bind(&FaceCreateFixture::failIfError, this, _1));
+ createFace(factory,
+ FaceUri("udp4://127.0.0.1:20070"),
+ ndn::nfd::FACE_PERSISTENCY_PERMANENT,
+ {CreateFaceExpectedResult::SUCCESS, 0, ""});
- factory.createFace(FaceUri("udp4://127.0.0.1:20072"),
- ndn::nfd::FACE_PERSISTENCY_PERMANENT,
- bind([]{}),
- bind(&FaceCreateFixture::failIfError, this, _1));
+ createFace(factory,
+ FaceUri("udp4://127.0.0.1:20072"),
+ ndn::nfd::FACE_PERSISTENCY_PERMANENT,
+ {CreateFaceExpectedResult::SUCCESS, 0, ""});
}
BOOST_AUTO_TEST_CASE(UnsupportedFaceCreate)
{
- UdpFactory factory;
+ UdpFactory factory = UdpFactory();
factory.createChannel("127.0.0.1", "20070");
- BOOST_CHECK_THROW(factory.createFace(FaceUri("udp4://127.0.0.1:20070"),
- ndn::nfd::FACE_PERSISTENCY_ON_DEMAND,
- bind([]{}),
- bind([]{})),
- ProtocolFactory::Error);
+ createFace(factory,
+ FaceUri("udp4://127.0.0.1:20070"),
+ ndn::nfd::FACE_PERSISTENCY_ON_DEMAND,
+ {CreateFaceExpectedResult::FAILURE, 406,
+ "Outgoing unicast UDP faces do not support on-demand persistency"});
}
class FakeNetworkInterfaceFixture : public BaseFixture