use of io.joynr.arbitration.DiscoveryQos in project joynr by bmwcarit.
the class JeeJoynrServiceLocatorTest method testGetWithMessagingAndDiscoveryQos.
@Test
public void testGetWithMessagingAndDiscoveryQos() {
MessagingQos messagingQos = new MessagingQos();
DiscoveryQos discoveryQos = new DiscoveryQos();
MyServiceSync result = subject.get(MyServiceSync.class, "local", messagingQos, discoveryQos);
assertNotNull(result);
String callResult = result.callMe("one");
assertNotNull(callResult);
assertEquals("two", callResult);
verify(myJoynrProxy).callMe("one");
verify(proxyBuilder).setMessagingQos(messagingQos);
verify(proxyBuilder).setDiscoveryQos(discoveryQos);
}
use of io.joynr.arbitration.DiscoveryQos in project joynr by bmwcarit.
the class LocalDiscoveryTest method testRemoteGlobalDiscoveryEntries.
@SuppressWarnings("unchecked")
@Test
public void testRemoteGlobalDiscoveryEntries() {
String testDomain = "testDomain";
String interfaceName = testProxy.INTERFACE_NAME;
final Collection<DiscoveryEntry> discoveryEntries = new HashSet<>();
final List<GlobalDiscoveryEntry> globalDiscoveryEntries = new ArrayList<>();
DiscoveryEntry discoveryEntry = new DiscoveryEntry(VersionUtil.getVersionFromAnnotation(testProxy.class), testDomain, interfaceName, "participantId", new ProviderQos(), System.currentTimeMillis(), System.currentTimeMillis() + 100000, "publicKeyId");
discoveryEntries.add(discoveryEntry);
globalDiscoveryEntries.add(CapabilityUtils.discoveryEntry2GlobalDiscoveryEntry(discoveryEntry, new MqttAddress()));
when(globalDiscoveryEntryCacheMock.lookup(any(String[].class), eq(interfaceName), anyLong())).thenReturn(new HashSet<DiscoveryEntry>());
Mockito.doAnswer(new Answer<Object>() {
@SuppressWarnings("rawtypes")
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
Object[] arguments = invocation.getArguments();
assert (arguments[0] instanceof Callback);
((Callback) arguments[0]).resolve((Object) globalDiscoveryEntries);
return null;
}
}).when(globalCapabilitiesDirectoryClientMock).lookup(any(Callback.class), any(String[].class), eq(interfaceName), anyLong());
ProxyBuilder<testProxy> proxyBuilder = runtime.getProxyBuilder(testDomain, testProxy.class);
final Future<Void> future = new Future<Void>();
DiscoveryQos discoveryQos = new DiscoveryQos();
discoveryQos.setDiscoveryScope(DiscoveryScope.GLOBAL_ONLY);
proxyBuilder.setDiscoveryQos(discoveryQos).build(new ProxyCreatedCallback<testProxy>() {
@Override
public void onProxyCreationFinished(testProxy result) {
future.onSuccess(null);
}
@Override
public void onProxyCreationError(JoynrRuntimeException error) {
future.onFailure(error);
}
});
try {
future.get(5000);
verify(joynrMessagingConnectorFactoryMock).create(anyString(), discoveryEntryWithMetaInfoArgumentCaptor.capture(), any(MessagingQos.class));
assertDiscoveryEntryEqualsCaptured(discoveryEntry);
} catch (Exception e) {
Assert.fail("Unexpected exception from ProxyCreatedCallback: " + e);
}
}
use of io.joynr.arbitration.DiscoveryQos in project joynr by bmwcarit.
the class LocalDiscoveryTest method testLocalDiscoveryEntries.
@Test
public void testLocalDiscoveryEntries() {
String testDomain = "testDomain";
String interfaceName = testProxy.INTERFACE_NAME;
Collection<DiscoveryEntry> discoveryEntries = new HashSet<>();
DiscoveryEntry discoveryEntry = new DiscoveryEntry(VersionUtil.getVersionFromAnnotation(testProxy.class), testDomain, interfaceName, "participantId", new ProviderQos(), System.currentTimeMillis(), System.currentTimeMillis() + 100000, "publicKeyId");
discoveryEntries.add(discoveryEntry);
when(localDiscoveryEntryStoreMock.lookup(any(String[].class), eq(interfaceName))).thenReturn(discoveryEntries);
ProxyBuilder<testProxy> proxyBuilder = runtime.getProxyBuilder(testDomain, testProxy.class);
final Future<Void> future = new Future<Void>();
DiscoveryQos discoveryQos = new DiscoveryQos();
discoveryQos.setDiscoveryScope(DiscoveryScope.LOCAL_ONLY);
proxyBuilder.setDiscoveryQos(discoveryQos).build(new ProxyCreatedCallback<testProxy>() {
@Override
public void onProxyCreationFinished(testProxy result) {
future.onSuccess(null);
}
@Override
public void onProxyCreationError(JoynrRuntimeException error) {
future.onFailure(error);
}
});
try {
future.get(5000);
verify(joynrMessagingConnectorFactoryMock).create(anyString(), discoveryEntryWithMetaInfoArgumentCaptor.capture(), any(MessagingQos.class));
assertDiscoveryEntryEqualsCaptured(discoveryEntry);
} catch (Exception e) {
Assert.fail("Unexpected exception from ProxyCreatedCallback: " + e);
}
}
use of io.joynr.arbitration.DiscoveryQos in project joynr by bmwcarit.
the class ShutdownTest method testProxyCallAfterShutdown.
@Test(expected = JoynrShutdownException.class)
@Ignore
public // test is taking too long because it is attempting to send deregister requests that are not implemented in the mocks
void testProxyCallAfterShutdown() throws DiscoveryException, JoynrIllegalStateException, InterruptedException {
Mockito.when(messageReceiverMock.getChannelId()).thenReturn("ShutdownTestChannelId");
dummyApplication.getRuntime().registerProvider("ShutdownTestdomain", provider, providerQos);
ProxyBuilder<testProxy> proxyBuilder = dummyApplication.getRuntime().getProxyBuilder("ShutdownTestdomain", testProxy.class);
testProxy proxy = proxyBuilder.setDiscoveryQos(new DiscoveryQos(30000, ArbitrationStrategy.HighestPriority, 0)).build();
dummyApplication.shutdown();
proxy.getFirstPrime();
}
use of io.joynr.arbitration.DiscoveryQos in project joynr by bmwcarit.
the class ProxyErrorsTest method setUp.
@Before
public void setUp() {
// the error callback and NoCompatibleProviderFoundException will each increment the permits.
// The test will wait until 2 permits are available, or fail in the junit test timeout time.
waitOnExceptionAndErrorCallbackSemaphore = new Semaphore(-1, true);
domain = "domain-" + UUID.randomUUID().toString();
domain2 = "domain2-" + UUID.randomUUID().toString();
Properties joynrConfig = new Properties();
joynrConfig.setProperty(MessagingPropertyKeys.CHANNELID, "discoverydirectory_channelid");
// provider and proxy using same runtime to allow local-only communications
runtime = getRuntime(joynrConfig);
ProviderQos providerQos = new ProviderQos();
providerQos.setScope(ProviderScope.LOCAL);
runtime.registerProvider(domain, provider, providerQos);
runtime.registerProvider(domain2, provider, providerQos);
discoveryQos = new DiscoveryQos();
discoveryQos.setDiscoveryScope(DiscoveryScope.LOCAL_ONLY);
discoveryQos.setDiscoveryTimeoutMs(1000);
discoveryQos.setRetryIntervalMs(100);
callback = new ProxyCreatedCallback<ProxyErrorsTest.TestProxyWrongVersion>() {
@Override
public void onProxyCreationFinished(TestProxyWrongVersion result) {
fail("proxy creation should fail with a version exception");
}
@Override
public void onProxyCreationError(JoynrRuntimeException error) {
// adds 1 of 2 permits to the semaphore. The other is provided when the exception is caught
waitOnExceptionAndErrorCallbackSemaphore.release();
}
};
}
Aggregations