use of joynr.system.RoutingTypes.ChannelAddress in project joynr by bmwcarit.
the class CcMessageRouterTest method testMessageProcessedListenerOnlyCalledOnceForMulticast.
@Test
public void testMessageProcessedListenerOnlyCalledOnceForMulticast() throws Exception {
final Semaphore semaphore = new Semaphore(-1);
ChannelAddress receiverAddress1 = new ChannelAddress("http://testUrl", "channelId1");
ChannelAddress receiverAddress2 = new ChannelAddress("http://testUrl", "channelId2");
prepareMulticastForMultipleAddresses(receiverAddress1, receiverAddress2);
final ImmutableMessage immutableMessage = joynrMessage.getImmutableMessage();
final MessageProcessedListener mockMessageProcessedListener = mock(MessageProcessedListener.class);
messageRouter.registerMessageProcessedListener(mockMessageProcessedListener);
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
verify(mockMessageProcessedListener, times(0)).messageProcessed(eq(immutableMessage.getId()));
invocation.getArgumentAt(1, SuccessAction.class).execute();
semaphore.release();
return null;
}
}).when(messagingStubMock).transmit(eq(immutableMessage), any(SuccessAction.class), any(FailureAction.class));
messageRouter.route(immutableMessage);
semaphore.tryAcquire(1000, TimeUnit.MILLISECONDS);
verify(messagingStubMock, times(2)).transmit(eq(immutableMessage), any(SuccessAction.class), any(FailureAction.class));
verify(mockMessageProcessedListener).messageProcessed(eq(immutableMessage.getId()));
}
use of joynr.system.RoutingTypes.ChannelAddress in project joynr by bmwcarit.
the class LongPollingHttpMulticastAddressCalculator method calculate.
@Override
public Address calculate(ImmutableMessage message) {
if (true) {
throw new UnsupportedOperationException("Multicasts are not yet supported for HTTP long polling.");
}
ChannelAddress multicastAddress = null;
if (globalAddress != null) {
try {
String multicastChannelId = URLEncoder.encode(message.getSender() + "/" + message.getRecipient(), UTF_8);
multicastAddress = new ChannelAddress(globalAddress.getMessagingEndpointUrl(), multicastChannelId);
} catch (UnsupportedEncodingException e) {
logger.error("Unable to encode multicast channel from message {}", message, e);
}
} else {
logger.warn("Unable to calculate multicast address for message {} because no global address was found for long polling.", message);
}
return multicastAddress;
}
Aggregations