diff --git a/iceoryx_examples/icediscovery/iox_find_service.cpp b/iceoryx_examples/icediscovery/iox_find_service.cpp index 7cdcb63acb..645110519f 100644 --- a/iceoryx_examples/icediscovery/iox_find_service.cpp +++ b/iceoryx_examples/icediscovery/iox_find_service.cpp @@ -48,27 +48,38 @@ int main() serviceDiscovery.findService(iox::capro::IdString_t{"Radar"}, iox::capro::IdString_t{"FrontLeft"}, iox::capro::IdString_t{"Image"}, - printSearchResult); + printSearchResult, + iox::popo::MessagingPattern::PUB_SUB); //! [search for unique service] std::cout << "\nSearched for {'Radar', *, *}. Found the following services:" << std::endl; - serviceDiscovery.findService( - iox::capro::IdString_t{"Radar"}, iox::capro::Wildcard, iox::capro::Wildcard, printSearchResult); + serviceDiscovery.findService(iox::capro::IdString_t{"Radar"}, + iox::capro::Wildcard, + iox::capro::Wildcard, + printSearchResult, + iox::popo::MessagingPattern::PUB_SUB); std::cout << "\nSearched for {*, 'FrontLeft', *}. Found the following services:" << std::endl; - serviceDiscovery.findService( - iox::capro::Wildcard, iox::capro::IdString_t{"FrontLeft"}, iox::capro::Wildcard, printSearchResult); + serviceDiscovery.findService(iox::capro::Wildcard, + iox::capro::IdString_t{"FrontLeft"}, + iox::capro::Wildcard, + printSearchResult, + iox::popo::MessagingPattern::PUB_SUB); std::cout << "\nSearched for {*, 'FrontRight', 'Image'}. Found the following services:" << std::endl; serviceDiscovery.findService(iox::capro::Wildcard, iox::capro::IdString_t{"FrontRight"}, iox::capro::IdString_t{"Image"}, - printSearchResult); + printSearchResult, + iox::popo::MessagingPattern::PUB_SUB); std::cout << "\nSearched for {'Camera', *, *}. Found the following services:" << std::endl; //! [search for all Camera services] - serviceDiscovery.findService( - iox::capro::IdString_t{"Camera"}, iox::capro::Wildcard, iox::capro::Wildcard, printSearchResult); + serviceDiscovery.findService(iox::capro::IdString_t{"Camera"}, + iox::capro::Wildcard, + iox::capro::Wildcard, + printSearchResult, + iox::popo::MessagingPattern::PUB_SUB); //! [search for all Camera services] std::this_thread::sleep_for(std::chrono::seconds(1)); diff --git a/iceoryx_hoofs/include/iceoryx_hoofs/error_handling/error_handling.hpp b/iceoryx_hoofs/include/iceoryx_hoofs/error_handling/error_handling.hpp index a277a8acec..c19d196f53 100644 --- a/iceoryx_hoofs/include/iceoryx_hoofs/error_handling/error_handling.hpp +++ b/iceoryx_hoofs/include/iceoryx_hoofs/error_handling/error_handling.hpp @@ -67,6 +67,7 @@ namespace iox error(POSH__RUNTIME_NAME_EMPTY) \ error(POSH__RUNTIME_LEADING_SLASH_PROVIDED) \ error(POSH__SERVICE_DISCOVERY_UNKNOWN_EVENT_PROVIDED) \ + error(POSH__SERVICE_DISCOVERY_UNKNOWN_MESSAGE_PATTERN_PROVIDED) \ error(POSH__PORT_MANAGER_PUBLISHERPORT_NOT_UNIQUE) \ error(POSH__PORT_MANAGER_SERVERPORT_NOT_UNIQUE) \ error(POSH__PORT_MANAGER_COULD_NOT_ADD_SERVICE_TO_REGISTRY) \ diff --git a/iceoryx_posh/include/iceoryx_posh/runtime/service_discovery.hpp b/iceoryx_posh/include/iceoryx_posh/runtime/service_discovery.hpp index 170e796026..17f48c6ce7 100644 --- a/iceoryx_posh/include/iceoryx_posh/runtime/service_discovery.hpp +++ b/iceoryx_posh/include/iceoryx_posh/runtime/service_discovery.hpp @@ -24,6 +24,14 @@ namespace iox { +namespace popo +{ +enum class MessagingPattern +{ + PUB_SUB, + REQ_RES +}; +} namespace runtime { enum class ServiceDiscoveryEvent : popo::EventEnumIdentifier @@ -48,7 +56,8 @@ class ServiceDiscovery /// ServiceContainer: container that is filled with all matching instances ServiceContainer findService(const cxx::optional& service, const cxx::optional& instance, - const cxx::optional& event) noexcept; + const cxx::optional& event, + const popo::MessagingPattern pattern) noexcept; /// @brief Searches all services that match the provided service description and applies a function to each of them /// @param[in] service service string to search for, a nullopt corresponds to a wildcard @@ -58,7 +67,8 @@ class ServiceDiscovery void findService(const cxx::optional& service, const cxx::optional& instance, const cxx::optional& event, - const cxx::function_ref& callableForEach) noexcept; + const cxx::function_ref& callableForEach, + const popo::MessagingPattern pattern) noexcept; friend iox::popo::NotificationAttorney; diff --git a/iceoryx_posh/source/runtime/service_discovery.cpp b/iceoryx_posh/source/runtime/service_discovery.cpp index 99ab5a3da1..0998ed75cb 100644 --- a/iceoryx_posh/source/runtime/service_discovery.cpp +++ b/iceoryx_posh/source/runtime/service_discovery.cpp @@ -23,21 +23,22 @@ namespace runtime { ServiceContainer ServiceDiscovery::findService(const cxx::optional& service, const cxx::optional& instance, - const cxx::optional& event) noexcept + const cxx::optional& event, + const popo::MessagingPattern pattern) noexcept { ServiceContainer searchResult; auto lambda = [&](const capro::ServiceDescription& entry) { searchResult.emplace_back(entry); }; - findService(service, instance, event, lambda); + findService(service, instance, event, lambda, pattern); return searchResult; } -void ServiceDiscovery::findService( - const cxx::optional& service, - const cxx::optional& instance, - const cxx::optional& event, - const cxx::function_ref& callableForEach) noexcept +void ServiceDiscovery::findService(const cxx::optional& service, + const cxx::optional& instance, + const cxx::optional& event, + const cxx::function_ref& callableForEach, + const popo::MessagingPattern pattern) noexcept { if (!callableForEach) { @@ -48,13 +49,36 @@ void ServiceDiscovery::findService( m_serviceRegistry = *serviceRegistrySample; }); - m_serviceRegistry.find( - service, instance, event, [&](const roudi::ServiceRegistry::ServiceDescriptionEntry& serviceEntry) { - if (serviceEntry.publisherCount > 0) - { - callableForEach(serviceEntry.serviceDescription); - } - }); + switch (pattern) + { + case popo::MessagingPattern::PUB_SUB: + { + m_serviceRegistry.find( + service, instance, event, [&](const roudi::ServiceRegistry::ServiceDescriptionEntry& serviceEntry) { + if (serviceEntry.publisherCount > 0) + { + callableForEach(serviceEntry.serviceDescription); + } + }); + break; + } + case popo::MessagingPattern::REQ_RES: + { + m_serviceRegistry.find( + service, instance, event, [&](const roudi::ServiceRegistry::ServiceDescriptionEntry& serviceEntry) { + if (serviceEntry.serverCount > 0) + { + callableForEach(serviceEntry.serviceDescription); + } + }); + break; + } + default: + { + LogWarn() << "ServiceDiscovery could not perform search due to unknown MessagingPattern!"; + errorHandler(Error::kPOSH__SERVICE_DISCOVERY_UNKNOWN_MESSAGE_PATTERN_PROVIDED, nullptr, ErrorLevel::MODERATE); + } + } } void ServiceDiscovery::enableEvent(popo::TriggerHandle&& triggerHandle, const ServiceDiscoveryEvent event) noexcept @@ -68,7 +92,7 @@ void ServiceDiscovery::enableEvent(popo::TriggerHandle&& triggerHandle, const Se } default: { - LogWarn() << "ServiceDiscovery::enableEvent() called with unkown event!"; + LogWarn() << "ServiceDiscovery::enableEvent() called with unknown event!"; errorHandler(Error::kPOSH__SERVICE_DISCOVERY_UNKNOWN_EVENT_PROVIDED, nullptr, ErrorLevel::MODERATE); } } @@ -85,7 +109,7 @@ void ServiceDiscovery::disableEvent(const ServiceDiscoveryEvent event) noexcept } default: { - LogWarn() << "ServiceDiscovery::disableEvent() called with unkown event!"; + LogWarn() << "ServiceDiscovery::disableEvent() called with unknown event!"; errorHandler(Error::kPOSH__SERVICE_DISCOVERY_UNKNOWN_EVENT_PROVIDED, nullptr, ErrorLevel::MODERATE); } } diff --git a/iceoryx_posh/test/integrationtests/test_service_discovery.cpp b/iceoryx_posh/test/integrationtests/test_service_discovery.cpp index a49361963d..7766c05f42 100644 --- a/iceoryx_posh/test/integrationtests/test_service_discovery.cpp +++ b/iceoryx_posh/test/integrationtests/test_service_discovery.cpp @@ -21,6 +21,7 @@ #include "iceoryx_posh/iceoryx_posh_types.hpp" #include "iceoryx_posh/popo/listener.hpp" #include "iceoryx_posh/popo/untyped_publisher.hpp" +#include "iceoryx_posh/popo/untyped_server.hpp" #include "iceoryx_posh/popo/wait_set.hpp" #include "iceoryx_posh/runtime/posh_runtime.hpp" #include "iceoryx_posh/runtime/service_discovery.hpp" @@ -42,8 +43,24 @@ using iox::capro::ServiceDescription; using iox::roudi::RouDiEnvironment; using iox::runtime::ServiceContainer; +struct Publisher +{ + using Producer = iox::popo::UntypedPublisher; + static constexpr MessagingPattern KIND{MessagingPattern::PUB_SUB}; + static constexpr auto MAX_PRODUCERS{iox::MAX_PUBLISHERS}; + static constexpr auto MAX_USER_PRODUCERS{iox::MAX_PUBLISHERS - iox::NUMBER_OF_INTERNAL_PUBLISHERS}; +}; + +struct Server +{ + using Producer = iox::popo::UntypedServer; + static constexpr MessagingPattern KIND{MessagingPattern::REQ_RES}; + static constexpr auto MAX_PRODUCERS{iox::MAX_SERVERS}; + static constexpr auto MAX_USER_PRODUCERS{iox::MAX_SERVERS}; +}; -class ServiceDiscovery_test : public RouDi_GTest + +class ServiceDiscoveryPubSub_test : public RouDi_GTest { public: void SetUp() override @@ -74,10 +91,12 @@ class ServiceDiscovery_test : public RouDi_GTest callbackWasCalled = true; } - static void searchForService(ServiceDiscovery* const serviceDiscovery, ServiceDescription* service) + static void searchForPublisher(ServiceDiscovery* const serviceDiscovery, ServiceDescription* service) { - serviceContainer = serviceDiscovery->findService( - service->getServiceIDString(), service->getInstanceIDString(), service->getEventIDString()); + serviceContainer = serviceDiscovery->findService(service->getServiceIDString(), + service->getInstanceIDString(), + service->getEventIDString(), + MessagingPattern::PUB_SUB); callbackWasCalled = true; } @@ -85,9 +104,17 @@ class ServiceDiscovery_test : public RouDi_GTest Watchdog m_watchdog{m_fatalTimeout}; }; -std::atomic_bool ServiceDiscovery_test::callbackWasCalled{false}; -ServiceContainer ServiceDiscovery_test::serviceContainer; -ServiceContainer ServiceDiscovery_test::searchResultOfFindServiceWithFindHandler; +std::atomic_bool ServiceDiscoveryPubSub_test::callbackWasCalled{false}; +ServiceContainer ServiceDiscoveryPubSub_test::serviceContainer; +ServiceContainer ServiceDiscoveryPubSub_test::searchResultOfFindServiceWithFindHandler; + +template +class ServiceDiscovery_test : public ServiceDiscoveryPubSub_test +{ + public: + using CommunicationKind = T; +}; + void compareAndClearServiceContainers(ServiceContainer& lhs, ServiceContainer& rhs) { @@ -101,348 +128,400 @@ void compareAndClearServiceContainers(ServiceContainer& lhs, ServiceContainer& r rhs.clear(); } -TEST_F(ServiceDiscovery_test, FindServiceWithWildcardsReturnsOnlyIntrospectionServicesAndServiceRegistry) -{ - ::testing::Test::RecordProperty("TEST_ID", "d944f32c-edef-44f5-a6eb-c19ee73c98eb"); - auto searchResult = sut.findService(iox::capro::Wildcard, iox::capro::Wildcard, iox::capro::Wildcard); - - - for (auto& service : searchResult) - { - EXPECT_THAT(service.getInstanceIDString().c_str(), StrEq("RouDi_ID")); - } +/// +/// Publish-Subscribe || Request-Response +/// - sut.findService(iox::capro::Wildcard, iox::capro::Wildcard, iox::capro::Wildcard, findHandler); - compareAndClearServiceContainers(searchResult, searchResultOfFindServiceWithFindHandler); -} +using CommunicationKind = Types; +TYPED_TEST_SUITE(ServiceDiscovery_test, CommunicationKind); -TEST_F(ServiceDiscovery_test, FindServiceReturnsOfferedService) +TYPED_TEST(ServiceDiscovery_test, FindServiceReturnsOfferedService) { ::testing::Test::RecordProperty("TEST_ID", "30f0e255-3584-4ab2-b7a6-85c16026852d"); const iox::capro::ServiceDescription SERVICE_DESCRIPTION("service", "instance", "event"); - iox::popo::UntypedPublisher publisher(SERVICE_DESCRIPTION); - auto serviceContainer = sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), - SERVICE_DESCRIPTION.getInstanceIDString(), - SERVICE_DESCRIPTION.getEventIDString()); + typename TestFixture::CommunicationKind::Producer producer(SERVICE_DESCRIPTION); + + auto serviceContainer = this->sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), + SERVICE_DESCRIPTION.getInstanceIDString(), + SERVICE_DESCRIPTION.getEventIDString(), + TestFixture::CommunicationKind::KIND); ASSERT_THAT(serviceContainer.size(), Eq(1U)); EXPECT_THAT(*serviceContainer.begin(), Eq(SERVICE_DESCRIPTION)); - sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), - SERVICE_DESCRIPTION.getInstanceIDString(), - SERVICE_DESCRIPTION.getEventIDString(), - findHandler); - compareAndClearServiceContainers(serviceContainer, searchResultOfFindServiceWithFindHandler); + this->sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), + SERVICE_DESCRIPTION.getInstanceIDString(), + SERVICE_DESCRIPTION.getEventIDString(), + this->findHandler, + TestFixture::CommunicationKind::KIND); + compareAndClearServiceContainers(serviceContainer, this->searchResultOfFindServiceWithFindHandler); } -TEST_F(ServiceDiscovery_test, ReofferedServiceWithValidServiceDescriptionCanBeFound) +TYPED_TEST(ServiceDiscovery_test, ReofferedServiceWithServiceDescriptionCanBeFound) { ::testing::Test::RecordProperty("TEST_ID", "b67b4990-e2fd-4efa-ab5d-e53c4ee55972"); const iox::capro::ServiceDescription SERVICE_DESCRIPTION("service", "instance", "event"); - iox::popo::UntypedPublisher publisher(SERVICE_DESCRIPTION); + typename TestFixture::CommunicationKind::Producer producer(SERVICE_DESCRIPTION); - auto serviceContainer = sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), - SERVICE_DESCRIPTION.getInstanceIDString(), - SERVICE_DESCRIPTION.getEventIDString()); + auto serviceContainer = this->sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), + SERVICE_DESCRIPTION.getInstanceIDString(), + SERVICE_DESCRIPTION.getEventIDString(), + TestFixture::CommunicationKind::KIND); ASSERT_THAT(serviceContainer.size(), Eq(1U)); EXPECT_THAT(*serviceContainer.begin(), Eq(SERVICE_DESCRIPTION)); - sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), - SERVICE_DESCRIPTION.getInstanceIDString(), - SERVICE_DESCRIPTION.getEventIDString(), - findHandler); - compareAndClearServiceContainers(serviceContainer, searchResultOfFindServiceWithFindHandler); - - publisher.stopOffer(); + this->sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), + SERVICE_DESCRIPTION.getInstanceIDString(), + SERVICE_DESCRIPTION.getEventIDString(), + this->findHandler, + TestFixture::CommunicationKind::KIND); + compareAndClearServiceContainers(serviceContainer, this->searchResultOfFindServiceWithFindHandler); + + producer.stopOffer(); this->InterOpWait(); - serviceContainer = sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), - SERVICE_DESCRIPTION.getInstanceIDString(), - SERVICE_DESCRIPTION.getEventIDString()); + serviceContainer = this->sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), + SERVICE_DESCRIPTION.getInstanceIDString(), + SERVICE_DESCRIPTION.getEventIDString(), + TestFixture::CommunicationKind::KIND); EXPECT_TRUE(serviceContainer.empty()); - sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), - SERVICE_DESCRIPTION.getInstanceIDString(), - SERVICE_DESCRIPTION.getEventIDString(), - findHandler); - EXPECT_TRUE(searchResultOfFindServiceWithFindHandler.empty()); - - publisher.offer(); + this->sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), + SERVICE_DESCRIPTION.getInstanceIDString(), + SERVICE_DESCRIPTION.getEventIDString(), + this->findHandler, + TestFixture::CommunicationKind::KIND); + EXPECT_TRUE(this->searchResultOfFindServiceWithFindHandler.empty()); + + producer.offer(); this->InterOpWait(); - serviceContainer = sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), - SERVICE_DESCRIPTION.getInstanceIDString(), - SERVICE_DESCRIPTION.getEventIDString()); + serviceContainer = this->sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), + SERVICE_DESCRIPTION.getInstanceIDString(), + SERVICE_DESCRIPTION.getEventIDString(), + TestFixture::CommunicationKind::KIND); ASSERT_THAT(serviceContainer.size(), Eq(1U)); EXPECT_THAT(*serviceContainer.begin(), Eq(SERVICE_DESCRIPTION)); - sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), - SERVICE_DESCRIPTION.getInstanceIDString(), - SERVICE_DESCRIPTION.getEventIDString(), - findHandler); - compareAndClearServiceContainers(serviceContainer, searchResultOfFindServiceWithFindHandler); + this->sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), + SERVICE_DESCRIPTION.getInstanceIDString(), + SERVICE_DESCRIPTION.getEventIDString(), + this->findHandler, + TestFixture::CommunicationKind::KIND); + compareAndClearServiceContainers(serviceContainer, this->searchResultOfFindServiceWithFindHandler); } -TEST_F(ServiceDiscovery_test, OfferExistingServiceMultipleTimesIsRedundant) +TYPED_TEST(ServiceDiscovery_test, OfferExistingServiceMultipleTimesIsRedundant) { ::testing::Test::RecordProperty("TEST_ID", "ae0790ed-4e1b-4f12-94b3-c9e56433c935"); const iox::capro::ServiceDescription SERVICE_DESCRIPTION("service", "instance", "event"); - iox::popo::UntypedPublisher publisher(SERVICE_DESCRIPTION); - publisher.offer(); + typename TestFixture::CommunicationKind::Producer producer(SERVICE_DESCRIPTION); + producer.offer(); this->InterOpWait(); - auto serviceContainer = sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), - SERVICE_DESCRIPTION.getInstanceIDString(), - SERVICE_DESCRIPTION.getEventIDString()); + auto serviceContainer = this->sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), + SERVICE_DESCRIPTION.getInstanceIDString(), + SERVICE_DESCRIPTION.getEventIDString(), + TestFixture::CommunicationKind::KIND); ASSERT_THAT(serviceContainer.size(), Eq(1U)); EXPECT_THAT(*serviceContainer.begin(), Eq(SERVICE_DESCRIPTION)); - sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), - SERVICE_DESCRIPTION.getInstanceIDString(), - SERVICE_DESCRIPTION.getEventIDString(), - findHandler); - compareAndClearServiceContainers(serviceContainer, searchResultOfFindServiceWithFindHandler); + this->sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), + SERVICE_DESCRIPTION.getInstanceIDString(), + SERVICE_DESCRIPTION.getEventIDString(), + this->findHandler, + TestFixture::CommunicationKind::KIND); + compareAndClearServiceContainers(serviceContainer, this->searchResultOfFindServiceWithFindHandler); } -TEST_F(ServiceDiscovery_test, FindSameServiceMultipleTimesReturnsSingleInstance) +TYPED_TEST(ServiceDiscovery_test, FindSameServiceMultipleTimesReturnsSingleInstance) { ::testing::Test::RecordProperty("TEST_ID", "21948bcf-fe7e-44b4-b93b-f46303e3e050"); const iox::capro::ServiceDescription SERVICE_DESCRIPTION("service", "instance", "event"); - iox::popo::UntypedPublisher publisher(SERVICE_DESCRIPTION); + typename TestFixture::CommunicationKind::Producer producer(SERVICE_DESCRIPTION); - auto serviceContainer = sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), - SERVICE_DESCRIPTION.getInstanceIDString(), - SERVICE_DESCRIPTION.getEventIDString()); + auto serviceContainer = this->sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), + SERVICE_DESCRIPTION.getInstanceIDString(), + SERVICE_DESCRIPTION.getEventIDString(), + TestFixture::CommunicationKind::KIND); ASSERT_THAT(serviceContainer.size(), Eq(1U)); EXPECT_THAT(*serviceContainer.begin(), Eq(SERVICE_DESCRIPTION)); - sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), - SERVICE_DESCRIPTION.getInstanceIDString(), - SERVICE_DESCRIPTION.getEventIDString(), - findHandler); - compareAndClearServiceContainers(serviceContainer, searchResultOfFindServiceWithFindHandler); - - serviceContainer = sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), - SERVICE_DESCRIPTION.getInstanceIDString(), - SERVICE_DESCRIPTION.getEventIDString()); + this->sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), + SERVICE_DESCRIPTION.getInstanceIDString(), + SERVICE_DESCRIPTION.getEventIDString(), + this->findHandler, + TestFixture::CommunicationKind::KIND); + compareAndClearServiceContainers(serviceContainer, this->searchResultOfFindServiceWithFindHandler); + + serviceContainer = this->sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), + SERVICE_DESCRIPTION.getInstanceIDString(), + SERVICE_DESCRIPTION.getEventIDString(), + TestFixture::CommunicationKind::KIND); ASSERT_THAT(serviceContainer.size(), Eq(1U)); EXPECT_THAT(*serviceContainer.begin(), Eq(SERVICE_DESCRIPTION)); - sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), - SERVICE_DESCRIPTION.getInstanceIDString(), - SERVICE_DESCRIPTION.getEventIDString(), - findHandler); - compareAndClearServiceContainers(serviceContainer, searchResultOfFindServiceWithFindHandler); + this->sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), + SERVICE_DESCRIPTION.getInstanceIDString(), + SERVICE_DESCRIPTION.getEventIDString(), + this->findHandler, + TestFixture::CommunicationKind::KIND); + compareAndClearServiceContainers(serviceContainer, this->searchResultOfFindServiceWithFindHandler); } -TEST_F(ServiceDiscovery_test, OfferDifferentServicesWithSameInstanceAndEvent) +TYPED_TEST(ServiceDiscovery_test, OfferDifferentServicesWithSameInstanceAndEvent) { ::testing::Test::RecordProperty("TEST_ID", "25bf794d-450e-47ce-a920-ab2ea479af39"); const IdString_t INSTANCE = "instance"; const IdString_t EVENT = "event"; const iox::capro::ServiceDescription SERVICE_DESCRIPTION1("service1", INSTANCE, EVENT); - iox::popo::UntypedPublisher publisher_sd1(SERVICE_DESCRIPTION1); + typename TestFixture::CommunicationKind::Producer producer_sd1(SERVICE_DESCRIPTION1); const iox::capro::ServiceDescription SERVICE_DESCRIPTION2("service2", INSTANCE, EVENT); - iox::popo::UntypedPublisher publisher_sd2(SERVICE_DESCRIPTION2); + typename TestFixture::CommunicationKind::Producer producer_sd2(SERVICE_DESCRIPTION2); const iox::capro::ServiceDescription SERVICE_DESCRIPTION3("service3", INSTANCE, EVENT); - iox::popo::UntypedPublisher publisher_sd3(SERVICE_DESCRIPTION3); + typename TestFixture::CommunicationKind::Producer producer_sd3(SERVICE_DESCRIPTION3); - auto serviceContainer = sut.findService(SERVICE_DESCRIPTION1.getServiceIDString(), INSTANCE, EVENT); + auto serviceContainer = this->sut.findService( + SERVICE_DESCRIPTION1.getServiceIDString(), INSTANCE, EVENT, TestFixture::CommunicationKind::KIND); ASSERT_THAT(serviceContainer.size(), Eq(1U)); EXPECT_THAT(*serviceContainer.begin(), Eq(SERVICE_DESCRIPTION1)); - sut.findService(SERVICE_DESCRIPTION1.getServiceIDString(), INSTANCE, EVENT, findHandler); - compareAndClearServiceContainers(serviceContainer, searchResultOfFindServiceWithFindHandler); - - serviceContainer = sut.findService(SERVICE_DESCRIPTION2.getServiceIDString(), INSTANCE, EVENT); + this->sut.findService(SERVICE_DESCRIPTION1.getServiceIDString(), + INSTANCE, + EVENT, + this->findHandler, + TestFixture::CommunicationKind::KIND); + compareAndClearServiceContainers(serviceContainer, this->searchResultOfFindServiceWithFindHandler); + + serviceContainer = this->sut.findService( + SERVICE_DESCRIPTION2.getServiceIDString(), INSTANCE, EVENT, TestFixture::CommunicationKind::KIND); ASSERT_THAT(serviceContainer.size(), Eq(1U)); EXPECT_THAT(*serviceContainer.begin(), Eq(SERVICE_DESCRIPTION2)); - sut.findService(SERVICE_DESCRIPTION2.getServiceIDString(), INSTANCE, EVENT, findHandler); - compareAndClearServiceContainers(serviceContainer, searchResultOfFindServiceWithFindHandler); - serviceContainer = sut.findService(SERVICE_DESCRIPTION3.getServiceIDString(), INSTANCE, EVENT); + this->sut.findService(SERVICE_DESCRIPTION2.getServiceIDString(), + INSTANCE, + EVENT, + this->findHandler, + TestFixture::CommunicationKind::KIND); + compareAndClearServiceContainers(serviceContainer, this->searchResultOfFindServiceWithFindHandler); + + serviceContainer = this->sut.findService( + SERVICE_DESCRIPTION3.getServiceIDString(), INSTANCE, EVENT, TestFixture::CommunicationKind::KIND); ASSERT_THAT(serviceContainer.size(), Eq(1U)); EXPECT_THAT(*serviceContainer.begin(), Eq(SERVICE_DESCRIPTION3)); - sut.findService(SERVICE_DESCRIPTION3.getServiceIDString(), INSTANCE, EVENT, findHandler); - compareAndClearServiceContainers(serviceContainer, searchResultOfFindServiceWithFindHandler); + this->sut.findService(SERVICE_DESCRIPTION3.getServiceIDString(), + INSTANCE, + EVENT, + this->findHandler, + TestFixture::CommunicationKind::KIND); + compareAndClearServiceContainers(serviceContainer, this->searchResultOfFindServiceWithFindHandler); } -TEST_F(ServiceDiscovery_test, FindServiceDoesNotReturnServiceWhenStringsDoNotMatch) +TYPED_TEST(ServiceDiscovery_test, FindServiceDoesNotReturnServiceWhenStringsDoNotMatch) { ::testing::Test::RecordProperty("TEST_ID", "1984e907-e990-48b2-8cbd-eab3f67cd162"); const iox::capro::ServiceDescription SERVICE_DESCRIPTION1("service1", "instance1", "event1"); - iox::popo::UntypedPublisher publisher_sd1(SERVICE_DESCRIPTION1); + typename TestFixture::CommunicationKind::Producer producer_sd1(SERVICE_DESCRIPTION1); const iox::capro::ServiceDescription SERVICE_DESCRIPTION2("service2", "instance2", "event2"); - iox::popo::UntypedPublisher publisher_sd2(SERVICE_DESCRIPTION2); + typename TestFixture::CommunicationKind::Producer producer_sd2(SERVICE_DESCRIPTION2); - auto serviceContainer = sut.findService(SERVICE_DESCRIPTION1.getServiceIDString(), - SERVICE_DESCRIPTION1.getInstanceIDString(), - SERVICE_DESCRIPTION2.getEventIDString()); + auto serviceContainer = this->sut.findService(SERVICE_DESCRIPTION1.getServiceIDString(), + SERVICE_DESCRIPTION1.getInstanceIDString(), + SERVICE_DESCRIPTION2.getEventIDString(), + TestFixture::CommunicationKind::KIND); ASSERT_THAT(serviceContainer.size(), Eq(0U)); - sut.findService(SERVICE_DESCRIPTION1.getServiceIDString(), - SERVICE_DESCRIPTION1.getInstanceIDString(), - SERVICE_DESCRIPTION2.getEventIDString(), - findHandler); - EXPECT_TRUE(searchResultOfFindServiceWithFindHandler.empty()); - - serviceContainer = sut.findService(SERVICE_DESCRIPTION1.getServiceIDString(), - SERVICE_DESCRIPTION2.getInstanceIDString(), - SERVICE_DESCRIPTION1.getEventIDString()); + this->sut.findService(SERVICE_DESCRIPTION1.getServiceIDString(), + SERVICE_DESCRIPTION1.getInstanceIDString(), + SERVICE_DESCRIPTION2.getEventIDString(), + this->findHandler, + TestFixture::CommunicationKind::KIND); + EXPECT_TRUE(this->searchResultOfFindServiceWithFindHandler.empty()); + + serviceContainer = this->sut.findService(SERVICE_DESCRIPTION1.getServiceIDString(), + SERVICE_DESCRIPTION2.getInstanceIDString(), + SERVICE_DESCRIPTION1.getEventIDString(), + TestFixture::CommunicationKind::KIND); EXPECT_THAT(serviceContainer.size(), Eq(0U)); - sut.findService(SERVICE_DESCRIPTION1.getServiceIDString(), - SERVICE_DESCRIPTION2.getInstanceIDString(), - SERVICE_DESCRIPTION1.getEventIDString(), - findHandler); - EXPECT_TRUE(searchResultOfFindServiceWithFindHandler.empty()); - - serviceContainer = sut.findService(SERVICE_DESCRIPTION1.getServiceIDString(), - SERVICE_DESCRIPTION2.getInstanceIDString(), - SERVICE_DESCRIPTION2.getEventIDString()); + this->sut.findService(SERVICE_DESCRIPTION1.getServiceIDString(), + SERVICE_DESCRIPTION2.getInstanceIDString(), + SERVICE_DESCRIPTION1.getEventIDString(), + this->findHandler, + TestFixture::CommunicationKind::KIND); + EXPECT_TRUE(this->searchResultOfFindServiceWithFindHandler.empty()); + + serviceContainer = this->sut.findService(SERVICE_DESCRIPTION1.getServiceIDString(), + SERVICE_DESCRIPTION2.getInstanceIDString(), + SERVICE_DESCRIPTION2.getEventIDString(), + TestFixture::CommunicationKind::KIND); EXPECT_THAT(serviceContainer.size(), Eq(0U)); - sut.findService(SERVICE_DESCRIPTION1.getServiceIDString(), - SERVICE_DESCRIPTION2.getInstanceIDString(), - SERVICE_DESCRIPTION2.getEventIDString(), - findHandler); - EXPECT_TRUE(searchResultOfFindServiceWithFindHandler.empty()); + this->sut.findService(SERVICE_DESCRIPTION1.getServiceIDString(), + SERVICE_DESCRIPTION2.getInstanceIDString(), + SERVICE_DESCRIPTION2.getEventIDString(), + this->findHandler, + TestFixture::CommunicationKind::KIND); + EXPECT_TRUE(this->searchResultOfFindServiceWithFindHandler.empty()); } -TEST_F(ServiceDiscovery_test, FindServiceWithInstanceAndEventWildcardReturnsAllMatchingServices) +TYPED_TEST(ServiceDiscovery_test, FindServiceWithInstanceAndEventWildcardReturnsAllMatchingServices) { ::testing::Test::RecordProperty("TEST_ID", "6e0b1a12-6995-45f4-8fd8-59acbca9bfa8"); const IdString_t SERVICE = "service"; const iox::capro::ServiceDescription SERVICE_DESCRIPTION1(SERVICE, "instance1", "event1"); - iox::popo::UntypedPublisher publisher_sd1(SERVICE_DESCRIPTION1); + typename TestFixture::CommunicationKind::Producer producer_sd1(SERVICE_DESCRIPTION1); const iox::capro::ServiceDescription SERVICE_DESCRIPTION2(SERVICE, "instance2", "event2"); - iox::popo::UntypedPublisher publisher_sd2(SERVICE_DESCRIPTION2); + typename TestFixture::CommunicationKind::Producer producer_sd2(SERVICE_DESCRIPTION2); const iox::capro::ServiceDescription SERVICE_DESCRIPTION3(SERVICE, "instance3", "event3"); - iox::popo::UntypedPublisher publisher_sd3(SERVICE_DESCRIPTION3); + typename TestFixture::CommunicationKind::Producer producer_sd3(SERVICE_DESCRIPTION3); ServiceContainer serviceContainerExp; serviceContainerExp.push_back(SERVICE_DESCRIPTION1); serviceContainerExp.push_back(SERVICE_DESCRIPTION2); serviceContainerExp.push_back(SERVICE_DESCRIPTION3); - auto serviceContainer = sut.findService(SERVICE, iox::capro::Wildcard, iox::capro::Wildcard); + auto serviceContainer = this->sut.findService( + SERVICE, iox::capro::Wildcard, iox::capro::Wildcard, TestFixture::CommunicationKind::KIND); ASSERT_THAT(serviceContainer.size(), Eq(3U)); EXPECT_TRUE(serviceContainer == serviceContainerExp); - sut.findService(SERVICE, iox::capro::Wildcard, iox::capro::Wildcard, findHandler); - EXPECT_TRUE(searchResultOfFindServiceWithFindHandler == serviceContainerExp); + this->sut.findService( + SERVICE, iox::capro::Wildcard, iox::capro::Wildcard, this->findHandler, TestFixture::CommunicationKind::KIND); + EXPECT_TRUE(this->searchResultOfFindServiceWithFindHandler == serviceContainerExp); } -TEST_F(ServiceDiscovery_test, FindServiceWithServiceWildcardReturnsCorrectServices) +TYPED_TEST(ServiceDiscovery_test, FindServiceWithServiceWildcardReturnsCorrectServices) { ::testing::Test::RecordProperty("TEST_ID", "f4731a52-39d8-4d49-b247-008a2e9181f9"); const IdString_t INSTANCE = "instance"; const IdString_t EVENT = "event"; const iox::capro::ServiceDescription SERVICE_DESCRIPTION1("service1", INSTANCE, EVENT); - iox::popo::UntypedPublisher publisher_sd1(SERVICE_DESCRIPTION1); + typename TestFixture::CommunicationKind::Producer producer_sd1(SERVICE_DESCRIPTION1); const iox::capro::ServiceDescription SERVICE_DESCRIPTION2("service2", "another_instance", EVENT); - iox::popo::UntypedPublisher publisher_sd2(SERVICE_DESCRIPTION2); + typename TestFixture::CommunicationKind::Producer producer_sd2(SERVICE_DESCRIPTION2); const iox::capro::ServiceDescription SERVICE_DESCRIPTION3("service3", INSTANCE, EVENT); - iox::popo::UntypedPublisher publisher_sd3(SERVICE_DESCRIPTION3); + typename TestFixture::CommunicationKind::Producer producer_sd3(SERVICE_DESCRIPTION3); const iox::capro::ServiceDescription SERVICE_DESCRIPTION4("service4", INSTANCE, "another_event"); - iox::popo::UntypedPublisher publisher_sd4(SERVICE_DESCRIPTION4); + typename TestFixture::CommunicationKind::Producer producer_sd4(SERVICE_DESCRIPTION4); ServiceContainer serviceContainerExp; serviceContainerExp.push_back(SERVICE_DESCRIPTION1); serviceContainerExp.push_back(SERVICE_DESCRIPTION3); - auto serviceContainer = sut.findService(iox::capro::Wildcard, INSTANCE, EVENT); + auto serviceContainer = + this->sut.findService(iox::capro::Wildcard, INSTANCE, EVENT, TestFixture::CommunicationKind::KIND); ASSERT_THAT(serviceContainer.size(), Eq(2U)); EXPECT_TRUE(serviceContainer == serviceContainerExp); - sut.findService(iox::capro::Wildcard, INSTANCE, EVENT, findHandler); - EXPECT_TRUE(searchResultOfFindServiceWithFindHandler == serviceContainerExp); + this->sut.findService( + iox::capro::Wildcard, INSTANCE, EVENT, this->findHandler, TestFixture::CommunicationKind::KIND); + EXPECT_TRUE(this->searchResultOfFindServiceWithFindHandler == serviceContainerExp); } -TEST_F(ServiceDiscovery_test, FindServiceWithEventWildcardReturnsCorrectServices) +TYPED_TEST(ServiceDiscovery_test, FindServiceWithEventWildcardReturnsCorrectServices) { ::testing::Test::RecordProperty("TEST_ID", "e78b35f4-b3c3-4c39-b10a-67712c72e28a"); const IdString_t SERVICE = "service"; const IdString_t INSTANCE = "instance"; const iox::capro::ServiceDescription SERVICE_DESCRIPTION1(SERVICE, INSTANCE, "event1"); - iox::popo::UntypedPublisher publisher_sd1(SERVICE_DESCRIPTION1); + typename TestFixture::CommunicationKind::Producer producer_sd1(SERVICE_DESCRIPTION1); const iox::capro::ServiceDescription SERVICE_DESCRIPTION2("another_service", INSTANCE, "event2"); - iox::popo::UntypedPublisher publisher_sd2(SERVICE_DESCRIPTION2); + typename TestFixture::CommunicationKind::Producer producer_sd2(SERVICE_DESCRIPTION2); const iox::capro::ServiceDescription SERVICE_DESCRIPTION3(SERVICE, INSTANCE, "event3"); - iox::popo::UntypedPublisher publisher_sd3(SERVICE_DESCRIPTION3); + typename TestFixture::CommunicationKind::Producer producer_sd3(SERVICE_DESCRIPTION3); const iox::capro::ServiceDescription SERVICE_DESCRIPTION4(SERVICE, "another_instance", "event4"); - iox::popo::UntypedPublisher publisher_sd4(SERVICE_DESCRIPTION4); + typename TestFixture::CommunicationKind::Producer producer_sd4(SERVICE_DESCRIPTION4); ServiceContainer serviceContainerExp; serviceContainerExp.push_back(SERVICE_DESCRIPTION1); serviceContainerExp.push_back(SERVICE_DESCRIPTION3); - auto serviceContainer = sut.findService(SERVICE, INSTANCE, iox::capro::Wildcard); + auto serviceContainer = + this->sut.findService(SERVICE, INSTANCE, iox::capro::Wildcard, TestFixture::CommunicationKind::KIND); ASSERT_THAT(serviceContainer.size(), Eq(2U)); EXPECT_TRUE(serviceContainer == serviceContainerExp); - sut.findService(SERVICE, INSTANCE, iox::capro::Wildcard, findHandler); - EXPECT_TRUE(searchResultOfFindServiceWithFindHandler == serviceContainerExp); + this->sut.findService( + SERVICE, INSTANCE, iox::capro::Wildcard, this->findHandler, TestFixture::CommunicationKind::KIND); + EXPECT_TRUE(this->searchResultOfFindServiceWithFindHandler == serviceContainerExp); } -TEST_F(ServiceDiscovery_test, FindServiceWithInstanceWildcardReturnsCorrectServices) +TYPED_TEST(ServiceDiscovery_test, FindServiceWithInstanceWildcardReturnsCorrectServices) { ::testing::Test::RecordProperty("TEST_ID", "2ec4b422-3ded-4af3-9e72-3b870c55031c"); const IdString_t SERVICE = "service"; const IdString_t EVENT = "event"; const iox::capro::ServiceDescription SERVICE_DESCRIPTION1(SERVICE, "instance1", EVENT); - iox::popo::UntypedPublisher publisher_sd1(SERVICE_DESCRIPTION1); + typename TestFixture::CommunicationKind::Producer producer_sd1(SERVICE_DESCRIPTION1); const iox::capro::ServiceDescription SERVICE_DESCRIPTION2("another_service", "instance2", EVENT); - iox::popo::UntypedPublisher publisher_sd2(SERVICE_DESCRIPTION2); + typename TestFixture::CommunicationKind::Producer producer_sd2(SERVICE_DESCRIPTION2); const iox::capro::ServiceDescription SERVICE_DESCRIPTION3(SERVICE, "instance3", EVENT); - iox::popo::UntypedPublisher publisher_sd3(SERVICE_DESCRIPTION3); + typename TestFixture::CommunicationKind::Producer producer_sd3(SERVICE_DESCRIPTION3); const iox::capro::ServiceDescription SERVICE_DESCRIPTION4(SERVICE, "instance4", "another_event"); - iox::popo::UntypedPublisher publisher_sd4(SERVICE_DESCRIPTION4); + typename TestFixture::CommunicationKind::Producer producer_sd4(SERVICE_DESCRIPTION4); ServiceContainer serviceContainerExp; serviceContainerExp.push_back(SERVICE_DESCRIPTION1); serviceContainerExp.push_back(SERVICE_DESCRIPTION3); - auto serviceContainer = sut.findService(SERVICE, iox::capro::Wildcard, EVENT); + auto serviceContainer = + this->sut.findService(SERVICE, iox::capro::Wildcard, EVENT, TestFixture::CommunicationKind::KIND); ASSERT_THAT(serviceContainer.size(), Eq(2U)); EXPECT_TRUE(serviceContainer == serviceContainerExp); - sut.findService(SERVICE, iox::capro::Wildcard, EVENT, findHandler); - EXPECT_TRUE(searchResultOfFindServiceWithFindHandler == serviceContainerExp); + this->sut.findService( + SERVICE, iox::capro::Wildcard, EVENT, this->findHandler, TestFixture::CommunicationKind::KIND); + EXPECT_TRUE(this->searchResultOfFindServiceWithFindHandler == serviceContainerExp); } -TEST_F(ServiceDiscovery_test, OfferSingleServiceMultiInstance) +TYPED_TEST(ServiceDiscovery_test, OfferSingleServiceMultiInstance) { ::testing::Test::RecordProperty("TEST_ID", "538bec69-ea02-400e-8643-c833d6e84972"); const IdString_t SERVICE = "service"; const iox::capro::ServiceDescription SERVICE_DESCRIPTION1(SERVICE, "instance1", "event1"); - iox::popo::UntypedPublisher publisher_sd1(SERVICE_DESCRIPTION1); + typename TestFixture::CommunicationKind::Producer producer_sd1(SERVICE_DESCRIPTION1); const iox::capro::ServiceDescription SERVICE_DESCRIPTION2(SERVICE, "instance2", "event2"); - iox::popo::UntypedPublisher publisher_sd2(SERVICE_DESCRIPTION2); + typename TestFixture::CommunicationKind::Producer producer_sd2(SERVICE_DESCRIPTION2); const iox::capro::ServiceDescription SERVICE_DESCRIPTION3(SERVICE, "instance3", "event3"); - iox::popo::UntypedPublisher publisher_sd3(SERVICE_DESCRIPTION3); + typename TestFixture::CommunicationKind::Producer producer_sd3(SERVICE_DESCRIPTION3); - auto serviceContainer = - sut.findService(SERVICE, SERVICE_DESCRIPTION1.getInstanceIDString(), SERVICE_DESCRIPTION1.getEventIDString()); + auto serviceContainer = this->sut.findService(SERVICE, + SERVICE_DESCRIPTION1.getInstanceIDString(), + SERVICE_DESCRIPTION1.getEventIDString(), + TestFixture::CommunicationKind::KIND); ASSERT_THAT(serviceContainer.size(), Eq(1U)); EXPECT_THAT(*serviceContainer.begin(), Eq(SERVICE_DESCRIPTION1)); - sut.findService( - SERVICE, SERVICE_DESCRIPTION1.getInstanceIDString(), SERVICE_DESCRIPTION1.getEventIDString(), findHandler); - compareAndClearServiceContainers(serviceContainer, searchResultOfFindServiceWithFindHandler); - - serviceContainer = - sut.findService(SERVICE, SERVICE_DESCRIPTION2.getInstanceIDString(), SERVICE_DESCRIPTION2.getEventIDString()); + this->sut.findService(SERVICE, + SERVICE_DESCRIPTION1.getInstanceIDString(), + SERVICE_DESCRIPTION1.getEventIDString(), + this->findHandler, + TestFixture::CommunicationKind::KIND); + compareAndClearServiceContainers(serviceContainer, this->searchResultOfFindServiceWithFindHandler); + + serviceContainer = this->sut.findService(SERVICE, + SERVICE_DESCRIPTION2.getInstanceIDString(), + SERVICE_DESCRIPTION2.getEventIDString(), + TestFixture::CommunicationKind::KIND); ASSERT_THAT(serviceContainer.size(), Eq(1U)); EXPECT_THAT(*serviceContainer.begin(), Eq(SERVICE_DESCRIPTION2)); - sut.findService( - SERVICE, SERVICE_DESCRIPTION2.getInstanceIDString(), SERVICE_DESCRIPTION2.getEventIDString(), findHandler); - compareAndClearServiceContainers(serviceContainer, searchResultOfFindServiceWithFindHandler); - - serviceContainer = - sut.findService(SERVICE, SERVICE_DESCRIPTION3.getInstanceIDString(), SERVICE_DESCRIPTION3.getEventIDString()); + this->sut.findService(SERVICE, + SERVICE_DESCRIPTION2.getInstanceIDString(), + SERVICE_DESCRIPTION2.getEventIDString(), + this->findHandler, + TestFixture::CommunicationKind::KIND); + compareAndClearServiceContainers(serviceContainer, this->searchResultOfFindServiceWithFindHandler); + + serviceContainer = this->sut.findService(SERVICE, + SERVICE_DESCRIPTION3.getInstanceIDString(), + SERVICE_DESCRIPTION3.getEventIDString(), + TestFixture::CommunicationKind::KIND); ASSERT_THAT(serviceContainer.size(), Eq(1U)); EXPECT_THAT(*serviceContainer.begin(), Eq(SERVICE_DESCRIPTION3)); - sut.findService( - SERVICE, SERVICE_DESCRIPTION3.getInstanceIDString(), SERVICE_DESCRIPTION3.getEventIDString(), findHandler); - compareAndClearServiceContainers(serviceContainer, searchResultOfFindServiceWithFindHandler); + this->sut.findService(SERVICE, + SERVICE_DESCRIPTION3.getInstanceIDString(), + SERVICE_DESCRIPTION3.getEventIDString(), + this->findHandler, + TestFixture::CommunicationKind::KIND); + compareAndClearServiceContainers(serviceContainer, this->searchResultOfFindServiceWithFindHandler); } -TEST_F(ServiceDiscovery_test, FindServiceReturnsCorrectServiceInstanceCombinations) +TYPED_TEST(ServiceDiscovery_test, FindServiceReturnsCorrectServiceInstanceCombinations) { ::testing::Test::RecordProperty("TEST_ID", "360839a7-9309-4e7e-8e89-892097a87f7a"); @@ -459,78 +538,94 @@ TEST_F(ServiceDiscovery_test, FindServiceReturnsCorrectServiceInstanceCombinatio const iox::capro::ServiceDescription SERVICE_DESCRIPTION_1_2_2(SERVICE1, INSTANCE2, EVENT2); const iox::capro::ServiceDescription SERVICE_DESCRIPTION_1_2_3(SERVICE1, INSTANCE2, EVENT3); - iox::popo::UntypedPublisher publisher_sd_1_1_1(SERVICE_DESCRIPTION_1_1_1); - iox::popo::UntypedPublisher publisher_sd_1_1_2(SERVICE_DESCRIPTION_1_1_2); - iox::popo::UntypedPublisher publisher_sd_1_2_1(SERVICE_DESCRIPTION_1_2_1); - iox::popo::UntypedPublisher publisher_sd_1_2_2(SERVICE_DESCRIPTION_1_2_2); - iox::popo::UntypedPublisher publisher_sd_1_2_3(SERVICE_DESCRIPTION_1_2_3); + typename TestFixture::CommunicationKind::Producer producer_sd_1_1_1(SERVICE_DESCRIPTION_1_1_1); + typename TestFixture::CommunicationKind::Producer producer_sd_1_1_2(SERVICE_DESCRIPTION_1_1_2); + typename TestFixture::CommunicationKind::Producer producer_sd_1_2_1(SERVICE_DESCRIPTION_1_2_1); + typename TestFixture::CommunicationKind::Producer producer_sd_1_2_2(SERVICE_DESCRIPTION_1_2_2); + typename TestFixture::CommunicationKind::Producer producer_sd_1_2_3(SERVICE_DESCRIPTION_1_2_3); - auto serviceContainer = sut.findService(SERVICE1, INSTANCE1, EVENT1); + auto serviceContainer = this->sut.findService(SERVICE1, INSTANCE1, EVENT1, TestFixture::CommunicationKind::KIND); ASSERT_THAT(serviceContainer.size(), Eq(1U)); EXPECT_THAT(*serviceContainer.begin(), Eq(SERVICE_DESCRIPTION_1_1_1)); - sut.findService(SERVICE1, INSTANCE1, EVENT1, findHandler); - compareAndClearServiceContainers(serviceContainer, searchResultOfFindServiceWithFindHandler); + this->sut.findService(SERVICE1, INSTANCE1, EVENT1, this->findHandler, TestFixture::CommunicationKind::KIND); + compareAndClearServiceContainers(serviceContainer, this->searchResultOfFindServiceWithFindHandler); - serviceContainer = sut.findService(SERVICE1, INSTANCE1, EVENT2); + serviceContainer = this->sut.findService(SERVICE1, INSTANCE1, EVENT2, TestFixture::CommunicationKind::KIND); ASSERT_THAT(serviceContainer.size(), Eq(1U)); + EXPECT_THAT(*serviceContainer.begin(), Eq(SERVICE_DESCRIPTION_1_1_2)); - sut.findService(SERVICE1, INSTANCE1, EVENT2, findHandler); - compareAndClearServiceContainers(serviceContainer, searchResultOfFindServiceWithFindHandler); + this->sut.findService(SERVICE1, INSTANCE1, EVENT2, this->findHandler, TestFixture::CommunicationKind::KIND); + compareAndClearServiceContainers(serviceContainer, this->searchResultOfFindServiceWithFindHandler); - serviceContainer = sut.findService(SERVICE1, INSTANCE2, EVENT1); + serviceContainer = this->sut.findService(SERVICE1, INSTANCE2, EVENT1, TestFixture::CommunicationKind::KIND); ASSERT_THAT(serviceContainer.size(), Eq(1U)); EXPECT_THAT(*serviceContainer.begin(), Eq(SERVICE_DESCRIPTION_1_2_1)); - sut.findService(SERVICE1, INSTANCE2, EVENT1, findHandler); - compareAndClearServiceContainers(serviceContainer, searchResultOfFindServiceWithFindHandler); + this->sut.findService(SERVICE1, INSTANCE2, EVENT1, this->findHandler, TestFixture::CommunicationKind::KIND); + compareAndClearServiceContainers(serviceContainer, this->searchResultOfFindServiceWithFindHandler); - serviceContainer = sut.findService(SERVICE1, INSTANCE2, EVENT2); + serviceContainer = this->sut.findService(SERVICE1, INSTANCE2, EVENT2, TestFixture::CommunicationKind::KIND); ASSERT_THAT(serviceContainer.size(), Eq(1U)); EXPECT_THAT(*serviceContainer.begin(), Eq(SERVICE_DESCRIPTION_1_2_2)); - sut.findService(SERVICE1, INSTANCE2, EVENT2, findHandler); - compareAndClearServiceContainers(serviceContainer, searchResultOfFindServiceWithFindHandler); + this->sut.findService(SERVICE1, INSTANCE2, EVENT2, this->findHandler, TestFixture::CommunicationKind::KIND); + compareAndClearServiceContainers(serviceContainer, this->searchResultOfFindServiceWithFindHandler); - serviceContainer = sut.findService(SERVICE1, INSTANCE2, EVENT3); + serviceContainer = this->sut.findService(SERVICE1, INSTANCE2, EVENT3, TestFixture::CommunicationKind::KIND); ASSERT_THAT(serviceContainer.size(), Eq(1U)); EXPECT_THAT(*serviceContainer.begin(), Eq(SERVICE_DESCRIPTION_1_2_3)); - sut.findService(SERVICE1, INSTANCE2, EVENT3, findHandler); - compareAndClearServiceContainers(serviceContainer, searchResultOfFindServiceWithFindHandler); + this->sut.findService(SERVICE1, INSTANCE2, EVENT3, this->findHandler, TestFixture::CommunicationKind::KIND); + compareAndClearServiceContainers(serviceContainer, this->searchResultOfFindServiceWithFindHandler); } -TEST_F(ServiceDiscovery_test, FindServiceDoesNotReturnNotOfferedServices) +TYPED_TEST(ServiceDiscovery_test, FindServiceDoesNotReturnNotOfferedServices) { ::testing::Test::RecordProperty("TEST_ID", "e4f99eb1-7496-4a1e-bbd1-ebdb07e1ec9b"); const IdString_t INSTANCE = "instance"; const IdString_t EVENT = "event"; const iox::capro::ServiceDescription SERVICE_DESCRIPTION1("service1", INSTANCE, EVENT); - iox::popo::UntypedPublisher publisher_sd1(SERVICE_DESCRIPTION1); + typename TestFixture::CommunicationKind::Producer producer_sd1(SERVICE_DESCRIPTION1); const iox::capro::ServiceDescription SERVICE_DESCRIPTION2("service2", INSTANCE, EVENT); - iox::popo::UntypedPublisher publisher_sd2(SERVICE_DESCRIPTION2); + typename TestFixture::CommunicationKind::Producer producer_sd2(SERVICE_DESCRIPTION2); const iox::capro::ServiceDescription SERVICE_DESCRIPTION3("service3", INSTANCE, EVENT); - iox::popo::UntypedPublisher publisher_sd3(SERVICE_DESCRIPTION3); + typename TestFixture::CommunicationKind::Producer producer_sd3(SERVICE_DESCRIPTION3); - publisher_sd1.stopOffer(); - publisher_sd3.stopOffer(); + producer_sd1.stopOffer(); + producer_sd3.stopOffer(); this->InterOpWait(); - auto serviceContainer = sut.findService(SERVICE_DESCRIPTION1.getServiceIDString(), INSTANCE, EVENT); + auto serviceContainer = this->sut.findService( + SERVICE_DESCRIPTION1.getServiceIDString(), INSTANCE, EVENT, TestFixture::CommunicationKind::KIND); EXPECT_THAT(serviceContainer.size(), Eq(0U)); - sut.findService(SERVICE_DESCRIPTION1.getServiceIDString(), INSTANCE, EVENT, findHandler); - EXPECT_TRUE(searchResultOfFindServiceWithFindHandler.empty()); - - serviceContainer = sut.findService(SERVICE_DESCRIPTION2.getServiceIDString(), INSTANCE, EVENT); + this->sut.findService(SERVICE_DESCRIPTION1.getServiceIDString(), + INSTANCE, + EVENT, + this->findHandler, + TestFixture::CommunicationKind::KIND); + EXPECT_TRUE(this->searchResultOfFindServiceWithFindHandler.empty()); + + serviceContainer = this->sut.findService( + SERVICE_DESCRIPTION2.getServiceIDString(), INSTANCE, EVENT, TestFixture::CommunicationKind::KIND); ASSERT_THAT(serviceContainer.size(), Eq(1U)); EXPECT_THAT(*serviceContainer.begin(), Eq(SERVICE_DESCRIPTION2)); - sut.findService(SERVICE_DESCRIPTION2.getServiceIDString(), INSTANCE, EVENT, findHandler); - compareAndClearServiceContainers(serviceContainer, searchResultOfFindServiceWithFindHandler); - - serviceContainer = sut.findService(SERVICE_DESCRIPTION3.getServiceIDString(), INSTANCE, EVENT); + this->sut.findService(SERVICE_DESCRIPTION2.getServiceIDString(), + INSTANCE, + EVENT, + this->findHandler, + TestFixture::CommunicationKind::KIND); + compareAndClearServiceContainers(serviceContainer, this->searchResultOfFindServiceWithFindHandler); + + serviceContainer = this->sut.findService( + SERVICE_DESCRIPTION3.getServiceIDString(), INSTANCE, EVENT, TestFixture::CommunicationKind::KIND); EXPECT_THAT(serviceContainer.size(), Eq(0U)); - sut.findService(SERVICE_DESCRIPTION3.getServiceIDString(), INSTANCE, EVENT, findHandler); - EXPECT_TRUE(searchResultOfFindServiceWithFindHandler.empty()); + this->sut.findService(SERVICE_DESCRIPTION3.getServiceIDString(), + INSTANCE, + EVENT, + this->findHandler, + TestFixture::CommunicationKind::KIND); + EXPECT_TRUE(this->searchResultOfFindServiceWithFindHandler.empty()); } -TEST_F(ServiceDiscovery_test, NonExistingServicesAreNotFound) +TYPED_TEST(ServiceDiscovery_test, NonExistingServicesAreNotFound) { ::testing::Test::RecordProperty("TEST_ID", "86b87264-4df4-4d20-9357-06391ca1d57f"); const IdString_t SERVICE = "service"; @@ -540,97 +635,173 @@ TEST_F(ServiceDiscovery_test, NonExistingServicesAreNotFound) const IdString_t EVENT = "event"; const IdString_t NONEXISTENT_EVENT = "hypnotoad"; const iox::capro::ServiceDescription SERVICE_DESCRIPTION(SERVICE, INSTANCE, EVENT); - iox::popo::UntypedPublisher publisher_sd(SERVICE_DESCRIPTION); + typename TestFixture::CommunicationKind::Producer producer_sd(SERVICE_DESCRIPTION); - auto serviceContainer = sut.findService(NONEXISTENT_SERVICE, NONEXISTENT_INSTANCE, NONEXISTENT_EVENT); + auto serviceContainer = this->sut.findService( + NONEXISTENT_SERVICE, NONEXISTENT_INSTANCE, NONEXISTENT_EVENT, TestFixture::CommunicationKind::KIND); EXPECT_THAT(serviceContainer.size(), Eq(0U)); - sut.findService(NONEXISTENT_SERVICE, NONEXISTENT_INSTANCE, NONEXISTENT_EVENT, findHandler); - EXPECT_TRUE(searchResultOfFindServiceWithFindHandler.empty()); + this->sut.findService(NONEXISTENT_SERVICE, + NONEXISTENT_INSTANCE, + NONEXISTENT_EVENT, + this->findHandler, + TestFixture::CommunicationKind::KIND); + EXPECT_TRUE(this->searchResultOfFindServiceWithFindHandler.empty()); - serviceContainer = sut.findService(NONEXISTENT_SERVICE, NONEXISTENT_INSTANCE, EVENT); + serviceContainer = + this->sut.findService(NONEXISTENT_SERVICE, NONEXISTENT_INSTANCE, EVENT, TestFixture::CommunicationKind::KIND); EXPECT_THAT(serviceContainer.size(), Eq(0U)); - sut.findService(NONEXISTENT_SERVICE, NONEXISTENT_INSTANCE, EVENT, findHandler); - EXPECT_TRUE(searchResultOfFindServiceWithFindHandler.empty()); + this->sut.findService( + NONEXISTENT_SERVICE, NONEXISTENT_INSTANCE, EVENT, this->findHandler, TestFixture::CommunicationKind::KIND); + EXPECT_TRUE(this->searchResultOfFindServiceWithFindHandler.empty()); - serviceContainer = sut.findService(NONEXISTENT_SERVICE, INSTANCE, NONEXISTENT_EVENT); + serviceContainer = + this->sut.findService(NONEXISTENT_SERVICE, INSTANCE, NONEXISTENT_EVENT, TestFixture::CommunicationKind::KIND); EXPECT_THAT(serviceContainer.size(), Eq(0U)); - sut.findService(NONEXISTENT_SERVICE, INSTANCE, NONEXISTENT_EVENT, findHandler); - EXPECT_TRUE(searchResultOfFindServiceWithFindHandler.empty()); + this->sut.findService( + NONEXISTENT_SERVICE, INSTANCE, NONEXISTENT_EVENT, this->findHandler, TestFixture::CommunicationKind::KIND); + EXPECT_TRUE(this->searchResultOfFindServiceWithFindHandler.empty()); - serviceContainer = sut.findService(NONEXISTENT_SERVICE, INSTANCE, EVENT); + serviceContainer = + this->sut.findService(NONEXISTENT_SERVICE, INSTANCE, EVENT, TestFixture::CommunicationKind::KIND); EXPECT_THAT(serviceContainer.size(), Eq(0U)); - sut.findService(NONEXISTENT_SERVICE, INSTANCE, EVENT, findHandler); - EXPECT_TRUE(searchResultOfFindServiceWithFindHandler.empty()); + this->sut.findService( + NONEXISTENT_SERVICE, INSTANCE, EVENT, this->findHandler, TestFixture::CommunicationKind::KIND); + EXPECT_TRUE(this->searchResultOfFindServiceWithFindHandler.empty()); - serviceContainer = sut.findService(SERVICE, NONEXISTENT_INSTANCE, NONEXISTENT_EVENT); + serviceContainer = + this->sut.findService(SERVICE, NONEXISTENT_INSTANCE, NONEXISTENT_EVENT, TestFixture::CommunicationKind::KIND); EXPECT_THAT(serviceContainer.size(), Eq(0U)); - sut.findService(SERVICE, NONEXISTENT_INSTANCE, NONEXISTENT_EVENT, findHandler); - EXPECT_TRUE(searchResultOfFindServiceWithFindHandler.empty()); + this->sut.findService( + SERVICE, NONEXISTENT_INSTANCE, NONEXISTENT_EVENT, this->findHandler, TestFixture::CommunicationKind::KIND); + EXPECT_TRUE(this->searchResultOfFindServiceWithFindHandler.empty()); - serviceContainer = sut.findService(SERVICE, NONEXISTENT_INSTANCE, NONEXISTENT_EVENT); + serviceContainer = + this->sut.findService(SERVICE, NONEXISTENT_INSTANCE, NONEXISTENT_EVENT, TestFixture::CommunicationKind::KIND); EXPECT_THAT(serviceContainer.size(), Eq(0U)); - sut.findService(SERVICE, NONEXISTENT_INSTANCE, NONEXISTENT_EVENT, findHandler); - EXPECT_TRUE(searchResultOfFindServiceWithFindHandler.empty()); + this->sut.findService( + SERVICE, NONEXISTENT_INSTANCE, NONEXISTENT_EVENT, this->findHandler, TestFixture::CommunicationKind::KIND); + EXPECT_TRUE(this->searchResultOfFindServiceWithFindHandler.empty()); - serviceContainer = sut.findService(SERVICE, INSTANCE, NONEXISTENT_EVENT); + serviceContainer = + this->sut.findService(SERVICE, INSTANCE, NONEXISTENT_EVENT, TestFixture::CommunicationKind::KIND); EXPECT_THAT(serviceContainer.size(), Eq(0U)); - sut.findService(SERVICE, INSTANCE, NONEXISTENT_EVENT, findHandler); - EXPECT_TRUE(searchResultOfFindServiceWithFindHandler.empty()); + this->sut.findService( + SERVICE, INSTANCE, NONEXISTENT_EVENT, this->findHandler, TestFixture::CommunicationKind::KIND); + EXPECT_TRUE(this->searchResultOfFindServiceWithFindHandler.empty()); } -TEST_F(ServiceDiscovery_test, FindServiceReturnsMaxPublisherServices) +TYPED_TEST(ServiceDiscovery_test, FindServiceReturnsMaxProducerServices) { ::testing::Test::RecordProperty("TEST_ID", "68628cc2-df6d-46e4-8586-7563f43bf10c"); const IdString_t SERVICE = "s"; - constexpr auto MAX_USER_PUBLISHERS = iox::MAX_PUBLISHERS - iox::NUMBER_OF_INTERNAL_PUBLISHERS; - // if the result size is limited to be lower than the number of publishers in the registry, + + // if the result size is limited to be lower than the number of producers in the registry, // there is no way to retrieve them all - constexpr auto NUM_PUBLISHERS = std::min(MAX_USER_PUBLISHERS, iox::MAX_FINDSERVICE_RESULT_SIZE); - iox::cxx::vector publishers; + constexpr auto NUM_PRODUCERS = + std::min(TestFixture::CommunicationKind::MAX_USER_PRODUCERS, iox::MAX_FINDSERVICE_RESULT_SIZE); + iox::cxx::vector producers; // we want to check whether we find all the services, including internal ones like introspection, // so we first search for them without creating other services to obtain the internal ones - ServiceContainer serviceContainerExp = - sut.findService(iox::capro::Wildcard, iox::capro::Wildcard, iox::capro::Wildcard); + ServiceContainer serviceContainerExp = this->sut.findService( + iox::capro::Wildcard, iox::capro::Wildcard, iox::capro::Wildcard, TestFixture::CommunicationKind::KIND); - for (size_t i = 0; i < NUM_PUBLISHERS; i++) + for (size_t i = 0; i < NUM_PRODUCERS; i++) { std::string instance = "i" + iox::cxx::convert::toString(i); iox::capro::ServiceDescription SERVICE_DESCRIPTION( SERVICE, IdString_t(iox::cxx::TruncateToCapacity, instance), "foo"); - publishers.emplace_back(SERVICE_DESCRIPTION); + producers.emplace_back(SERVICE_DESCRIPTION); serviceContainerExp.push_back(SERVICE_DESCRIPTION); } // now we should find the maximum number of services we can search for, - // i.e. internal services and those we just created (iox::MAX_PUBLISHERS combined) - auto serviceContainer = sut.findService(iox::capro::Wildcard, iox::capro::Wildcard, iox::capro::Wildcard); + // i.e. internal services and those we just created (iox::MAX_PRODUCERS combined) + auto serviceContainer = this->sut.findService( + iox::capro::Wildcard, iox::capro::Wildcard, iox::capro::Wildcard, TestFixture::CommunicationKind::KIND); - constexpr auto EXPECTED_NUM_PUBLISHERS = std::min(iox::MAX_PUBLISHERS, iox::MAX_FINDSERVICE_RESULT_SIZE); - EXPECT_EQ(serviceContainer.size(), EXPECTED_NUM_PUBLISHERS); + constexpr auto EXPECTED_NUM_PRODUCERS = + std::min(TestFixture::CommunicationKind::MAX_PRODUCERS, iox::MAX_FINDSERVICE_RESULT_SIZE); + EXPECT_EQ(serviceContainer.size(), EXPECTED_NUM_PRODUCERS); EXPECT_TRUE(serviceContainer == serviceContainerExp); - sut.findService(iox::capro::Wildcard, iox::capro::Wildcard, iox::capro::Wildcard, findHandler); - compareAndClearServiceContainers(serviceContainer, searchResultOfFindServiceWithFindHandler); + this->sut.findService(iox::capro::Wildcard, + iox::capro::Wildcard, + iox::capro::Wildcard, + this->findHandler, + TestFixture::CommunicationKind::KIND); + compareAndClearServiceContainers(serviceContainer, this->searchResultOfFindServiceWithFindHandler); +} + +/// +/// Publisher-Subscriber && Request-Response +/// + +TEST_F(ServiceDiscoveryPubSub_test, FindServiceWithPublisherAndServerWithTheSameServiceDescriptionAreBothFound) +{ + ::testing::Test::RecordProperty("TEST_ID", "1ea59629-2fc7-4ef4-9acb-9892a9ec640c"); + + const iox::capro::ServiceDescription SERVICE_DESCRIPTION("Curry", "Chicken tikka", "Ginger"); + + iox::popo::UntypedPublisher publisher(SERVICE_DESCRIPTION); + iox::popo::UntypedServer server(SERVICE_DESCRIPTION); + + auto serviceContainerPubSub = this->sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), + SERVICE_DESCRIPTION.getInstanceIDString(), + SERVICE_DESCRIPTION.getEventIDString(), + MessagingPattern::PUB_SUB); + + auto serviceContainerReqRes = this->sut.findService(SERVICE_DESCRIPTION.getServiceIDString(), + SERVICE_DESCRIPTION.getInstanceIDString(), + SERVICE_DESCRIPTION.getEventIDString(), + MessagingPattern::REQ_RES); + + ASSERT_THAT(serviceContainerPubSub.size(), Eq(1U)); + EXPECT_THAT(*serviceContainerPubSub.begin(), Eq(SERVICE_DESCRIPTION)); + + ASSERT_THAT(serviceContainerReqRes.size(), Eq(1U)); + EXPECT_THAT(*serviceContainerReqRes.begin(), Eq(SERVICE_DESCRIPTION)); } -TEST_F(ServiceDiscovery_test, FindServiceWithEmptyCallableDoesNotDie) +/// +/// Publisher-Subscriber +/// + +TEST_F(ServiceDiscoveryPubSub_test, FindServiceWithWildcardsReturnsOnlyIntrospectionServicesAndServiceRegistry) +{ + ::testing::Test::RecordProperty("TEST_ID", "d944f32c-edef-44f5-a6eb-c19ee73c98eb"); + auto searchResult = this->sut.findService( + iox::capro::Wildcard, iox::capro::Wildcard, iox::capro::Wildcard, MessagingPattern::PUB_SUB); + + + for (auto& service : searchResult) + { + EXPECT_THAT(service.getInstanceIDString().c_str(), StrEq("RouDi_ID")); + } + + this->sut.findService( + iox::capro::Wildcard, iox::capro::Wildcard, iox::capro::Wildcard, findHandler, MessagingPattern::PUB_SUB); + compareAndClearServiceContainers(searchResult, searchResultOfFindServiceWithFindHandler); +} + +TEST_F(ServiceDiscoveryPubSub_test, FindServiceWithEmptyCallableDoesNotDie) { ::testing::Test::RecordProperty("TEST_ID", "7e1bf253-ce81-47cc-9b4a-605de7e49b64"); const iox::capro::ServiceDescription SERVICE_DESCRIPTION("ninjababy", "pow", "pow"); iox::popo::UntypedPublisher publisher(SERVICE_DESCRIPTION); iox::cxx::function_ref searchFunction; - sut.findService(iox::capro::Wildcard, iox::capro::Wildcard, iox::capro::Wildcard, searchFunction); + this->sut.findService( + iox::capro::Wildcard, iox::capro::Wildcard, iox::capro::Wildcard, searchFunction, MessagingPattern::PUB_SUB); } -TEST_F(ServiceDiscovery_test, ServiceDiscoveryIsAttachableToWaitSet) +TEST_F(ServiceDiscoveryPubSub_test, ServiceDiscoveryIsAttachableToWaitSet) { ::testing::Test::RecordProperty("TEST_ID", "fc0eeb7a-6f2a-481f-ae8a-1e17460e261f"); iox::popo::WaitSet<10U> waitSet; waitSet - .attachEvent(sut, + .attachEvent(this->sut, ServiceDiscoveryEvent::SERVICE_REGISTRY_CHANGED, 0U, iox::popo::createNotificationCallback(testCallback)) @@ -638,13 +809,13 @@ TEST_F(ServiceDiscovery_test, ServiceDiscoveryIsAttachableToWaitSet) .or_else([](auto) { GTEST_FAIL() << "Could not attach to wait set"; }); } -TEST_F(ServiceDiscovery_test, ServiceDiscoveryIsNotifiedbyWaitSetAboutSingleService) +TEST_F(ServiceDiscoveryPubSub_test, ServiceDiscoveryIsNotifiedbyWaitSetAboutSingleService) { ::testing::Test::RecordProperty("TEST_ID", "f1cf36b5-3db2-4e6f-8e05-e7e449530ec0"); iox::popo::WaitSet<1U> waitSet; waitSet - .attachEvent(sut, + .attachEvent(this->sut, ServiceDiscoveryEvent::SERVICE_REGISTRY_CHANGED, 0U, iox::popo::createNotificationCallback(testCallback)) @@ -663,17 +834,17 @@ TEST_F(ServiceDiscovery_test, ServiceDiscoveryIsNotifiedbyWaitSetAboutSingleServ EXPECT_TRUE(callbackWasCalled); } -TEST_F(ServiceDiscovery_test, ServiceDiscoveryNotifiedbyWaitSetFindsSingleService) +TEST_F(ServiceDiscoveryPubSub_test, ServiceDiscoveryNotifiedbyWaitSetFindsSingleService) { ::testing::Test::RecordProperty("TEST_ID", "1ecde7e0-f5b2-4721-b309-66f32f40a7bf"); iox::popo::WaitSet<1U> waitSet; iox::capro::ServiceDescription serviceDescriptionToSearchFor("Soep", "Moemi", "Luela"); waitSet - .attachEvent(sut, + .attachEvent(this->sut, ServiceDiscoveryEvent::SERVICE_REGISTRY_CHANGED, 0U, - iox::popo::createNotificationCallback(searchForService, serviceDescriptionToSearchFor)) + iox::popo::createNotificationCallback(searchForPublisher, serviceDescriptionToSearchFor)) .or_else([](auto) { GTEST_FAIL() << "Could not attach to wait set"; }); iox::popo::UntypedPublisher publisher(serviceDescriptionToSearchFor); @@ -689,26 +860,28 @@ TEST_F(ServiceDiscovery_test, ServiceDiscoveryNotifiedbyWaitSetFindsSingleServic EXPECT_THAT(serviceContainer.front(), Eq(serviceDescriptionToSearchFor)); } -TEST_F(ServiceDiscovery_test, ServiceDiscoveryIsAttachableToListener) +TEST_F(ServiceDiscoveryPubSub_test, ServiceDiscoveryIsAttachableToListener) { ::testing::Test::RecordProperty("TEST_ID", "def201f7-d1bf-4031-8e50-a2ad22ee303c"); iox::popo::Listener listener; listener - .attachEvent( - sut, ServiceDiscoveryEvent::SERVICE_REGISTRY_CHANGED, iox::popo::createNotificationCallback(testCallback)) + .attachEvent(this->sut, + ServiceDiscoveryEvent::SERVICE_REGISTRY_CHANGED, + iox::popo::createNotificationCallback(testCallback)) .and_then([]() { GTEST_SUCCEED(); }) .or_else([](auto) { GTEST_FAIL() << "Could not attach to listener"; }); } -TEST_F(ServiceDiscovery_test, ServiceDiscoveryIsNotifiedByListenerAboutSingleService) +TEST_F(ServiceDiscoveryPubSub_test, ServiceDiscoveryIsNotifiedByListenerAboutSingleService) { ::testing::Test::RecordProperty("TEST_ID", "305107fc-41dd-431c-8032-ed5e82f93038"); iox::popo::Listener listener; listener - .attachEvent( - sut, ServiceDiscoveryEvent::SERVICE_REGISTRY_CHANGED, iox::popo::createNotificationCallback(testCallback)) + .attachEvent(this->sut, + ServiceDiscoveryEvent::SERVICE_REGISTRY_CHANGED, + iox::popo::createNotificationCallback(testCallback)) .or_else([](auto) { GTEST_FAIL() << "Could not attach to listener"; }); const iox::capro::ServiceDescription SERVICE_DESCRIPTION("Moep", "Fluepp", "Shoezzel"); @@ -722,16 +895,16 @@ TEST_F(ServiceDiscovery_test, ServiceDiscoveryIsNotifiedByListenerAboutSingleSer EXPECT_TRUE(callbackWasCalled.load()); } -TEST_F(ServiceDiscovery_test, ServiceDiscoveryNotifiedbyListenerFindsSingleService) +TEST_F(ServiceDiscoveryPubSub_test, ServiceDiscoveryNotifiedbyListenerFindsSingleService) { ::testing::Test::RecordProperty("TEST_ID", "b38ba8a4-ff27-437a-b376-13125cb419cb"); iox::popo::Listener listener; iox::capro::ServiceDescription serviceDescriptionToSearchFor("Gimbel", "Seggel", "Doedel"); listener - .attachEvent(sut, + .attachEvent(this->sut, ServiceDiscoveryEvent::SERVICE_REGISTRY_CHANGED, - iox::popo::createNotificationCallback(searchForService, serviceDescriptionToSearchFor)) + iox::popo::createNotificationCallback(searchForPublisher, serviceDescriptionToSearchFor)) .or_else([](auto) { GTEST_FAIL() << "Could not attach to listener"; }); iox::popo::UntypedPublisher publisher(serviceDescriptionToSearchFor);