Search in sources :

Example 21 with ProviderQos

use of joynr.types.ProviderQos 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");
    }
}
Also used : Version(joynr.types.Version) ChannelAddress(joynr.system.RoutingTypes.ChannelAddress) CustomParameter(joynr.types.CustomParameter) DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo) DiscoveryException(io.joynr.exceptions.DiscoveryException) ProviderQos(joynr.types.ProviderQos) Test(org.junit.Test)

Example 22 with ProviderQos

use of joynr.types.ProviderQos in project joynr by bmwcarit.

the class CapabilitiesUtilsTest method testGetMqttAddressFromGlobalDiscoveryEntry.

@Test
public void testGetMqttAddressFromGlobalDiscoveryEntry() {
    GlobalDiscoveryEntry globalDiscoveryEntry = new GlobalDiscoveryEntry(new Version(0, 0), "domain", "interfaceName", "participantId", new ProviderQos(), 0L, 0L, "publicKeyId", "{\"_typeName\":\"joynr.system.RoutingTypes.MqttAddress\",\"brokerUri\":\"tcp://broker:1883\",\"topic\":\"topic\"}");
    Address result = CapabilityUtils.getAddressFromGlobalDiscoveryEntry(globalDiscoveryEntry);
    assertTrue(result instanceof MqttAddress);
    assertEquals("tcp://broker:1883", ((MqttAddress) result).getBrokerUri());
    assertEquals("topic", ((MqttAddress) result).getTopic());
}
Also used : MqttAddress(joynr.system.RoutingTypes.MqttAddress) Address(joynr.system.RoutingTypes.Address) Version(joynr.types.Version) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) ProviderQos(joynr.types.ProviderQos) MqttAddress(joynr.system.RoutingTypes.MqttAddress) Test(org.junit.Test)

Example 23 with ProviderQos

use of joynr.types.ProviderQos in project joynr by bmwcarit.

the class CapabilitiesUtilsTest method testCreateNewGlobalDiscoveryEntry.

@Test
public void testCreateNewGlobalDiscoveryEntry() {
    Version version = new Version(0, 0);
    String domain = "domain";
    String interfaceName = "interfaceName";
    String participantId = "participantId";
    String publicKeyId = "publicKeyId";
    Address mqttAddress = new MqttAddress("tcp://broker:1883", "topic");
    ProviderQos providerQos = new ProviderQos();
    GlobalDiscoveryEntry result = CapabilityUtils.newGlobalDiscoveryEntry(version, domain, interfaceName, participantId, providerQos, 0L, 0L, publicKeyId, mqttAddress);
    assertNotNull(result);
    assertEquals(version, result.getProviderVersion());
    assertEquals(domain, result.getDomain());
    assertEquals(interfaceName, result.getInterfaceName());
    assertEquals(participantId, result.getParticipantId());
    assertEquals(providerQos, result.getQos());
    assertEquals((Long) 0L, result.getLastSeenDateMs());
    assertEquals((Long) 0L, result.getExpiryDateMs());
    assertEquals(publicKeyId, result.getPublicKeyId());
    assertEquals("{\"_typeName\":\"joynr.system.RoutingTypes.MqttAddress\",\"brokerUri\":\"tcp://broker:1883\",\"topic\":\"topic\"}", result.getAddress());
}
Also used : MqttAddress(joynr.system.RoutingTypes.MqttAddress) Address(joynr.system.RoutingTypes.Address) Version(joynr.types.Version) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) ProviderQos(joynr.types.ProviderQos) MqttAddress(joynr.system.RoutingTypes.MqttAddress) Test(org.junit.Test)

Example 24 with ProviderQos

use of joynr.types.ProviderQos in project joynr by bmwcarit.

the class CapabilitiesUtilsTest method createCollectionOfDiscoveryEntriesWithMetaInfo.

private Collection<DiscoveryEntryWithMetaInfo> createCollectionOfDiscoveryEntriesWithMetaInfo() {
    Collection<DiscoveryEntryWithMetaInfo> discoveryEntries = new ArrayList<>(2);
    discoveryEntries.add(new DiscoveryEntryWithMetaInfo(new Version(42, 23), "testDomain1", "testInterfaceName", "testParticipantId1", new ProviderQos(), 4711l, 4712l, "testPublicKeyId1", true));
    discoveryEntries.add(new DiscoveryEntryWithMetaInfo(new Version(42, 23), "testDomain2", "testInterfaceName", "testParticipantId2", new ProviderQos(), 4721l, 4722l, "testPublicKeyId2", false));
    return discoveryEntries;
}
Also used : Version(joynr.types.Version) ArrayList(java.util.ArrayList) DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo) ProviderQos(joynr.types.ProviderQos)

Example 25 with ProviderQos

use of joynr.types.ProviderQos in project joynr by bmwcarit.

the class StaticCapabilitiesProvisioningTest method createDiscoveryEntries.

private Set<DiscoveryEntry> createDiscoveryEntries(String domain, String... interfaceNames) {
    Set<DiscoveryEntry> discoveryEntries = new HashSet<DiscoveryEntry>();
    String participantId = "particpantId";
    ProviderQos qos = new ProviderQos();
    Long lastSeenDateMs = 0L;
    Long expiryDateMs = 0L;
    String publicKeyId = "publicKeyId";
    Address address = new MqttAddress("brokerUri", "topic");
    for (String interfaceName : interfaceNames) {
        GlobalDiscoveryEntry entry = CapabilityUtils.newGlobalDiscoveryEntry(new Version(0, 1), domain, interfaceName, participantId, qos, lastSeenDateMs, expiryDateMs, publicKeyId, address);
        discoveryEntries.add(entry);
    }
    return discoveryEntries;
}
Also used : DiscoveryEntry(joynr.types.DiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) ChannelAddress(joynr.system.RoutingTypes.ChannelAddress) MqttAddress(joynr.system.RoutingTypes.MqttAddress) Address(joynr.system.RoutingTypes.Address) Version(joynr.types.Version) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) ProviderQos(joynr.types.ProviderQos) HashSet(java.util.HashSet) MqttAddress(joynr.system.RoutingTypes.MqttAddress)

Aggregations

ProviderQos (joynr.types.ProviderQos)69 Version (joynr.types.Version)43 Test (org.junit.Test)37 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)27 DiscoveryEntry (joynr.types.DiscoveryEntry)25 DiscoveryEntryWithMetaInfo (joynr.types.DiscoveryEntryWithMetaInfo)24 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)21 Matchers.anyString (org.mockito.Matchers.anyString)16 ArrayList (java.util.ArrayList)15 ChannelAddress (joynr.system.RoutingTypes.ChannelAddress)13 Before (org.junit.Before)13 Callback (io.joynr.proxy.Callback)12 HashSet (java.util.HashSet)11 MqttAddress (joynr.system.RoutingTypes.MqttAddress)10 InvocationOnMock (org.mockito.invocation.InvocationOnMock)10 Address (joynr.system.RoutingTypes.Address)9 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)8 MessagingQos (io.joynr.messaging.MessagingQos)8 Properties (java.util.Properties)8 DiscoveryException (io.joynr.exceptions.DiscoveryException)7