use of io.joynr.exceptions.SubscriptionException in project joynr by bmwcarit.
the class SubscriptionManagerTest method testRegisterMulticastSubscription.
@SuppressWarnings("unchecked")
private void testRegisterMulticastSubscription(String subscriptionId, String... partitions) throws Exception {
Method method = TestMulticastSubscriptionInterface.class.getMethod("subscribeToMyMulticast", new Class[0]);
BroadcastSubscriptionListener listener = spy(new BroadcastSubscriptionListener() {
@Override
public void onError(SubscriptionException error) {
}
@Override
public void onSubscribed(String subscriptionId) {
}
@SuppressWarnings("unused")
public void onReceive() {
}
});
SubscriptionQos subscriptionQos = mock(MulticastSubscriptionQos.class);
Object[] args;
if (subscriptionId == null) {
args = new Object[] { listener, subscriptionQos, partitions };
} else {
args = new Object[] { subscriptionId, listener, subscriptionQos, partitions };
}
String multicastId = MulticastIdUtil.createMulticastId(toParticipantId, "myMulticast", partitions);
Set<String> subscriptionIdSet = new HashSet<>();
Pattern multicastIdPattern = Pattern.compile(multicastId);
multicastSubscribersDirectory.put(multicastIdPattern, subscriptionIdSet);
when(multicastWildcardRegexFactory.createIdPattern(multicastId)).thenReturn(multicastIdPattern);
MulticastSubscribeInvocation invocation = new MulticastSubscribeInvocation(method, args, future);
DiscoveryEntryWithMetaInfo toDiscoveryEntry = new DiscoveryEntryWithMetaInfo();
toDiscoveryEntry.setParticipantId(toParticipantId);
subscriptionManager.registerMulticastSubscription(fromParticipantId, Sets.newHashSet(toDiscoveryEntry), invocation);
verify(multicastSubscribersDirectory).put(any(Pattern.class), anySet());
assertEquals(1, subscriptionIdSet.size());
if (subscriptionId != null) {
assertEquals(subscriptionId, subscriptionIdSet.iterator().next());
}
verify(dispatcher).sendSubscriptionRequest(eq(fromParticipantId), eq(Sets.newHashSet(toDiscoveryEntry)), any(SubscriptionRequest.class), any(MessagingQos.class));
}
use of io.joynr.exceptions.SubscriptionException in project joynr by bmwcarit.
the class SubscriptionManagerTest method testHandleSubscriptionReplyWithError.
@Test
public void testHandleSubscriptionReplyWithError() {
SubscriptionException subscriptionError = new SubscriptionException(subscriptionId);
SubscriptionReply subscriptionReply = new SubscriptionReply(subscriptionId, subscriptionError);
@SuppressWarnings("unchecked") Future<String> futureMock = mock(Future.class);
subscriptionFutureMap.put(subscriptionId, futureMock);
subscriptionManager.handleSubscriptionReply(subscriptionReply);
verify(futureMock).onFailure(eq(subscriptionError));
}
Aggregations