use of io.joynr.messaging.FailureAction in project joynr by bmwcarit.
the class CcMessageRouterTest method testNoMessageDuplicationForMulticastForMultipleAddressesWithErrorFromStub.
@Test
public void testNoMessageDuplicationForMulticastForMultipleAddressesWithErrorFromStub() throws Exception {
ChannelAddress receiverAddress1 = new ChannelAddress("http://testUrl", "channelId1");
ChannelAddress receiverAddress2 = new ChannelAddress("http://testUrl", "channelId2");
prepareMulticastForMultipleAddresses(receiverAddress1, receiverAddress2);
ImmutableMessage immutableMessage = joynrMessage.getImmutableMessage();
doAnswer(new Answer<Void>() {
private int callCount = 0;
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
FailureAction failureAction = invocation.getArgumentAt(2, FailureAction.class);
if (callCount < 2) {
callCount++;
failureAction.execute(new JoynrDelayMessageException(10, "first retry"));
} else {
failureAction.execute(new JoynrMessageNotSentException("do not retry twice"));
}
return null;
}
}).when(messagingStubMock).transmit(eq(immutableMessage), any(SuccessAction.class), any(FailureAction.class));
messageRouter.route(immutableMessage);
Thread.sleep(1000);
verify(messagingStubMock, times(4)).transmit(eq(immutableMessage), any(SuccessAction.class), any(FailureAction.class));
verify(middlewareMessagingStubFactoryMock, times(2)).create(receiverAddress1);
verify(middlewareMessagingStubFactoryMock, times(2)).create(receiverAddress2);
}
Aggregations