Search in sources :

Example 1 with MethodWithMultipleOutputParametersCallback

use of joynr.tests.testAsync.MethodWithMultipleOutputParametersCallback 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 2 with MethodWithMultipleOutputParametersCallback

use of joynr.tests.testAsync.MethodWithMultipleOutputParametersCallback 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)

Aggregations

JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)2 MethodWithMultipleOutputParametersCallback (joynr.tests.testAsync.MethodWithMultipleOutputParametersCallback)2 joynr.tests.testProxy (joynr.tests.testProxy)2 TestEnum (joynr.tests.testTypes.TestEnum)2 GpsLocation (joynr.types.Localisation.GpsLocation)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 MethodWithMultipleOutputParametersReturned (joynr.tests.testSync.MethodWithMultipleOutputParametersReturned)1