face: consistently use the template method pattern in ProtocolFactory
Change-Id: Ied0bf02cfcdffc7e9b2c28c5452441c01f98ccbc
diff --git a/tests/daemon/face/ethernet-factory.t.cpp b/tests/daemon/face/ethernet-factory.t.cpp
index b0351b7..b69141d 100644
--- a/tests/daemon/face/ethernet-factory.t.cpp
+++ b/tests/daemon/face/ethernet-factory.t.cpp
@@ -49,8 +49,8 @@
{
std::set<std::string> uris;
std::transform(netifs.begin(), netifs.end(), std::inserter(uris, uris.end()),
- [] (const shared_ptr<const ndn::net::NetworkInterface>& ni) {
- return FaceUri::fromDev(ni->getName()).toString();
+ [] (const auto& netif) {
+ return FaceUri::fromDev(netif->getName()).toString();
});
return uris;
}
@@ -93,7 +93,7 @@
checkChannelListEqual(factory, this->listUrisOfAvailableNetifs());
auto channels = factory.getChannels();
BOOST_CHECK(std::all_of(channels.begin(), channels.end(),
- [] (const shared_ptr<const Channel>& ch) { return ch->isListening(); }));
+ [] (const auto& ch) { return ch->isListening(); }));
BOOST_CHECK_EQUAL(this->countEtherMcastFaces(), 0);
}
@@ -119,7 +119,7 @@
checkChannelListEqual(factory, this->listUrisOfAvailableNetifs());
auto channels = factory.getChannels();
BOOST_CHECK(std::none_of(channels.begin(), channels.end(),
- [] (const shared_ptr<const Channel>& ch) { return ch->isListening(); }));
+ [] (const auto& ch) { return ch->isListening(); }));
BOOST_CHECK_EQUAL(this->countEtherMcastFaces(), 0);
}
diff --git a/tests/daemon/face/face-system-fixture.hpp b/tests/daemon/face/face-system-fixture.hpp
index b3ae91f..b7254fa 100644
--- a/tests/daemon/face/face-system-fixture.hpp
+++ b/tests/daemon/face/face-system-fixture.hpp
@@ -161,37 +161,19 @@
class DummyProtocolFactory : public ProtocolFactory
{
public:
- DummyProtocolFactory(const CtorParams& params)
- : ProtocolFactory(params)
- {
- }
+ using ProtocolFactory::ProtocolFactory;
void
- processConfig(OptionalConfigSection configSection,
- FaceSystem::ConfigContext& context) final
+ doProcessConfig(OptionalConfigSection configSection,
+ FaceSystem::ConfigContext& context) final
{
processConfigHistory.push_back({configSection, context.isDryRun,
context.generalConfig.wantCongestionMarking});
if (!context.isDryRun) {
- this->providedSchemes = this->newProvidedSchemes;
+ providedSchemes = newProvidedSchemes;
}
}
- void
- createFace(const CreateFaceRequest& req,
- const FaceCreatedCallback& onCreated,
- const FaceCreationFailedCallback& onFailure) final
- {
- BOOST_FAIL("createFace should not be called");
- }
-
- std::vector<shared_ptr<const Channel>>
- getChannels() const final
- {
- BOOST_FAIL("getChannels should not be called");
- return {};
- }
-
public:
struct ProcessConfigArgs
{
diff --git a/tests/daemon/face/tcp-factory.t.cpp b/tests/daemon/face/tcp-factory.t.cpp
index 21c49cc..d349cf9 100644
--- a/tests/daemon/face/tcp-factory.t.cpp
+++ b/tests/daemon/face/tcp-factory.t.cpp
@@ -68,7 +68,7 @@
checkChannelListEqual(factory, {"tcp4://0.0.0.0:6363", "tcp6://[::]:6363"});
auto channels = factory.getChannels();
BOOST_CHECK(std::all_of(channels.begin(), channels.end(),
- [] (const shared_ptr<const Channel>& ch) { return ch->isListening(); }));
+ [] (const auto& ch) { return ch->isListening(); }));
BOOST_CHECK_EQUAL(factory.m_local.m_whitelist.size(), 2);
BOOST_CHECK_EQUAL(factory.m_local.m_whitelist.count("127.0.0.0/8"), 1);
@@ -95,7 +95,7 @@
checkChannelListEqual(factory, {"tcp4://0.0.0.0:7001", "tcp6://[::]:7001"});
auto channels = factory.getChannels();
BOOST_CHECK(std::none_of(channels.begin(), channels.end(),
- [] (const shared_ptr<const Channel>& ch) { return ch->isListening(); }));
+ [] (const auto& ch) { return ch->isListening(); }));
}
BOOST_AUTO_TEST_CASE(DisableV4)
diff --git a/tests/daemon/face/udp-factory.t.cpp b/tests/daemon/face/udp-factory.t.cpp
index 360cc34..088b300 100644
--- a/tests/daemon/face/udp-factory.t.cpp
+++ b/tests/daemon/face/udp-factory.t.cpp
@@ -197,7 +197,7 @@
checkChannelListEqual(factory, {"udp4://0.0.0.0:6363", "udp6://[::]:6363"});
auto channels = factory.getChannels();
BOOST_CHECK(std::all_of(channels.begin(), channels.end(),
- [] (const shared_ptr<const Channel>& ch) { return ch->isListening(); }));
+ [] (const auto& ch) { return ch->isListening(); }));
}
BOOST_AUTO_TEST_CASE(DisableListen)
@@ -220,7 +220,7 @@
checkChannelListEqual(factory, {"udp4://0.0.0.0:7001", "udp6://[::]:7001"});
auto channels = factory.getChannels();
BOOST_CHECK(std::none_of(channels.begin(), channels.end(),
- [] (const shared_ptr<const Channel>& ch) { return ch->isListening(); }));
+ [] (const auto& ch) { return ch->isListening(); }));
}
BOOST_AUTO_TEST_CASE(DisableV4)
diff --git a/tests/daemon/mgmt/face-manager.t.cpp b/tests/daemon/mgmt/face-manager.t.cpp
index a08c2dc..69b2116 100644
--- a/tests/daemon/mgmt/face-manager.t.cpp
+++ b/tests/daemon/mgmt/face-manager.t.cpp
@@ -291,31 +291,8 @@
class TestProtocolFactory : public face::ProtocolFactory
{
public:
- TestProtocolFactory(const CtorParams& params)
- : ProtocolFactory(params)
- {
- }
+ using ProtocolFactory::ProtocolFactory;
- void
- processConfig(OptionalConfigSection configSection,
- FaceSystem::ConfigContext& context) final
- {
- }
-
- void
- createFace(const CreateFaceRequest& req,
- const face::FaceCreatedCallback& onCreated,
- const face::FaceCreationFailedCallback& onConnectFailed) final
- {
- }
-
- std::vector<shared_ptr<const face::Channel>>
- getChannels() const final
- {
- return m_channels;
- }
-
-public:
shared_ptr<TestChannel>
addChannel(const std::string& channelUri)
{
@@ -325,6 +302,13 @@
}
private:
+ std::vector<shared_ptr<const face::Channel>>
+ doGetChannels() const final
+ {
+ return m_channels;
+ }
+
+private:
std::vector<shared_ptr<const face::Channel>> m_channels;
};