Search in sources :

Example 1 with TestEnum

use of joynr.tests.testTypes.TestEnum in project joynr by bmwcarit.

the class AbstractProviderProxyEnd2EndTest method sendingANullValueOnceDoesntCrashProvider.

@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void sendingANullValueOnceDoesntCrashProvider() throws DiscoveryException, JoynrIllegalStateException, InterruptedException {
    ProxyBuilder<testProxy> proxyBuilder = consumerRuntime.getProxyBuilder(domain, testProxy.class);
    testProxy proxy = proxyBuilder.setMessagingQos(messagingQos).setDiscoveryQos(discoveryQos).build();
    proxy.methodWithEnumParameter(null);
    TestEnum input = TestEnum.TWO;
    int result = proxy.methodWithEnumParameter(input);
    assertEquals(2, result);
}
Also used : joynr.tests.testProxy(joynr.tests.testProxy) TestEnum(joynr.tests.testTypes.TestEnum) Test(org.junit.Test)

Example 2 with TestEnum

use of joynr.tests.testTypes.TestEnum 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 3 with TestEnum

use of joynr.tests.testTypes.TestEnum in project joynr by bmwcarit.

the class AbstractSubscriptionEnd2EndTest method subscribeToEnumAttribute.

@SuppressWarnings("unchecked")
@Test
public void subscribeToEnumAttribute() throws InterruptedException, ApplicationException {
    final Semaphore onReceiveSemaphore = new Semaphore(0);
    AttributeSubscriptionListener<TestEnum> testEnumListener = mock(AttributeSubscriptionListener.class);
    doAnswer(new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocation) {
            onReceiveSemaphore.release();
            return null;
        }
    }).when(testEnumListener).onReceive(any(TestEnum.class));
    TestEnum expectedTestEnum = TestEnum.TWO;
    provider.setEnumAttribute(expectedTestEnum);
    int periods = 2;
    long subscriptionDuration = (PERIOD_MS * periods) + EXPECTED_LATENCY_MS;
    PeriodicSubscriptionQos subscriptionQos = new PeriodicSubscriptionQos();
    subscriptionQos.setPeriodMs(PERIOD_MS);
    subscriptionQos.setValidityMs(subscriptionDuration);
    subscriptionQos.setAlertAfterIntervalMs(500);
    subscriptionQos.setPublicationTtlMs(0);
    Future<String> subscriptionId = proxy.subscribeToEnumAttribute(testEnumListener, subscriptionQos);
    assertTrue(onReceiveSemaphore.tryAcquire(periods, subscriptionDuration + 1000, TimeUnit.MILLISECONDS));
    verify(testEnumListener, times(0)).onError(null);
    proxy.unsubscribeFromEnumAttribute(subscriptionId.get(FUTURE_SUBSCRIPTION_ID_TIMEOUTMS));
}
Also used : InvocationOnMock(org.mockito.invocation.InvocationOnMock) TestEnum(joynr.tests.testTypes.TestEnum) Semaphore(java.util.concurrent.Semaphore) PeriodicSubscriptionQos(joynr.PeriodicSubscriptionQos) Test(org.junit.Test)

Example 4 with TestEnum

use of joynr.tests.testTypes.TestEnum in project joynr by bmwcarit.

the class AbstractProviderProxyEnd2EndTest method testMethodWithEnumInputReturnsResult.

@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void testMethodWithEnumInputReturnsResult() throws DiscoveryException, JoynrIllegalStateException, InterruptedException {
    ProxyBuilder<testProxy> proxyBuilder = consumerRuntime.getProxyBuilder(domain, testProxy.class);
    testProxy proxy = proxyBuilder.setMessagingQos(messagingQos).setDiscoveryQos(discoveryQos).build();
    TestEnum input = TestEnum.TWO;
    int result = proxy.methodWithEnumParameter(input);
    assertEquals(2, result);
}
Also used : joynr.tests.testProxy(joynr.tests.testProxy) TestEnum(joynr.tests.testTypes.TestEnum) Test(org.junit.Test)

Example 5 with TestEnum

use of joynr.tests.testTypes.TestEnum in project joynr by bmwcarit.

the class AbstractProviderProxyEnd2EndTest method testEnumAttribute.

@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void testEnumAttribute() throws DiscoveryException, JoynrIllegalStateException, InterruptedException {
    ProxyBuilder<testProxy> proxyBuilder = consumerRuntime.getProxyBuilder(domain, testProxy.class);
    testProxy proxy = proxyBuilder.setMessagingQos(messagingQos).setDiscoveryQos(discoveryQos).build();
    proxy.setEnumAttribute(TestEnum.TWO);
    TestEnum result = proxy.getEnumAttribute();
    assertEquals(TestEnum.TWO, result);
}
Also used : joynr.tests.testProxy(joynr.tests.testProxy) TestEnum(joynr.tests.testTypes.TestEnum) Test(org.junit.Test)

Aggregations

TestEnum (joynr.tests.testTypes.TestEnum)10 Test (org.junit.Test)10 joynr.tests.testProxy (joynr.tests.testProxy)7 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)2 Semaphore (java.util.concurrent.Semaphore)2 MethodWithMultipleOutputParametersCallback (joynr.tests.testAsync.MethodWithMultipleOutputParametersCallback)2 GpsLocation (joynr.types.Localisation.GpsLocation)2 Ignore (org.junit.Ignore)2 SubscriptionException (io.joynr.exceptions.SubscriptionException)1 HashMap (java.util.HashMap)1 MulticastSubscriptionQos (joynr.MulticastSubscriptionQos)1 PeriodicSubscriptionQos (joynr.PeriodicSubscriptionQos)1 joynr.tests.testBroadcastInterface (joynr.tests.testBroadcastInterface)1 MethodWithMultipleOutputParametersReturned (joynr.tests.testSync.MethodWithMultipleOutputParametersReturned)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1