Search in sources :

Example 56 with Version

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

the class CapabilitiesUtilsTest method createCollectionOfDiscoveryEntries.

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

Example 57 with Version

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

the class CapabilitiesUtilsTest method testConvertLocalDiscoveryEntryToDiscoveryEntryWithMetaInfo.

@Test
public void testConvertLocalDiscoveryEntryToDiscoveryEntryWithMetaInfo() {
    boolean isLocal = true;
    DiscoveryEntry discoveryEntry = new DiscoveryEntry(new Version(42, 23), "testDomain", "testInterfaceName", "testParticipantId", new ProviderQos(), 4711l, 4712l, "testPublicKeyId");
    DiscoveryEntryWithMetaInfo convertedDiscoveryEntry = CapabilityUtils.convertToDiscoveryEntryWithMetaInfo(isLocal, discoveryEntry);
    compareDiscoveryEntries(isLocal, discoveryEntry, convertedDiscoveryEntry);
}
Also used : DiscoveryEntry(joynr.types.DiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) Version(joynr.types.Version) DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo) ProviderQos(joynr.types.ProviderQos) Test(org.junit.Test)

Example 58 with Version

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

the class LegacyCapabilitiesProvisioning method createDiscoveryEntryFor.

private void createDiscoveryEntryFor(Class<?> interfaceClass, String interfaceName, String channelId, String participantId, String urlForAddress, String localChannelId, String domain) {
    boolean hasUrl = isPresent(urlForAddress);
    boolean hasParticipantId = isPresent(participantId);
    if (hasUrl && !hasParticipantId) {
        throw new IllegalArgumentException(format("When configuring the discovery directory or domain access controller " + "via properties, you must provide both a URL and a participant ID per service.%n" + "You provided the URL '%s' and the participant ID '%s' for the service %s.%n" + "Please complete the configuration and restart the application.", urlForAddress, participantId, interfaceName));
    }
    if (hasParticipantId && hasUrl && isPresent(channelId) && isPresent(domain)) {
        Address address;
        if (localChannelId.equals(channelId)) {
            address = new InProcessAddress();
        } else if (urlForAddress.startsWith("tcp") || urlForAddress.startsWith("mqtt")) {
            address = new MqttAddress(urlForAddress, channelId);
        } else {
            address = new ChannelAddress(urlForAddress, channelId);
        }
        DiscoveryEntry discoveryEntry = CapabilityUtils.newGlobalDiscoveryEntry(new Version(0, 1), domain, interfaceName, participantId, new ProviderQos(), System.currentTimeMillis(), Long.MAX_VALUE, "", address);
        logger.debug("Created legacy discovery entry: {}", discoveryEntry);
        legacyDiscoveryEntries.put(interfaceClass, discoveryEntry);
        legacyAddresses.put(interfaceClass, address);
    } else {
        logger.trace("Insufficient properties data to create entry for interface {}", interfaceName);
    }
}
Also used : DiscoveryEntry(joynr.types.DiscoveryEntry) ChannelAddress(joynr.system.RoutingTypes.ChannelAddress) InProcessAddress(io.joynr.messaging.inprocess.InProcessAddress) MqttAddress(joynr.system.RoutingTypes.MqttAddress) Address(joynr.system.RoutingTypes.Address) InProcessAddress(io.joynr.messaging.inprocess.InProcessAddress) Version(joynr.types.Version) ChannelAddress(joynr.system.RoutingTypes.ChannelAddress) ProviderQos(joynr.types.ProviderQos) MqttAddress(joynr.system.RoutingTypes.MqttAddress)

Example 59 with Version

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

the class LocalCapabilitiesDirectoryTest method addLocalOnlyCapability.

@SuppressWarnings("unchecked")
@Test(timeout = 2000)
public void addLocalOnlyCapability() throws InterruptedException {
    ProviderQos providerQos = new ProviderQos();
    providerQos.setScope(ProviderScope.LOCAL);
    globalDiscoveryEntry = new GlobalDiscoveryEntry(new Version(47, 11), "test", TestInterface.INTERFACE_NAME, "participantId", providerQos, System.currentTimeMillis(), expiryDateMs, publicKeyId, channelAddressSerialized);
    localCapabilitiesDirectory.add(discoveryEntry);
    Thread.sleep(1000);
    verify(globalCapabilitiesClient, never()).add(any(Callback.class), any(GlobalDiscoveryEntry.class));
}
Also used : Callback(io.joynr.proxy.Callback) Version(joynr.types.Version) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) ProviderQos(joynr.types.ProviderQos) Test(org.junit.Test)

Example 60 with Version

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

the class LocalCapabilitiesDirectoryTest method addGlobalCapFails_NextAddShallAddGlobalAgain.

@SuppressWarnings("unchecked")
@Test(timeout = 1000)
public void addGlobalCapFails_NextAddShallAddGlobalAgain() throws InterruptedException {
    ProviderQos providerQos = new ProviderQos();
    providerQos.setScope(ProviderScope.GLOBAL);
    String participantId = LocalCapabilitiesDirectoryTest.class.getName() + ".addLocalAndThanGlobalShallWork";
    String domain = "testDomain";
    final DiscoveryEntry discoveryEntry = new DiscoveryEntry(new Version(47, 11), domain, TestInterface.INTERFACE_NAME, participantId, providerQos, System.currentTimeMillis(), expiryDateMs, publicKeyId);
    globalDiscoveryEntry = new GlobalDiscoveryEntry(new Version(47, 11), domain, TestInterface.INTERFACE_NAME, participantId, providerQos, System.currentTimeMillis(), expiryDateMs, publicKeyId, channelAddressSerialized);
    Mockito.doAnswer(createAddAnswerWithError()).when(globalCapabilitiesClient).add(any(Callback.class), eq(globalDiscoveryEntry));
    Promise<DeferredVoid> promise = localCapabilitiesDirectory.add(discoveryEntry);
    promise.then(new PromiseListener() {

        @Override
        public void onFulfillment(Object... values) {
            verify(globalDiscoveryEntryCacheMock, never()).add(eq(globalDiscoveryEntry));
            verify(globalCapabilitiesClient).add(any(Callback.class), eq(globalDiscoveryEntry));
            reset(globalCapabilitiesClient);
            localCapabilitiesDirectory.add(discoveryEntry);
            verify(globalCapabilitiesClient, timeout(200)).add(any(Callback.class), eq(globalDiscoveryEntry));
        }

        @Override
        public void onRejection(JoynrException error) {
        }
    });
}
Also used : DiscoveryEntry(joynr.types.DiscoveryEntry) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) PromiseListener(io.joynr.provider.PromiseListener) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) JoynrException(io.joynr.exceptions.JoynrException) Matchers.anyString(org.mockito.Matchers.anyString) DeferredVoid(io.joynr.provider.DeferredVoid) Callback(io.joynr.proxy.Callback) Version(joynr.types.Version) ProviderQos(joynr.types.ProviderQos) Test(org.junit.Test)

Aggregations

Version (joynr.types.Version)65 Test (org.junit.Test)47 ProviderQos (joynr.types.ProviderQos)43 DiscoveryEntryWithMetaInfo (joynr.types.DiscoveryEntryWithMetaInfo)29 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)24 DiscoveryEntry (joynr.types.DiscoveryEntry)22 ArrayList (java.util.ArrayList)13 ChannelAddress (joynr.system.RoutingTypes.ChannelAddress)13 Matchers.anyString (org.mockito.Matchers.anyString)12 Callback (io.joynr.proxy.Callback)11 HashSet (java.util.HashSet)11 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)10 InvocationOnMock (org.mockito.invocation.InvocationOnMock)10 JoynrVersion (io.joynr.JoynrVersion)9 Address (joynr.system.RoutingTypes.Address)9 HashMap (java.util.HashMap)8 MqttAddress (joynr.system.RoutingTypes.MqttAddress)8 DiscoveryException (io.joynr.exceptions.DiscoveryException)7 Set (java.util.Set)7 DeferredVoid (io.joynr.provider.DeferredVoid)6