Search in sources :

Example 31 with MutableMessage

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);
}
Also used : MutableMessage(joynr.MutableMessage) Test(org.junit.Test)

Example 32 with MutableMessage

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"));
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) MutableMessage(joynr.MutableMessage) MulticastSubscriptionRequest(joynr.MulticastSubscriptionRequest) SubscriptionRequest(joynr.SubscriptionRequest) Request(joynr.Request) Test(org.junit.Test)

Example 33 with MutableMessage

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));
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) MutableMessage(joynr.MutableMessage) Test(org.junit.Test)

Example 34 with MutableMessage

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));
}
Also used : OneWayRequest(joynr.OneWayRequest) MessagingQos(io.joynr.messaging.MessagingQos) MutableMessage(joynr.MutableMessage) Test(org.junit.Test)

Example 35 with MutableMessage

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();
}
Also used : MutableMessage(joynr.MutableMessage)

Aggregations

MutableMessage (joynr.MutableMessage)60 Test (org.junit.Test)35 MessagingQos (io.joynr.messaging.MessagingQos)15 ImmutableMessage (joynr.ImmutableMessage)9 MulticastSubscriptionRequest (joynr.MulticastSubscriptionRequest)7 SubscriptionRequest (joynr.SubscriptionRequest)6 Request (joynr.Request)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 Reply (joynr.Reply)4 Injector (com.google.inject.Injector)3 JoynrMessageProcessor (io.joynr.messaging.JoynrMessageProcessor)3 BroadcastSubscriptionRequest (joynr.BroadcastSubscriptionRequest)3 MulticastPublication (joynr.MulticastPublication)3 OneWayRequest (joynr.OneWayRequest)3 DiscoveryEntryWithMetaInfo (joynr.types.DiscoveryEntryWithMetaInfo)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 AbstractModule (com.google.inject.AbstractModule)2 TypeLiteral (com.google.inject.TypeLiteral)2 Multibinder (com.google.inject.multibindings.Multibinder)2 JoynrPropertiesModule (io.joynr.common.JoynrPropertiesModule)2