Search in sources :

Example 26 with JoynrRuntimeException

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

the class AbstractProviderProxyEnd2EndTest method asyncMethodCallReturnsErrorEnum.

@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void asyncMethodCallReturnsErrorEnum() {
    ProxyBuilder<testProxy> proxyBuilder = consumerRuntime.getProxyBuilder(domain, testProxy.class);
    testProxy proxy = proxyBuilder.setMessagingQos(messagingQos).setDiscoveryQos(discoveryQos).build();
    ApplicationException expected = new ApplicationException(ErrorEnumBase.BASE_ERROR_TYPECOLLECTION);
    Future<Void> future = proxy.methodWithErrorEnum(callbackWithApplicationExceptionErrorEnumBase);
    try {
        future.get();
        fail("Should throw ApplicationException");
    } catch (JoynrRuntimeException | InterruptedException e) {
        fail(e.toString());
    } catch (ApplicationException e) {
        assertEquals(expected, e);
    }
    verify(callbackWithApplicationExceptionErrorEnumBase).onFailure((ErrorEnumBase) (expected.getError()));
}
Also used : ApplicationException(joynr.exceptions.ApplicationException) joynr.tests.testProxy(joynr.tests.testProxy) DeferredVoid(io.joynr.provider.DeferredVoid) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) Test(org.junit.Test)

Example 27 with JoynrRuntimeException

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

the class AbstractProviderProxyEnd2EndTest method syncMethodCallReturnsImplicitErrorEnum.

@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void syncMethodCallReturnsImplicitErrorEnum() {
    ProxyBuilder<testProxy> proxyBuilder = consumerRuntime.getProxyBuilder(domain, testProxy.class);
    testProxy proxy = proxyBuilder.setMessagingQos(messagingQos).setDiscoveryQos(discoveryQos).build();
    try {
        proxy.methodWithImplicitErrorEnum();
        fail("Should throw ApplicationException");
    } catch (JoynrRuntimeException e) {
        fail(e.toString());
    } catch (ApplicationException e) {
        ApplicationException expected = new ApplicationException(MethodWithImplicitErrorEnumErrorEnum.IMPLICIT_ERROR);
        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 28 with JoynrRuntimeException

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

the class AbstractProviderProxyEnd2EndTest method calledMethodReturnsMultipleOutputParametersAsyncCallback.

@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void calledMethodReturnsMultipleOutputParametersAsyncCallback() throws Exception {
    ProxyBuilder<testProxy> proxyBuilder = consumerRuntime.getProxyBuilder(domain, testProxy.class);
    testProxy proxy = proxyBuilder.setMessagingQos(messagingQos).setDiscoveryQos(discoveryQos).build();
    final Object untilCallbackFinished = new Object();
    final Map<String, Object> result = new HashMap<String, Object>();
    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) {
            result.put("receivedString", aString);
            result.put("receivedNumber", aNumber);
            result.put("receivedComplexDataType", aComplexDataType);
            result.put("receivedEnum", anEnumResult);
            synchronized (untilCallbackFinished) {
                untilCallbackFinished.notify();
            }
        }
    });
    synchronized (untilCallbackFinished) {
        untilCallbackFinished.wait(CONST_DEFAULT_TEST_TIMEOUT);
    }
    assertEquals(TEST_INTEGER, result.get("receivedNumber"));
    assertEquals(TEST_STRING, result.get("receivedString"));
    assertEquals(TEST_COMPLEXTYPE, result.get("receivedComplexDataType"));
    assertEquals(TEST_ENUM, result.get("receivedEnum"));
}
Also used : HashMap(java.util.HashMap) 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 29 with JoynrRuntimeException

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

the class AbstractProviderProxyEnd2EndTest method asyncMethodCallWithByteBuffer.

@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void asyncMethodCallWithByteBuffer() throws JoynrWaitExpiredException, JoynrRuntimeException, InterruptedException, ApplicationException {
    ProxyBuilder<testProxy> proxyBuilder = consumerRuntime.getProxyBuilder(domain, testProxy.class);
    testProxy proxy = proxyBuilder.setMessagingQos(messagingQos).setDiscoveryQos(discoveryQos).build();
    Byte[] input = { 1, 2, 3 };
    Future<Byte[]> future = proxy.methodWithByteBuffer(new Callback<Byte[]>() {

        @Override
        public void onFailure(JoynrRuntimeException error) {
            fail("byteBuffer was not returned correctly");
        }

        @Override
        public void onSuccess(Byte[] result) {
        }
    }, input);
    Byte[] result = future.get();
    assertArrayEquals(input, result);
}
Also used : joynr.tests.testProxy(joynr.tests.testProxy) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) Test(org.junit.Test)

Example 30 with JoynrRuntimeException

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

the class GlobalCapabilitiesDirectoryClientTest method testLookupDomainsOnFailure.

@Test
public void testLookupDomainsOnFailure() {
    @SuppressWarnings("unchecked") Callback<List<GlobalDiscoveryEntry>> callbackListOfGlobalDiscoveryEntriesMock = (Callback<List<GlobalDiscoveryEntry>>) mock(Callback.class);
    Callback<GlobalDiscoveryEntry[]> callback = lookupDomainsHelper(callbackListOfGlobalDiscoveryEntriesMock);
    JoynrRuntimeException error = new JoynrRuntimeException();
    callback.onFailure(error);
    verify(callbackListOfGlobalDiscoveryEntriesMock).onFailure(eq(error));
    verify(callbackListOfGlobalDiscoveryEntriesMock, times(0)).onSuccess(anyListOf(GlobalDiscoveryEntry.class));
}
Also used : Callback(io.joynr.proxy.Callback) GlobalDiscoveryEntry(joynr.types.GlobalDiscoveryEntry) ArrayList(java.util.ArrayList) List(java.util.List) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) Test(org.junit.Test)

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