use of joynr.MutableMessage in project joynr by bmwcarit.
the class SplitSMRFTest method createImmutableMessage.
private ImmutableMessage createImmutableMessage(String type, String sender, String recipient) throws SecurityException, EncodingException, UnsuppportedVersionException {
MutableMessage message = new MutableMessage();
message.setType(type);
message.setSender(sender);
message.setRecipient(recipient);
message.setPayload(new byte[] { 0, 1, 2 });
return message.getImmutableMessage();
}
use of joynr.MutableMessage in project joynr by bmwcarit.
the class MessagingTest method createJoynrMessage.
private ImmutableMessage createJoynrMessage(ExpiryDate expiryDate) throws Exception {
MutableMessage message = new MutableMessage();
message.setType(Message.VALUE_MESSAGE_TYPE_REQUEST);
message.setPayload(("payload-" + UUID.randomUUID().toString()).getBytes(Charsets.UTF_8));
message.setTtlAbsolute(true);
message.setTtlMs(expiryDate.getValue());
message.setSender("");
message.setRecipient("");
return message.getImmutableMessage();
}
use of joynr.MutableMessage in project joynr by bmwcarit.
the class AbstractMessageSenderTest method testReplyToMessageQueue.
@Test
public void testReplyToMessageQueue() throws Exception {
MutableMessage message = createTestRequestMessage();
message = spy(message);
subject.sendMessage(message);
verify(messageRouterMock, never()).route(any(ImmutableMessage.class));
ImmutableMessage immutableMessageMock = Mockito.mock(ImmutableMessage.class);
when(message.getImmutableMessage()).thenReturn(immutableMessageMock);
String expectedReplyTo = "expectedReplyTo";
subject.setReplyToAddress(expectedReplyTo);
verify(messageRouterMock, times(1)).route(immutableMessageMock);
}
use of joynr.MutableMessage in project joynr by bmwcarit.
the class AbstractMessageSenderTest method testSerializationExceptionIsHandled.
@Test(expected = JoynrRuntimeException.class)
@SuppressWarnings("unchecked")
public void testSerializationExceptionIsHandled() throws Exception {
MutableMessage message = createTestRequestMessage();
message = spy(message);
when(message.getImmutableMessage()).thenThrow(EncodingException.class);
subject.setReplyToAddress("someReplyTo");
subject.sendMessage(message);
}
use of joynr.MutableMessage 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