Search in sources :

Example 1 with UnsubscribeInvocation

use of io.joynr.proxy.invocation.UnsubscribeInvocation 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)

Example 2 with UnsubscribeInvocation

use of io.joynr.proxy.invocation.UnsubscribeInvocation in project joynr by bmwcarit.

the class ConnectorTest method unsubscriptionMethodCallCallsSubscriptionManagerWithCorrectArguments.

@Test
public void unsubscriptionMethodCallCallsSubscriptionManagerWithCorrectArguments() {
    String subscriptionId = "subscriptionId";
    ConnectorInvocationHandler connector = createConnector();
    assertNotNull(connector);
    try {
        Method method = TestSubscriptionInterface.class.getDeclaredMethod("unsubscribeFromTestAttribute", String.class);
        UnsubscribeInvocation invocation = new UnsubscribeInvocation(method, new Object[] { subscriptionId }, null);
        connector.executeSubscriptionMethod(invocation);
        verify(subscriptionManager, times(1)).unregisterSubscription(fromParticipantId, toDiscoveryEntries, subscriptionId, qosSettings);
    } catch (Exception e) {
        fail("Unexpected exception from unsubscribe call: " + e);
    }
}
Also used : UnsubscribeInvocation(io.joynr.proxy.invocation.UnsubscribeInvocation) Method(java.lang.reflect.Method) SubscriptionException(io.joynr.exceptions.SubscriptionException) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) JoynrIllegalStateException(io.joynr.exceptions.JoynrIllegalStateException) Test(org.junit.Test)

Example 3 with UnsubscribeInvocation

use of io.joynr.proxy.invocation.UnsubscribeInvocation in project joynr by bmwcarit.

the class ConnectorTest method unsubscriptionMethodCall.

@Test
public void unsubscriptionMethodCall() throws JoynrIllegalStateException {
    ConnectorInvocationHandler connector = createConnector();
    assertNotNull(connector);
    try {
        Future<String> future = new Future<String>();
        String subscriptionId = "subscriptionId";
        Object[] args = new Object[] { subscriptionId };
        Method method = LocalisationSubscriptionInterface.class.getDeclaredMethod("unsubscribeFromGPSPosition", String.class);
        UnsubscribeInvocation unsubscribeInvocation = new UnsubscribeInvocation(method, args, future);
        connector.executeSubscriptionMethod(unsubscribeInvocation);
        verify(subscriptionManager, times(1)).unregisterSubscription(eq(fromParticipantId), eq(Sets.newHashSet(toDiscoveryEntry)), eq(subscriptionId), any(MessagingQos.class));
    } catch (Exception e) {
        // This is what is supposed to happen -> no error handling
        fail("Calling a subscription method with no expiry date throws an exception.");
    }
}
Also used : UnsubscribeInvocation(io.joynr.proxy.invocation.UnsubscribeInvocation) MessagingQos(io.joynr.messaging.MessagingQos) Method(java.lang.reflect.Method) SubscriptionException(io.joynr.exceptions.SubscriptionException) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) JoynrIllegalStateException(io.joynr.exceptions.JoynrIllegalStateException) Test(org.junit.Test)

Aggregations

JoynrIllegalStateException (io.joynr.exceptions.JoynrIllegalStateException)3 UnsubscribeInvocation (io.joynr.proxy.invocation.UnsubscribeInvocation)3 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)2 SubscriptionException (io.joynr.exceptions.SubscriptionException)2 Method (java.lang.reflect.Method)2 Test (org.junit.Test)2 DiscoveryException (io.joynr.exceptions.DiscoveryException)1 JoynrException (io.joynr.exceptions.JoynrException)1 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)1 MessagingQos (io.joynr.messaging.MessagingQos)1 MethodInvocation (io.joynr.proxy.invocation.MethodInvocation)1 MethodMetaInformation (joynr.MethodMetaInformation)1 ApplicationException (joynr.exceptions.ApplicationException)1