use of io.joynr.messaging.routing.TransportReadyListener in project joynr by bmwcarit.
the class CcMessageSenderTest method testReplyToIsSet.
@Test
public void testReplyToIsSet() throws Exception {
MutableMessage message = createTestRequestMessage();
final MqttAddress replyToAddress = new MqttAddress("testBrokerUri", "testTopic");
ObjectMapper objectMapper = new ObjectMapper();
String serializedReplyToAddress = objectMapper.writeValueAsString(replyToAddress);
ReplyToAddressProvider replyToAddressProviderMock = Mockito.mock(ReplyToAddressProvider.class);
doAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
assertEquals(1, invocation.getArguments().length);
assertThat(invocation.getArguments()[0], instanceOf(TransportReadyListener.class));
TransportReadyListener listener = (TransportReadyListener) invocation.getArguments()[0];
listener.transportReady(replyToAddress);
return null;
}
}).when(replyToAddressProviderMock).registerGlobalAddressesReadyListener(any(TransportReadyListener.class));
CcMessageSender subject = new CcMessageSender(messageRouterMock, replyToAddressProviderMock);
subject.sendMessage(message);
ArgumentCaptor<ImmutableMessage> argCaptor = ArgumentCaptor.forClass(ImmutableMessage.class);
verify(messageRouterMock).route(argCaptor.capture());
assertEquals(serializedReplyToAddress, argCaptor.getValue().getReplyTo());
}
Aggregations