use of joynr.exceptions.ProviderRuntimeException in project joynr by bmwcarit.
the class AbstractProviderProxyEnd2EndTest method asyncGetAttributeWithProviderRuntimeException.
@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void asyncGetAttributeWithProviderRuntimeException() {
ProxyBuilder<testProxy> proxyBuilder = consumerRuntime.getProxyBuilder(domain, testProxy.class);
testProxy proxy = proxyBuilder.setMessagingQos(messagingQos).setDiscoveryQos(discoveryQos).build();
ProviderRuntimeException expected = new ProviderRuntimeException("ProviderRuntimeException");
Future<Integer> future = proxy.getAttributeWithProviderRuntimeException(callbackInteger);
try {
future.get();
fail("Should throw ProviderRuntimeException");
} catch (ProviderRuntimeException e) {
assertEquals(expected, e);
} catch (Exception e) {
fail(e.toString());
}
verify(callbackInteger).onFailure(expected);
}
use of joynr.exceptions.ProviderRuntimeException in project joynr by bmwcarit.
the class AbstractSubscriptionEnd2EndTest method subscribeToAttributeWithProviderRuntimeException.
@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void subscribeToAttributeWithProviderRuntimeException() throws InterruptedException, ApplicationException {
Semaphore onErrorSemaphore = new Semaphore(0);
ProviderRuntimeException expectedException = new ProviderRuntimeException(SubscriptionTestsProviderImpl.MESSAGE_PROVIDERRUNTIMEEXCEPTION);
AttributeSubscriptionListener<Integer> listener = prepareOnErrorListenerMock(onErrorSemaphore, expectedException);
int periods = 2;
int subscriptionDuration = (PERIOD_MS * periods);
PeriodicSubscriptionQos subscriptionQos = new PeriodicSubscriptionQos();
subscriptionQos.setPeriodMs(PERIOD_MS);
subscriptionQos.setValidityMs(subscriptionDuration);
subscriptionQos.setAlertAfterIntervalMs(1000);
subscriptionQos.setPublicationTtlMs(0);
Future<String> subscriptionId = proxy.subscribeToAttributeWithProviderRuntimeException(listener, subscriptionQos);
long timeBeforeTest = System.currentTimeMillis();
long timeout = subscriptionDuration + EXPECTED_LATENCY_MS;
// expect at least #periods errors
assertTrue(onErrorSemaphore.tryAcquire(periods, timeout, TimeUnit.MILLISECONDS));
// expect at most #periods+1 errors
timeout = Math.max(timeout - (System.currentTimeMillis() - timeBeforeTest), 100);
assertFalse(onErrorSemaphore.tryAcquire(2, timeout, TimeUnit.MILLISECONDS));
// expect no successful subscription callback
verify(listener, times(0)).onReceive(anyInt());
proxy.unsubscribeFromAttributeWithProviderRuntimeException(subscriptionId.get(FUTURE_SUBSCRIPTION_ID_TIMEOUTMS));
}
use of joynr.exceptions.ProviderRuntimeException in project joynr by bmwcarit.
the class AbstractSubscriptionEnd2EndTest method subscribeToAttributeWithThrownException.
@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void subscribeToAttributeWithThrownException() throws InterruptedException, ApplicationException {
Semaphore onErrorSemaphore = new Semaphore(0);
ProviderRuntimeException expectedException = new ProviderRuntimeException(new IllegalArgumentException(SubscriptionTestsProviderImpl.MESSAGE_THROWN_PROVIDERRUNTIMEEXCEPTION).toString());
AttributeSubscriptionListener<Integer> listener = prepareOnErrorListenerMock(onErrorSemaphore, expectedException);
int periods = 2;
int subscriptionDuration = (PERIOD_MS * periods);
PeriodicSubscriptionQos subscriptionQos = new PeriodicSubscriptionQos();
subscriptionQos.setPeriodMs(PERIOD_MS);
subscriptionQos.setValidityMs(subscriptionDuration);
subscriptionQos.setAlertAfterIntervalMs(1000);
subscriptionQos.setPublicationTtlMs(0);
Future<String> subscriptionId = proxy.subscribeToAttributeWithThrownException(listener, subscriptionQos);
long timeBeforeTest = System.currentTimeMillis();
long timeout = subscriptionDuration + EXPECTED_LATENCY_MS;
// expect at least #periods errors
assertTrue(onErrorSemaphore.tryAcquire(periods, timeout, TimeUnit.MILLISECONDS));
// expect at most #periods+1 errors
timeout = Math.max(timeout - (System.currentTimeMillis() - timeBeforeTest), 100);
assertFalse(onErrorSemaphore.tryAcquire(2, timeout, TimeUnit.MILLISECONDS));
// expect no successful subscription callback
verify(listener, times(0)).onReceive(anyInt());
proxy.unsubscribeFromAttributeWithThrownException(subscriptionId.get(FUTURE_SUBSCRIPTION_ID_TIMEOUTMS));
}
use of joynr.exceptions.ProviderRuntimeException in project joynr by bmwcarit.
the class SubscriptionTestsProviderImpl method getAttributeWithProviderRuntimeException.
@Override
public Promise<Deferred<Integer>> getAttributeWithProviderRuntimeException() {
Deferred<Integer> deferred = new Deferred<Integer>();
ProviderRuntimeException error = new ProviderRuntimeException(MESSAGE_PROVIDERRUNTIMEEXCEPTION);
deferred.reject(error);
return new Promise<Deferred<Integer>>(deferred);
}
use of joynr.exceptions.ProviderRuntimeException in project joynr by bmwcarit.
the class DummyCapabilitiesDirectory method lookup.
@Override
public Promise<Lookup1Deferred> lookup(String[] domains, String interfaceName, joynr.types.DiscoveryQos discoveryQos) {
final Lookup1Deferred deferred = new Lookup1Deferred();
CapabilitiesCallback callback = new CapabilitiesCallback() {
@Override
public void processCapabilitiesReceived(@CheckForNull Collection<DiscoveryEntryWithMetaInfo> capabilities) {
if (capabilities != null) {
deferred.resolve(capabilities.toArray(new DiscoveryEntryWithMetaInfo[0]));
} else {
deferred.reject(new ProviderRuntimeException("Received capabilities list was null"));
}
}
@Override
public void onError(Throwable e) {
deferred.reject(new ProviderRuntimeException(e.toString()));
}
};
DiscoveryScope discoveryScope = DiscoveryScope.valueOf(discoveryQos.getDiscoveryScope().name());
lookup(domains, interfaceName, new DiscoveryQos(30000, ArbitrationStrategy.NotSet, discoveryQos.getCacheMaxAge(), discoveryScope), callback);
return new Promise<Lookup1Deferred>(deferred);
}
Aggregations