use of joynr.MutableMessage in project joynr by bmwcarit.
the class MutableMessageFactoryTest method createReply.
@Test
public void createReply() {
MutableMessage message = mutableMessageFactory.createReply(fromParticipantId, toParticipantId, reply, messagingQos);
assertEquals(Message.VALUE_MESSAGE_TYPE_REPLY, message.getType());
assertEquals(fromParticipantId, message.getSender());
assertEquals(toParticipantId, message.getRecipient());
assertExpiryDateEquals(expiryDate.getValue(), message);
assertTrue(message.getPayload() != null);
}
use of joynr.MutableMessage in project joynr by bmwcarit.
the class MutableMessageFactoryTest method testMessageProcessorUsed.
@Test
public void testMessageProcessorUsed() {
MutableMessage message = mutableMessageFactory.createRequest("from", "to", new Request("name", new Object[0], new Class[0]), new MessagingQos());
assertNotNull(message.getCustomHeaders().get("test"));
assertEquals("test", message.getCustomHeaders().get("test"));
}
use of joynr.MutableMessage in project joynr by bmwcarit.
the class RequestReplyManagerTest method requestMessagesSentToTheCommunicationManager.
@Test
public void requestMessagesSentToTheCommunicationManager() throws Exception {
requestReplyManager.sendRequest(testSenderParticipantId, testMessageResponderDiscoveryEntry, request1, new MessagingQos(TIME_TO_LIVE));
ArgumentCaptor<MutableMessage> messageCapture = ArgumentCaptor.forClass(MutableMessage.class);
verify(messageSenderMock, times(1)).sendMessage(messageCapture.capture());
assertEquals(messageCapture.getValue().getSender(), testSenderParticipantId);
assertEquals(messageCapture.getValue().getRecipient(), testMessageResponderParticipantId);
assertEquals(new String(messageCapture.getValue().getPayload(), Charsets.UTF_8), objectMapper.writeValueAsString(request1));
}
use of joynr.MutableMessage in project joynr by bmwcarit.
the class RequestReplyManagerTest method oneWayMessagesAreSentToTheCommunicationManager.
@Test
public void oneWayMessagesAreSentToTheCommunicationManager() throws Exception {
requestReplyManager.sendOneWayRequest(testSenderParticipantId, testOneWayRecipientDiscoveryEntries, oneWay1, new MessagingQos(TIME_TO_LIVE));
ArgumentCaptor<MutableMessage> messageCapture = ArgumentCaptor.forClass(MutableMessage.class);
verify(messageSenderMock, times(1)).sendMessage(messageCapture.capture());
assertEquals(messageCapture.getValue().getSender(), testSenderParticipantId);
assertEquals(messageCapture.getValue().getRecipient(), testOneWayRecipientParticipantId);
assertEquals(oneWay1, objectMapper.readValue(messageCapture.getValue().getPayload(), OneWayRequest.class));
}
use of joynr.MutableMessage in project joynr by bmwcarit.
the class BounceProxyCommunicationMock method createImmutableMessage.
/**
* Creates a serialized joynr message from a payload, a message ID and a
* relative ttl.
*
* @param relativeTtlMs
* @param postPayload
* @param msgId
* @return
* @throws JsonProcessingException
*/
public ImmutableMessage createImmutableMessage(final long relativeTtlMs, final byte[] postPayload) throws EncodingException, UnsuppportedVersionException {
MutableMessage message = new MutableMessage();
message.setType(Message.VALUE_MESSAGE_TYPE_REQUEST);
message.setTtlAbsolute(true);
message.setTtlMs(ExpiryDate.fromRelativeTtl(relativeTtlMs).getValue());
message.setPayload(postPayload);
message.setSender("testSender");
message.setRecipient("testRecipient");
return message.getImmutableMessage();
}
Aggregations