Search in sources :

Example 61 with ProviderRuntimeException

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);
}
Also used : joynr.tests.testProxy(joynr.tests.testProxy) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) JoynrIllegalStateException(io.joynr.exceptions.JoynrIllegalStateException) JoynrTimeoutException(io.joynr.exceptions.JoynrTimeoutException) DiscoveryException(io.joynr.exceptions.DiscoveryException) JoynrWaitExpiredException(io.joynr.exceptions.JoynrWaitExpiredException) ApplicationException(joynr.exceptions.ApplicationException) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException) Test(org.junit.Test)

Example 62 with ProviderRuntimeException

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));
}
Also used : Semaphore(java.util.concurrent.Semaphore) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException) PeriodicSubscriptionQos(joynr.PeriodicSubscriptionQos) Test(org.junit.Test)

Example 63 with ProviderRuntimeException

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));
}
Also used : Semaphore(java.util.concurrent.Semaphore) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException) PeriodicSubscriptionQos(joynr.PeriodicSubscriptionQos) Test(org.junit.Test)

Example 64 with ProviderRuntimeException

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);
}
Also used : Promise(io.joynr.provider.Promise) Deferred(io.joynr.provider.Deferred) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException)

Example 65 with ProviderRuntimeException

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);
}
Also used : Promise(io.joynr.provider.Promise) DiscoveryScope(io.joynr.arbitration.DiscoveryScope) CheckForNull(javax.annotation.CheckForNull) Collection(java.util.Collection) DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo) ProviderRuntimeException(joynr.exceptions.ProviderRuntimeException) DiscoveryQos(io.joynr.arbitration.DiscoveryQos)

Aggregations

ProviderRuntimeException (joynr.exceptions.ProviderRuntimeException)67 Promise (io.joynr.provider.Promise)27 ApplicationException (joynr.exceptions.ApplicationException)23 Test (org.junit.Test)21 MapStringString (joynr.interlanguagetest.namedTypeCollection2.MapStringString)19 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)13 DiscoveryException (io.joynr.exceptions.DiscoveryException)10 DeferredVoid (io.joynr.provider.DeferredVoid)10 JoynrIllegalStateException (io.joynr.exceptions.JoynrIllegalStateException)8 JoynrTimeoutException (io.joynr.exceptions.JoynrTimeoutException)8 JoynrWaitExpiredException (io.joynr.exceptions.JoynrWaitExpiredException)8 joynr.tests.testProxy (joynr.tests.testProxy)8 ExtendedExtendedBaseStruct (joynr.interlanguagetest.namedTypeCollection2.ExtendedExtendedBaseStruct)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 JoynrException (io.joynr.exceptions.JoynrException)4 ExtendedBaseStruct (joynr.interlanguagetest.namedTypeCollection2.ExtendedBaseStruct)4 JoynrVersion (io.joynr.JoynrVersion)3 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)3 Deferred (io.joynr.provider.Deferred)3 PromiseListener (io.joynr.provider.PromiseListener)3