Search in sources :

Example 11 with JoynrRuntimeException

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));
}
Also used : Address(joynr.system.RoutingTypes.Address) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) Test(org.junit.Test)

Example 12 with JoynrRuntimeException

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());
}
Also used : Address(joynr.system.RoutingTypes.Address) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) Test(org.junit.Test)

Example 13 with JoynrRuntimeException

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);
}
Also used : EncodingException(io.joynr.smrf.EncodingException) ImmutableMessage(joynr.ImmutableMessage) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) UnsuppportedVersionException(io.joynr.smrf.UnsuppportedVersionException)

Example 14 with JoynrRuntimeException

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);
    }
}
Also used : JoynrSubscriptionInterface(io.joynr.dispatcher.rpc.JoynrSubscriptionInterface) ApplicationException(joynr.exceptions.ApplicationException) Sync(io.joynr.Sync) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) JoynrBroadcastSubscriptionInterface(io.joynr.dispatcher.rpc.JoynrBroadcastSubscriptionInterface) JoynrIllegalStateException(io.joynr.exceptions.JoynrIllegalStateException) DiscoveryException(io.joynr.exceptions.DiscoveryException) JoynrException(io.joynr.exceptions.JoynrException) ApplicationException(joynr.exceptions.ApplicationException) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) JoynrIllegalStateException(io.joynr.exceptions.JoynrIllegalStateException) CheckForNull(javax.annotation.CheckForNull)

Example 15 with JoynrRuntimeException

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);
    }
}
Also used : UnsubscribeInvocation(io.joynr.proxy.invocation.UnsubscribeInvocation) MethodMetaInformation(joynr.MethodMetaInformation) MethodInvocation(io.joynr.proxy.invocation.MethodInvocation) DiscoveryException(io.joynr.exceptions.DiscoveryException) JoynrException(io.joynr.exceptions.JoynrException) ApplicationException(joynr.exceptions.ApplicationException) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) JoynrIllegalStateException(io.joynr.exceptions.JoynrIllegalStateException)

Aggregations

JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)76 Test (org.junit.Test)41 ApplicationException (joynr.exceptions.ApplicationException)18 joynr.tests.testProxy (joynr.tests.testProxy)16 MessagingQos (io.joynr.messaging.MessagingQos)14 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)13 Callback (io.joynr.proxy.Callback)9 Future (io.joynr.proxy.Future)9 ProviderRuntimeException (joynr.exceptions.ProviderRuntimeException)9 IOException (java.io.IOException)8 Semaphore (java.util.concurrent.Semaphore)8 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)8 InvocationOnMock (org.mockito.invocation.InvocationOnMock)8 DiscoveryException (io.joynr.exceptions.DiscoveryException)7 JoynrException (io.joynr.exceptions.JoynrException)7 DeferredVoid (io.joynr.provider.DeferredVoid)7 HashSet (java.util.HashSet)7 ProviderQos (joynr.types.ProviderQos)7 JoynrIllegalStateException (io.joynr.exceptions.JoynrIllegalStateException)5 ProxyCreatedCallback (io.joynr.proxy.ProxyBuilder.ProxyCreatedCallback)5