SystemServicesRoutingTest() : settingsFilename("test-resources/SystemServicesRoutingTest.settings"), settings(new QSettings(settingsFilename, QSettings::IniFormat)), routingDomain(), routingProviderParticipantId(), runtime(NULL), mockMessageReceiver(new MockMessageReceiver()), mockMessageSender(new MockMessageSender()), discoveryQos(), routingProxyBuilder(NULL), routingProxy(NULL) { SystemServicesSettings systemSettings(*settings); systemSettings.printSettings(); routingDomain = TypeUtil::toStd(systemSettings.getDomain()); routingProviderParticipantId = systemSettings.getCcRoutingProviderParticipantId(); discoveryQos.setCacheMaxAge(1000); discoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::FIXED_PARTICIPANT); discoveryQos.addCustomParameter("fixedParticipantId", TypeUtil::toStd(routingProviderParticipantId)); discoveryQos.setDiscoveryTimeout(50); QString channelId("SystemServicesRoutingTest.ChannelId"); EXPECT_CALL(*(dynamic_cast<MockMessageReceiver*>(mockMessageReceiver)), getReceiveChannelId()) .WillRepeatedly(::testing::ReturnRefOfCopy(channelId)); //runtime can only be created, after MockMessageReceiver has been told to return //a channelId for getReceiveChannelId. runtime = new JoynrClusterControllerRuntime(NULL, settings, mockMessageReceiver, mockMessageSender); // routing provider is normally registered in JoynrClusterControllerRuntime::create runtime->registerRoutingProvider(); }
void SetUp() { // start libjoynr runtime runtime = new LibJoynrDbusRuntime( new Settings(temporarylibjoynrSettingsFilename) ); SystemServicesSettings systemSettings(settings); systemSettings.printSettings(); std::string systemServicesDomain(systemSettings.getDomain()); // setup routing proxy std::string routingProviderParticipantId(systemSettings.getCcRoutingProviderParticipantId()); routingProxyBuilder = runtime ->createProxyBuilder<joynr::system::RoutingProxy>(systemServicesDomain); DiscoveryQos discoveryQos; discoveryQos.setCacheMaxAge(1000); discoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::FIXED_PARTICIPANT); discoveryQos.addCustomParameter("fixedParticipantId", routingProviderParticipantId); discoveryQos.setDiscoveryTimeout(50); routingProxy = routingProxyBuilder ->setMessagingQos(MessagingQos(5000)) ->setCached(false) ->setDiscoveryQos(discoveryQos) ->build(); EXPECT_TRUE(routingProxy != NULL); // setup discovery proxy std::string discoveryProviderParticipantId(systemSettings.getCcDiscoveryProviderParticipantId()); discoveryProxyBuilder = runtime ->createProxyBuilder<joynr::system::DiscoveryProxy>(systemServicesDomain); discoveryQos = DiscoveryQos(); discoveryQos.setCacheMaxAge(1000); discoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::FIXED_PARTICIPANT); discoveryQos.addCustomParameter("fixedParticipantId", discoveryProviderParticipantId); discoveryQos.setDiscoveryTimeout(50); discoveryProxy = discoveryProxyBuilder ->setMessagingQos(MessagingQos(5000)) ->setCached(false) ->setDiscoveryQos(discoveryQos) ->build(); EXPECT_TRUE(discoveryProxy != NULL); mockTestProvider = std::make_shared<MockTestProvider>(mockTestProviderQos); }
TEST_F(LocalCapabilitiesDirectoryTest, registerCapabilityAddsToCache) { EXPECT_CALL(*capabilitiesClient, getCapabilitiesForParticipantId(dummyParticipantId1,_)).Times(0); EXPECT_CALL(*capabilitiesClient, registerCapabilities(_)).Times(1); localCapabilitiesDirectory->registerCapability(DOMAIN_1_NAME ,INTERFACE_1_NAME, types::ProviderQos(), dummyParticipantId1); DiscoveryQos qos; qos.setCacheMaxAge(LocalCapabilitiesDirectory::NO_CACHE_FRESHNESS_REQ()); qos.setDiscoveryTimeout(ICapabilities::NO_TIMEOUT()); localCapabilitiesDirectory->getCapabilities(dummyParticipantId1, callback, discoveryQos); EXPECT_EQ(1, callback->getResults(TIMEOUT).size()); }
void DbusCapabilitiesUtil::copyDbusDiscoveryQosToJoynr(const joynr::messaging::types::Types::DiscoveryQos& dbusDiscoveryQos, DiscoveryQos& joynrDiscoveryQos) { // copy arbitration strategy switch (dbusDiscoveryQos.arbitrationStrategy) { case joynr::messaging::types::Types::ArbitrationStrategy::FIXED_CHANNEL: joynrDiscoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::FIXED_PARTICIPANT); break; case joynr::messaging::types::Types::ArbitrationStrategy::HIGHEST_PRIORITY: joynrDiscoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::HIGHEST_PRIORITY); break; case joynr::messaging::types::Types::ArbitrationStrategy::KEYWORD: joynrDiscoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::KEYWORD); break; case joynr::messaging::types::Types::ArbitrationStrategy::LOCAL_ONLY: joynrDiscoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::LOCAL_ONLY); break; case joynr::messaging::types::Types::ArbitrationStrategy::NOT_SET: joynrDiscoveryQos.setArbitrationStrategy(DiscoveryQos::ArbitrationStrategy::NOT_SET); break; default: assert(false); } switch(dbusDiscoveryQos.discoveryScope) { case joynr::messaging::types::Types::DiscoveryScope::GLOBAL_ONLY: joynrDiscoveryQos.setDiscoveryScope(DiscoveryQos::DiscoveryScope::GLOBAL_ONLY); break; case joynr::messaging::types::Types::DiscoveryScope::LOCAL_ONLY: joynrDiscoveryQos.setDiscoveryScope(DiscoveryQos::DiscoveryScope::LOCAL_ONLY); break; case joynr::messaging::types::Types::DiscoveryScope::LOCAL_THEN_GLOBAL: joynrDiscoveryQos.setDiscoveryScope(DiscoveryQos::DiscoveryScope::LOCAL_THEN_GLOBAL); break; case joynr::messaging::types::Types::DiscoveryScope::LOCAL_AND_GLOBAL: joynrDiscoveryQos.setDiscoveryScope(DiscoveryQos::DiscoveryScope::LOCAL_AND_GLOBAL); break; default: assert(false); } joynrDiscoveryQos.setCacheMaxAge(dbusDiscoveryQos.cacheMaxAge); joynrDiscoveryQos.setDiscoveryTimeout(dbusDiscoveryQos.discoveryTimeout); joynrDiscoveryQos.setProviderMustSupportOnChange(dbusDiscoveryQos.providerMustSupportOnChange); joynrDiscoveryQos.setRetryInterval(dbusDiscoveryQos.retryInterval); // copy the custom parameters auto parameterMap = dbusDiscoveryQos.customParameters; for(auto it = parameterMap.begin(); it != parameterMap.end(); it++) { joynr::messaging::types::Types::CustomParameter parameter = it->second; // initialize the joynr parameter joynrDiscoveryQos.addCustomParameter(QString::fromStdString(parameter.name), QString::fromStdString(parameter.value)); } }