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;
}
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);
}
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);
}
}
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));
}
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) {
}
});
}
Aggregations