Search in sources :

Example 16 with GlobalDiscoveryEntry

use of joynr.types.GlobalDiscoveryEntry 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);
}
Also used : Version(joynr.types.Version) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) ProviderQos(joynr.types.ProviderQos) MqttAddress(joynr.system.RoutingTypes.MqttAddress) Test(org.junit.Test)

Example 17 with GlobalDiscoveryEntry

use of joynr.types.GlobalDiscoveryEntry 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 18 with GlobalDiscoveryEntry

use of joynr.types.GlobalDiscoveryEntry 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 19 with GlobalDiscoveryEntry

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

the class StaticCapabilitiesProvisioningTest method assertContainsEntryFor.

private void assertContainsEntryFor(Collection<DiscoveryEntry> entries, String interfaceName, String participantId, String url) {
    boolean found = false;
    for (DiscoveryEntry entry : entries) {
        if (entry instanceof GlobalDiscoveryEntry) {
            GlobalDiscoveryEntry globalDiscoveryEntry = (GlobalDiscoveryEntry) entry;
            if (globalDiscoveryEntry.getInterfaceName().equals(interfaceName) && (participantId == null || participantId.equals(globalDiscoveryEntry.getParticipantId()))) {
                if (url != null) {
                    Address address = CapabilityUtils.getAddressFromGlobalDiscoveryEntry(globalDiscoveryEntry);
                    assertTrue(address instanceof ChannelAddress);
                    assertEquals(url, ((ChannelAddress) address).getMessagingEndpointUrl());
                }
                found = true;
            }
        }
    }
    assertTrue("Couldn't find " + interfaceName + ((participantId == null ? "" : " / " + participantId)) + " in " + entries, found);
}
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) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) ChannelAddress(joynr.system.RoutingTypes.ChannelAddress)

Example 20 with GlobalDiscoveryEntry

use of joynr.types.GlobalDiscoveryEntry 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

GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)45 Test (org.junit.Test)28 DiscoveryEntry (joynr.types.DiscoveryEntry)21 ProviderQos (joynr.types.ProviderQos)20 Version (joynr.types.Version)19 Callback (io.joynr.proxy.Callback)15 Matchers.anyString (org.mockito.Matchers.anyString)14 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)12 ArrayList (java.util.ArrayList)12 MqttAddress (joynr.system.RoutingTypes.MqttAddress)9 DeferredVoid (io.joynr.provider.DeferredVoid)8 Address (joynr.system.RoutingTypes.Address)6 InvocationOnMock (org.mockito.invocation.InvocationOnMock)6 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)5 ChannelAddress (joynr.system.RoutingTypes.ChannelAddress)5 DiscoveryEntryWithMetaInfo (joynr.types.DiscoveryEntryWithMetaInfo)5 List (java.util.List)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 MessagingQos (io.joynr.messaging.MessagingQos)3 Promise (io.joynr.provider.Promise)3