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);
}
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"));
}
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));
}
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);
}
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);
}
Aggregations