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