Search in sources :

Example 6 with MutableMessage

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

Example 7 with MutableMessage

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

Example 8 with MutableMessage

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

Example 9 with MutableMessage

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

Example 10 with MutableMessage

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());
}
Also used : TransportReadyListener(io.joynr.messaging.routing.TransportReadyListener) ReplyToAddressProvider(io.joynr.runtime.ReplyToAddressProvider) MutableMessage(joynr.MutableMessage) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ImmutableMessage(joynr.ImmutableMessage) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) MqttAddress(joynr.system.RoutingTypes.MqttAddress) Test(org.junit.Test)

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