use of io.joynr.exceptions.JoynrRuntimeException in project joynr by bmwcarit.
the class AddressManagerTest method testGetLocalAndGlobalAddressesForNonExistingProvider.
@Test
public void testGetLocalAndGlobalAddressesForNonExistingProvider() {
createAddressManager(GLOBAL_TRANSPORT_MQTT, multicastAddressCalculator);
when(joynrMessage.getSender()).thenReturn("participantId");
String multicastId = participantId + "/to";
when(joynrMessage.getRecipient()).thenReturn(multicastId);
when(routingTable.getIsGloballyVisible(participantId)).thenThrow(new JoynrRuntimeException());
Set<String> localParticipantIds = Sets.newHashSet("one");
when(multicastReceiverRegistry.getReceivers(multicastId)).thenReturn(localParticipantIds);
Address localAddress = mock(Address.class);
when(routingTable.get("one")).thenReturn(localAddress);
Address globalAddress = mock(Address.class);
when(multicastAddressCalculator.supports(GLOBAL_TRANSPORT_MQTT)).thenReturn(true);
when(multicastAddressCalculator.createsGlobalTransportAddresses()).thenReturn(true);
when(multicastAddressCalculator.calculate(joynrMessage)).thenReturn(globalAddress);
Set<Address> result = subject.getAddresses(joynrMessage);
assertNotNull(result);
assertEquals(1, result.size());
assertTrue(result.contains(localAddress));
assertFalse(result.contains(globalAddress));
}
use of io.joynr.exceptions.JoynrRuntimeException in project joynr by bmwcarit.
the class AddressManagerTest method testGetMulticastAddressGlobalVisibilityCheckThrowsException.
@Test
public void testGetMulticastAddressGlobalVisibilityCheckThrowsException() {
createAddressManager(NO_PRIMARY_GLOBAL_TRANSPORT_SELECTED, multicastAddressCalculator);
when(joynrMessage.getSender()).thenReturn(participantId + "/multicastname");
when(routingTable.getIsGloballyVisible(participantId)).thenThrow(new JoynrRuntimeException());
when(multicastAddressCalculator.createsGlobalTransportAddresses()).thenReturn(true);
Set<Address> result = subject.getAddresses(joynrMessage);
assertEquals(0, result.size());
}
use of io.joynr.exceptions.JoynrRuntimeException in project joynr by bmwcarit.
the class AbstractMessageSender method routeMutableMessage.
private void routeMutableMessage(MutableMessage mutableMessage) {
ImmutableMessage immutableMessage;
try {
immutableMessage = mutableMessage.getImmutableMessage();
} catch (SecurityException | EncodingException | UnsuppportedVersionException exception) {
throw new JoynrRuntimeException(exception.getMessage());
}
messageRouter.route(immutableMessage);
}
use of io.joynr.exceptions.JoynrRuntimeException in project joynr by bmwcarit.
the class ProxyInvocationHandlerImpl method invoke.
@Override
@CheckForNull
public Object invoke(@Nonnull Method method, Object[] args) throws ApplicationException {
logger.trace("calling proxy.{}({}) on domain: {} and interface {}, proxy participant ID: {}", method.getName(), args, domains, interfaceName, proxyParticipantId);
Class<?> methodInterfaceClass = method.getDeclaringClass();
try {
if (JoynrSubscriptionInterface.class.isAssignableFrom(methodInterfaceClass) || JoynrBroadcastSubscriptionInterface.class.isAssignableFrom(methodInterfaceClass)) {
return executeSubscriptionMethod(method, args);
} else if (methodInterfaceClass.getAnnotation(FireAndForget.class) != null) {
return executeOneWayMethod(method, args);
} else if (methodInterfaceClass.getAnnotation(Sync.class) != null) {
return executeSyncMethod(method, args);
} else if (methodInterfaceClass.getAnnotation(Async.class) != null) {
return executeAsyncMethod(method, args);
} else {
throw new JoynrIllegalStateException("Method is not part of sync, async or subscription interface");
}
} catch (JoynrRuntimeException | ApplicationException e) {
throw e;
} catch (Exception e) {
throw new JoynrRuntimeException(e);
}
}
use of io.joynr.exceptions.JoynrRuntimeException in project joynr by bmwcarit.
the class ProxyInvocationHandlerImpl method abort.
@Override
public void abort(JoynrRuntimeException exception) {
setThrowableForInvoke(exception);
for (Iterator<MethodInvocation<?>> iterator = queuedRpcList.iterator(); iterator.hasNext(); ) {
MethodInvocation<?> invocation = iterator.next();
try {
MethodMetaInformation metaInfo = new MethodMetaInformation(invocation.getMethod());
int callbackIndex = metaInfo.getCallbackIndex();
if (callbackIndex > -1) {
ICallback callback = (ICallback) invocation.getArgs()[callbackIndex];
callback.onFailure(exception);
}
} catch (Exception metaInfoException) {
logger.error("aborting call to method: " + invocation.getMethod().getName() + " but unable to call onError callback because of: " + metaInfoException.getMessage(), metaInfoException);
}
invocation.getFuture().onFailure(exception);
}
for (Iterator<UnsubscribeInvocation> iterator = queuedUnsubscripeInvocationList.iterator(); iterator.hasNext(); ) {
Invocation<String> invocation = iterator.next();
invocation.getFuture().onFailure(exception);
}
for (SubscriptionAction subscriptionAction : queuedSubscriptionInvocationList) {
subscriptionAction.fail(exception);
}
}
Aggregations