Search in sources :

Example 46 with MutableMessage

use of joynr.MutableMessage in project joynr by bmwcarit.

the class AbstractMessageSenderTest method testLocalMessageGetsNoReplyTo.

@Test
public void testLocalMessageGetsNoReplyTo() {
    MutableMessage message = createTestRequestMessage();
    message.setLocalMessage(true);
    subject.setReplyToAddress("someReplyTo");
    subject.sendMessage(message);
    ArgumentCaptor<ImmutableMessage> argCaptor = ArgumentCaptor.forClass(ImmutableMessage.class);
    verify(messageRouterMock).route(argCaptor.capture());
    assertEquals(null, argCaptor.getValue().getReplyTo());
}
Also used : MutableMessage(joynr.MutableMessage) ImmutableMessage(joynr.ImmutableMessage) Test(org.junit.Test)

Example 47 with MutableMessage

use of joynr.MutableMessage in project joynr by bmwcarit.

the class LibJoynrMessageSenderTest method testReplyToIsSet.

@Test
public void testReplyToIsSet() {
    MutableMessage message = createTestRequestMessage();
    String expectedReplyTo = "expectedReplyTo";
    LibJoynrMessageSender subject = new LibJoynrMessageSender(messageRouterMock);
    subject.setReplyToAddress(expectedReplyTo);
    subject.sendMessage(message);
    ArgumentCaptor<ImmutableMessage> argCaptor = ArgumentCaptor.forClass(ImmutableMessage.class);
    verify(messageRouterMock).route(argCaptor.capture());
    assertEquals(expectedReplyTo, argCaptor.getValue().getReplyTo());
}
Also used : MutableMessage(joynr.MutableMessage) ImmutableMessage(joynr.ImmutableMessage) Test(org.junit.Test)

Example 48 with MutableMessage

use of joynr.MutableMessage in project joynr by bmwcarit.

the class MessageSenderTestBase method createTestRequestMessage.

protected MutableMessage createTestRequestMessage() {
    MutableMessage message = new MutableMessage();
    message.setType(Message.VALUE_MESSAGE_TYPE_REQUEST);
    message.setLocalMessage(false);
    message.setSender("");
    message.setRecipient("");
    message.setPayload(new byte[] { 0, 1, 2 });
    return message;
}
Also used : MutableMessage(joynr.MutableMessage)

Example 49 with MutableMessage

use of joynr.MutableMessage in project joynr by bmwcarit.

the class DispatcherImplTest method testHandleOneWayRequest.

@Test
public void testHandleOneWayRequest() throws Exception {
    OneWayRequest request = new OneWayRequest("method", new Object[0], new Class<?>[0]);
    String toParticipantId = "toParticipantId";
    MessagingQos messagingQos = new MessagingQos(1000L);
    MutableMessage joynrMessage = messageFactory.createOneWayRequest("fromParticipantId", toParticipantId, request, messagingQos);
    fixture.messageArrived(joynrMessage.getImmutableMessage());
    verify(requestReplyManagerMock).handleOneWayRequest(toParticipantId, request, joynrMessage.getTtlMs());
    verify(messageSenderMock, never()).sendMessage(any(MutableMessage.class));
}
Also used : OneWayRequest(joynr.OneWayRequest) MessagingQos(io.joynr.messaging.MessagingQos) MutableMessage(joynr.MutableMessage) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 50 with MutableMessage

use of joynr.MutableMessage in project joynr by bmwcarit.

the class DispatcherImplTest method testPropagateCompressFlagFromRequestToRepliesImpl.

private void testPropagateCompressFlagFromRequestToRepliesImpl(final boolean compress) throws Exception {
    MessagingQos messagingQos = new MessagingQos(1000L);
    messagingQos.setCompress(compress);
    String requestReplyId = UUID.randomUUID().toString();
    Request request = new Request("methodName", new Object[] {}, new String[] {}, requestReplyId);
    final String providerParticipantId = "toParticipantId";
    MutableMessage joynrMessage = messageFactory.createRequest("fromParticipantId", providerParticipantId, request, messagingQos);
    ImmutableMessage outgoingMessage = joynrMessage.getImmutableMessage();
    fixture.messageArrived(outgoingMessage);
    verify(requestReplyManagerMock).handleRequest(providerCallbackReply.capture(), eq(providerParticipantId), eq(request), eq(joynrMessage.getTtlMs()));
    providerCallbackReply.getValue().onSuccess(new Reply(requestReplyId));
    verify(messageSenderMock).sendMessage(argThat(new MessageIsCompressedMatcher(compress)));
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) MutableMessage(joynr.MutableMessage) ImmutableMessage(joynr.ImmutableMessage) OneWayRequest(joynr.OneWayRequest) SubscriptionRequest(joynr.SubscriptionRequest) MulticastSubscriptionRequest(joynr.MulticastSubscriptionRequest) Request(joynr.Request) Reply(joynr.Reply) Matchers.anyString(org.mockito.Matchers.anyString)

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