Search in sources :

Example 61 with JoynrRuntimeException

use of io.joynr.exceptions.JoynrRuntimeException in project joynr by bmwcarit.

the class AbstractProviderProxyEnd2EndTest method testVoidOperation.

@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void testVoidOperation() throws DiscoveryException, JoynrIllegalStateException, InterruptedException, JoynrWaitExpiredException, ApplicationException {
    ProxyBuilder<testProxy> proxyBuilder = consumerRuntime.getProxyBuilder(domain, testProxy.class);
    testProxy proxy = proxyBuilder.setMessagingQos(messagingQos).setDiscoveryQos(discoveryQos).build();
    final Future<Boolean> future = new Future<Boolean>();
    proxy.voidOperation(new Callback<Void>() {

        @Override
        public void onSuccess(Void result) {
            future.onSuccess(true);
        }

        @Override
        public void onFailure(JoynrRuntimeException error) {
            future.onFailure(error);
        }
    });
    Boolean reply = future.get(8000);
    assertTrue(reply);
}
Also used : joynr.tests.testProxy(joynr.tests.testProxy) Future(io.joynr.proxy.Future) DeferredVoid(io.joynr.provider.DeferredVoid) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) Test(org.junit.Test)

Example 62 with JoynrRuntimeException

use of io.joynr.exceptions.JoynrRuntimeException in project joynr by bmwcarit.

the class AbstractProviderProxyEnd2EndTest method syncMethodCallReturnsExtendedErrorEnum.

@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void syncMethodCallReturnsExtendedErrorEnum() {
    ProxyBuilder<testProxy> proxyBuilder = consumerRuntime.getProxyBuilder(domain, testProxy.class);
    testProxy proxy = proxyBuilder.setMessagingQos(messagingQos).setDiscoveryQos(discoveryQos).build();
    try {
        proxy.methodWithErrorEnumExtended();
        fail("Should throw ApplicationException");
    } catch (JoynrRuntimeException e) {
        fail(e.toString());
    } catch (ApplicationException e) {
        ApplicationException expected = new ApplicationException(MethodWithErrorEnumExtendedErrorEnum.IMPLICIT_ERROR_TYPECOLLECTION);
        assertEquals(expected, e);
    }
}
Also used : ApplicationException(joynr.exceptions.ApplicationException) joynr.tests.testProxy(joynr.tests.testProxy) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) Test(org.junit.Test)

Example 63 with JoynrRuntimeException

use of io.joynr.exceptions.JoynrRuntimeException in project joynr by bmwcarit.

the class AbstractProviderProxyEnd2EndTest method calledMethodReturnsMultipleOutputParametersAsyncFuture.

@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void calledMethodReturnsMultipleOutputParametersAsyncFuture() throws Exception {
    ProxyBuilder<testProxy> proxyBuilder = consumerRuntime.getProxyBuilder(domain, testProxy.class);
    testProxy proxy = proxyBuilder.setMessagingQos(messagingQos).setDiscoveryQos(discoveryQos).build();
    Future<MethodWithMultipleOutputParametersReturned> future = proxy.methodWithMultipleOutputParameters(new MethodWithMultipleOutputParametersCallback() {

        @Override
        public void onFailure(JoynrRuntimeException error) {
            logger.error("error in calledMethodReturnsMultipleOutputParametersAsyncCallback", error);
        }

        @Override
        public void onSuccess(String aString, Integer aNumber, GpsLocation aComplexDataType, TestEnum anEnumResult) {
            assertEquals(TEST_INTEGER, aNumber);
            assertEquals(TEST_STRING, aString);
            assertEquals(TEST_COMPLEXTYPE, aComplexDataType);
            assertEquals(TEST_ENUM, anEnumResult);
        }
    });
    MethodWithMultipleOutputParametersReturned reply = future.get();
    assertEquals(TEST_INTEGER, reply.aNumber);
    assertEquals(TEST_STRING, reply.aString);
    assertEquals(TEST_COMPLEXTYPE, reply.aComplexDataType);
    assertEquals(TEST_ENUM, reply.anEnumResult);
}
Also used : MethodWithMultipleOutputParametersReturned(joynr.tests.testSync.MethodWithMultipleOutputParametersReturned) joynr.tests.testProxy(joynr.tests.testProxy) GpsLocation(joynr.types.Localisation.GpsLocation) TestEnum(joynr.tests.testTypes.TestEnum) MethodWithMultipleOutputParametersCallback(joynr.tests.testAsync.MethodWithMultipleOutputParametersCallback) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) Test(org.junit.Test)

Example 64 with JoynrRuntimeException

use of io.joynr.exceptions.JoynrRuntimeException in project joynr by bmwcarit.

the class AbstractSubscriptionEnd2EndTest method testSubscribeToNonExistentDomain.

@edu.umd.cs.findbugs.annotations.SuppressWarnings(value = "NP_NULL_ON_SOME_PATH_EXCEPTION", justification = "NPE in test would fail test")
@SuppressWarnings("unchecked")
@Ignore
@Test
public void testSubscribeToNonExistentDomain() throws InterruptedException {
    AttributeSubscriptionListener<Integer> integerListener = mock(AttributeSubscriptionListener.class);
    testProxy proxyToNonexistentDomain = null;
    try {
        ProxyBuilder<testProxy> proxyBuilder;
        String nonExistentDomain = UUID.randomUUID().toString() + "-domaindoesnotexist-end2end";
        MessagingQos messagingQos = new MessagingQos(20000);
        DiscoveryQos discoveryQos = new DiscoveryQos(50000, ArbitrationStrategy.HighestPriority, Long.MAX_VALUE);
        proxyBuilder = consumerRuntime.getProxyBuilder(nonExistentDomain, testProxy.class);
        proxyToNonexistentDomain = proxyBuilder.setMessagingQos(messagingQos).setDiscoveryQos(discoveryQos).build();
    } catch (DiscoveryException e) {
        logger.error(e.getMessage(), e);
    } catch (JoynrIllegalStateException e) {
        logger.error(e.getMessage(), e);
    }
    // This should not cause an exception
    PeriodicSubscriptionQos subscriptionQos = new PeriodicSubscriptionQos();
    subscriptionQos.setPeriodMs(PERIOD_MS);
    subscriptionQos.setValidityMs(30000);
    subscriptionQos.setAlertAfterIntervalMs(0);
    subscriptionQos.setPublicationTtlMs(0);
    Future<String> subscriptionId = proxyToNonexistentDomain.subscribeToTestAttribute(integerListener, subscriptionQos);
    Thread.sleep(4000);
    try {
        proxyToNonexistentDomain.unsubscribeFromTestAttribute(subscriptionId.get(FUTURE_SUBSCRIPTION_ID_TIMEOUTMS));
    } catch (JoynrRuntimeException | ApplicationException e) {
        assertTrue(e.getMessage(), e != null);
    }
    getSubscriptionTestsPublisher().waitForAttributeUnsubscription("testAttribute");
}
Also used : joynr.tests.testProxy(joynr.tests.testProxy) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) DiscoveryQos(io.joynr.arbitration.DiscoveryQos) JoynrIllegalStateException(io.joynr.exceptions.JoynrIllegalStateException) PeriodicSubscriptionQos(joynr.PeriodicSubscriptionQos) MessagingQos(io.joynr.messaging.MessagingQos) ApplicationException(joynr.exceptions.ApplicationException) DiscoveryException(io.joynr.exceptions.DiscoveryException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 65 with JoynrRuntimeException

use of io.joynr.exceptions.JoynrRuntimeException in project joynr by bmwcarit.

the class AccessControllerEnd2EndTest method createProxy.

private testProxy createProxy(JoynrRuntime runtime) {
    DiscoveryQos discoveryQos = new DiscoveryQos();
    discoveryQos.setDiscoveryScope(DiscoveryScope.LOCAL_ONLY);
    discoveryQos.setArbitrationStrategy(ArbitrationStrategy.HighestPriority);
    discoveryQos.setDiscoveryTimeoutMs(DISCOVERY_TIMEOUT);
    MessagingQos messagingQos = new MessagingQos();
    messagingQos.setTtl_ms(MESSAGING_TTL);
    final Future<Void> future = new Future<Void>();
    testProxy testProxy;
    testProxy = runtime.getProxyBuilder(TEST_DOMAIN, testProxy.class).setDiscoveryQos(discoveryQos).setMessagingQos(messagingQos).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);
    } catch (Exception e) {
        Assert.fail("Unexpected exception from ProxyCreatedCallback: " + e);
    }
    return testProxy;
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) joynr.tests.testProxy(joynr.tests.testProxy) Future(io.joynr.proxy.Future) ProxyCreatedCallback(io.joynr.proxy.ProxyBuilder.ProxyCreatedCallback) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) DiscoveryQos(io.joynr.arbitration.DiscoveryQos) JoynrMessageNotSentException(io.joynr.exceptions.JoynrMessageNotSentException) ExpectedException(org.junit.rules.ExpectedException) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException)

Aggregations

JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)76 Test (org.junit.Test)41 ApplicationException (joynr.exceptions.ApplicationException)18 joynr.tests.testProxy (joynr.tests.testProxy)16 MessagingQos (io.joynr.messaging.MessagingQos)14 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)13 Callback (io.joynr.proxy.Callback)9 Future (io.joynr.proxy.Future)9 ProviderRuntimeException (joynr.exceptions.ProviderRuntimeException)9 IOException (java.io.IOException)8 Semaphore (java.util.concurrent.Semaphore)8 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)8 InvocationOnMock (org.mockito.invocation.InvocationOnMock)8 DiscoveryException (io.joynr.exceptions.DiscoveryException)7 JoynrException (io.joynr.exceptions.JoynrException)7 DeferredVoid (io.joynr.provider.DeferredVoid)7 HashSet (java.util.HashSet)7 ProviderQos (joynr.types.ProviderQos)7 JoynrIllegalStateException (io.joynr.exceptions.JoynrIllegalStateException)5 ProxyCreatedCallback (io.joynr.proxy.ProxyBuilder.ProxyCreatedCallback)5