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