use of joynr.types.Version in project joynr by bmwcarit.
the class LocalDiscoveryAggregatorTest method setUp.
@Before
public void setUp() {
systemServicesDomain = "test.system.service.domain";
anotherDomain = "anotherDomain";
discoveryProviderParticipantId = "test.discovery.provider.participant";
when(proxyBuilderFactory.get(anyString(), eq(DiscoveryProxy.class))).thenReturn(proxyBuilder);
when(proxyBuilder.build()).thenReturn(discoveryProxyMock);
when(proxyBuilder.setMessagingQos(any(MessagingQos.class))).thenReturn(proxyBuilder);
localDiscoveryAggregator = new LocalDiscoveryAggregator(systemServicesDomain, discoveryProviderParticipantId, "routingProviderParticipantId", proxyBuilderFactory);
localDiscoveryAggregator.forceQueryOfDiscoveryProxy();
ProviderQos providerQos = new ProviderQos();
providerQos.setScope(ProviderScope.LOCAL);
discoveryProviderEntry = new DiscoveryEntryWithMetaInfo(new Version(0, 1), systemServicesDomain, Discovery.INTERFACE_NAME, discoveryProviderParticipantId, providerQos, System.currentTimeMillis(), expiryDateMs, publicKeyId, true);
anotherDiscoveryProviderEntry = new DiscoveryEntryWithMetaInfo(new Version(0, 0), anotherDomain, Discovery.INTERFACE_NAME, discoveryProviderParticipantId, providerQos, System.currentTimeMillis(), expiryDateMs, publicKeyId, true);
}
use of joynr.types.Version in project joynr by bmwcarit.
the class SerializationTest method serializeSubtypeInCompoundType.
@Test
public void serializeSubtypeInCompoundType() throws Exception {
MqttAddress mqttAddress = new MqttAddress("brokerUri", "topic");
GlobalDiscoveryEntry globalDiscoveryEntry = new GlobalDiscoveryEntry(new Version(47, 11), "domain", "interface", "participantId", new ProviderQos(), System.currentTimeMillis(), expiryDateMs, publicKeyId, objectMapper.writeValueAsString(mqttAddress));
String serializedGlobalDiscoveryEntry = objectMapper.writeValueAsString(globalDiscoveryEntry);
GlobalDiscoveryEntry receivedDiscoveryEntry = objectMapper.readValue(serializedGlobalDiscoveryEntry, GlobalDiscoveryEntry.class);
Assert.assertTrue(objectMapper.readValue(receivedDiscoveryEntry.getAddress(), Address.class) instanceof MqttAddress);
Assert.assertEquals(globalDiscoveryEntry, receivedDiscoveryEntry);
}
use of joynr.types.Version in project joynr by bmwcarit.
the class ArbitrationTest method keywordArbitratorOnChangeSubscriptionsTest.
// Check that the keyword arbitrator will only consider providers that support onChange subscriptions
// when this is requested by the DiscoveryQos
@Test
public void keywordArbitratorOnChangeSubscriptionsTest() throws InterruptedException {
ProviderQos providerQos = new ProviderQos();
CustomParameter[] qosParameters = { new CustomParameter(ArbitrationConstants.KEYWORD_PARAMETER, testKeyword) };
// Create a capability entry for a provider with the correct keyword but that does not support onChange subscriptions
providerQos.setCustomParameters(qosParameters);
providerQos.setSupportsOnChangeSubscriptions(false);
capabilitiesList.add(new DiscoveryEntryWithMetaInfo(new Version(47, 11), domain, TestInterface.INTERFACE_NAME, "wrongParticipantId", providerQos, System.currentTimeMillis(), NO_EXPIRY, publicKeyId, true));
// Create a capability entry for a provider with the correct keyword and that also supports onChange subscriptions
ProviderQos providerQos2 = new ProviderQos();
CustomParameter[] qosParameters2 = { new CustomParameter(ArbitrationConstants.KEYWORD_PARAMETER, testKeyword) };
providerQos2.setCustomParameters(qosParameters2);
providerQos2.setSupportsOnChangeSubscriptions(true);
expectedEndpointAddress = new ChannelAddress("http://testUrl", "testChannelId");
DiscoveryEntryWithMetaInfo expectedDiscoveryEntry = new DiscoveryEntryWithMetaInfo(new Version(47, 11), domain, TestInterface.INTERFACE_NAME, "expectedParticipantId", providerQos2, System.currentTimeMillis(), NO_EXPIRY, publicKeyId, true);
capabilitiesList.add(expectedDiscoveryEntry);
discoveryQos = new DiscoveryQos(ARBITRATION_TIMEOUT, ArbitrationStrategy.Keyword, Long.MAX_VALUE);
discoveryQos.addCustomParameter(ArbitrationConstants.KEYWORD_PARAMETER, testKeyword);
discoveryQos.setProviderMustSupportOnChange(true);
try {
Arbitrator arbitrator = ArbitratorFactory.create(Sets.newHashSet(domain), interfaceName, interfaceVersion, discoveryQos, localDiscoveryAggregator);
arbitrator.setArbitrationListener(arbitrationCallback);
arbitrator.scheduleArbitration();
assertTrue(localDiscoveryAggregatorSemaphore.tryAcquire(1000, TimeUnit.MILLISECONDS));
ArbitrationResult expectedArbitrationResult = new ArbitrationResult(expectedDiscoveryEntry);
verify(arbitrationCallback, times(1)).onSuccess(eq(expectedArbitrationResult));
} catch (DiscoveryException e) {
fail("A Joyn Arbitration Exception has been thrown");
}
}
use of joynr.types.Version in project joynr by bmwcarit.
the class ArbitrationTest method keyWordArbitratorMissingKeywordTest.
@Test
public void keyWordArbitratorMissingKeywordTest() throws InterruptedException {
ProviderQos providerQos = new ProviderQos();
CustomParameter[] qosParameters = { new CustomParameter(ArbitrationConstants.KEYWORD_PARAMETER, "wrongkeyword") };
providerQos.setCustomParameters(qosParameters);
expectedEndpointAddress = new ChannelAddress("http://testUrl", "testChannelId");
capabilitiesList.add(new DiscoveryEntryWithMetaInfo(new Version(47, 11), domain, TestInterface.INTERFACE_NAME, expectedParticipantId, providerQos, System.currentTimeMillis(), NO_EXPIRY, publicKeyId, true));
ProviderQos providerQos2 = new ProviderQos();
CustomParameter[] qosParameters2 = { new CustomParameter(ArbitrationConstants.KEYWORD_PARAMETER, "otherKeyword") };
providerQos2.setCustomParameters(qosParameters2);
capabilitiesList.add(new DiscoveryEntryWithMetaInfo(new Version(47, 11), domain, TestInterface.INTERFACE_NAME, "wrongParticipantId", providerQos2, System.currentTimeMillis(), NO_EXPIRY, publicKeyId, true));
// use minimal timeout to prevent restarting arbitration
int discoveryTimeout = 0;
discoveryQos = new DiscoveryQos(discoveryTimeout, ArbitrationStrategy.Keyword, Long.MAX_VALUE);
discoveryQos.addCustomParameter(ArbitrationConstants.KEYWORD_PARAMETER, testKeyword);
try {
Arbitrator arbitrator = ArbitratorFactory.create(Sets.newHashSet(domain), interfaceName, interfaceVersion, discoveryQos, localDiscoveryAggregator);
arbitrator.setArbitrationListener(arbitrationCallback);
arbitrator.scheduleArbitration();
assertTrue(localDiscoveryAggregatorSemaphore.tryAcquire(1000, TimeUnit.MILLISECONDS));
verify(arbitrationCallback, times(1)).onError(any(Throwable.class));
verify(arbitrationCallback, never()).onSuccess(any(ArbitrationResult.class));
} catch (DiscoveryException e) {
fail("A Joyn Arbitration Exception has been thrown");
}
}
use of joynr.types.Version in project joynr by bmwcarit.
the class DiscoveryEntryVersionFilterTest method testOnlyIncompatibleVersionsFilteredOut.
@Test
public void testOnlyIncompatibleVersionsFilteredOut() {
Version callerVersion = new Version(0, 0);
DiscoveryEntryWithMetaInfo compatibleEntry = mock(DiscoveryEntryWithMetaInfo.class);
Version compatibleVersion = new Version(0, 1);
when(compatibleEntry.getProviderVersion()).thenReturn(compatibleVersion);
when(versionCompatibilityChecker.check(eq(callerVersion), eq(compatibleVersion))).thenReturn(true);
DiscoveryEntryWithMetaInfo incompatibleEntry = mock(DiscoveryEntryWithMetaInfo.class);
Version incompatibleVersion = new Version(2, 2);
when(incompatibleEntry.getProviderVersion()).thenReturn(incompatibleVersion);
when(versionCompatibilityChecker.check(callerVersion, incompatibleVersion)).thenReturn(false);
Set<DiscoveryEntryWithMetaInfo> discoveryEntries = Sets.newHashSet(compatibleEntry, incompatibleEntry);
Set<DiscoveryEntryWithMetaInfo> result = subject.filter(callerVersion, discoveryEntries, null);
assertNotNull(result);
assertEquals(1, result.size());
assertEquals(compatibleEntry, result.iterator().next());
}
Aggregations