Search in sources :

Example 46 with MessagingQos

use of io.joynr.messaging.MessagingQos 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 47 with MessagingQos

use of io.joynr.messaging.MessagingQos 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)

Example 48 with MessagingQos

use of io.joynr.messaging.MessagingQos in project joynr by bmwcarit.

the class DispatcherImplTest method testSendMulticastMessage.

@Test
public void testSendMulticastMessage() {
    MutableMessageFactory messageFactoryMock = mock(MutableMessageFactory.class);
    ObjectMapper objectMapperMock = mock(ObjectMapper.class);
    fixture = new DispatcherImpl(requestReplyManagerMock, subscriptionManagerMock, publicationManagerMock, messageRouterMock, messageSenderMock, messageFactoryMock, objectMapperMock);
    String fromParticipantId = "fromParticipantId";
    MulticastPublication multicastPublication = mock(MulticastPublication.class);
    MessagingQos messagingQos = mock(MessagingQos.class);
    fixture.sendMulticast(fromParticipantId, multicastPublication, messagingQos);
    verify(messageFactoryMock).createMulticast(eq(fromParticipantId), eq(multicastPublication), eq(messagingQos));
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) MulticastPublication(joynr.MulticastPublication) Matchers.anyString(org.mockito.Matchers.anyString) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 49 with MessagingQos

use of io.joynr.messaging.MessagingQos in project joynr by bmwcarit.

the class MutableMessageFactoryTest method testCompressedFlagIsSet.

@Test
public void testCompressedFlagIsSet() {
    MutableMessage message;
    MessagingQos messagingQos = new MessagingQos();
    messagingQos.setCompress(true);
    message = mutableMessageFactory.createRequest("from", "to", request, messagingQos);
    assertEquals(true, message.getCompressed());
    messagingQos.setCompress(false);
    message = mutableMessageFactory.createRequest("from", "to", request, messagingQos);
    assertEquals(false, message.getCompressed());
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) MutableMessage(joynr.MutableMessage) Test(org.junit.Test)

Example 50 with MessagingQos

use of io.joynr.messaging.MessagingQos in project joynr by bmwcarit.

the class MutableMessageFactoryTest method setUp.

@Before
public void setUp() throws NoSuchMethodException, SecurityException {
    fromParticipantId = "sender";
    toParticipantId = "receiver";
    Injector injector = Guice.createInjector(new JoynrPropertiesModule(new Properties()), new JsonMessageSerializerModule(), new AbstractModule() {

        @Override
        protected void configure() {
            bind(Long.class).annotatedWith(Names.named(ConfigurableMessagingSettings.PROPERTY_TTL_UPLIFT_MS)).toInstance(NO_TTL_UPLIFT);
            requestStaticInjection(Request.class);
            Multibinder<JoynrMessageProcessor> joynrMessageProcessorMultibinder = Multibinder.newSetBinder(binder(), new TypeLiteral<JoynrMessageProcessor>() {
            });
            joynrMessageProcessorMultibinder.addBinding().toInstance(new JoynrMessageProcessor() {

                @Override
                public MutableMessage processOutgoing(MutableMessage joynrMessage) {
                    joynrMessage.getCustomHeaders().put("test", "test");
                    return joynrMessage;
                }

                @Override
                public ImmutableMessage processIncoming(ImmutableMessage joynrMessage) {
                    return joynrMessage;
                }
            });
        }
    });
    objectMapper = injector.getInstance(ObjectMapper.class);
    payload = "payload";
    Method method = TestProvider.class.getMethod("methodWithStrings", new Class[] { String.class });
    request = new Request(method.getName(), new String[] { payload }, method.getParameterTypes());
    String requestReplyId = request.getRequestReplyId();
    reply = new Reply(requestReplyId, objectMapper.<JsonNode>valueToTree(payload));
    messagingQos = new MessagingQos(TTL);
    expiryDate = DispatcherUtils.convertTtlToExpirationDate(messagingQos.getRoundTripTtl_ms());
    String subscriptionId = "subscription";
    String attributeName = "attribute";
    PeriodicSubscriptionQos subscriptionqos = new PeriodicSubscriptionQos();
    subscriptionqos.setPeriodMs(1000).setValidityMs(10).setAlertAfterIntervalMs(1500).setPublicationTtlMs(1000);
    subscriptionRequest = new SubscriptionRequest(subscriptionId, attributeName, subscriptionqos);
    String response = "response";
    publication = new SubscriptionPublication(Arrays.asList(response), subscriptionId);
    mutableMessageFactory = injector.getInstance(MutableMessageFactory.class);
}
Also used : Multibinder(com.google.inject.multibindings.Multibinder) JsonMessageSerializerModule(io.joynr.messaging.JsonMessageSerializerModule) MulticastSubscriptionRequest(joynr.MulticastSubscriptionRequest) SubscriptionRequest(joynr.SubscriptionRequest) Request(joynr.Request) JoynrMessageProcessor(io.joynr.messaging.JoynrMessageProcessor) JsonNode(com.fasterxml.jackson.databind.JsonNode) Method(java.lang.reflect.Method) Properties(java.util.Properties) AbstractModule(com.google.inject.AbstractModule) PeriodicSubscriptionQos(joynr.PeriodicSubscriptionQos) MessagingQos(io.joynr.messaging.MessagingQos) MulticastSubscriptionRequest(joynr.MulticastSubscriptionRequest) SubscriptionRequest(joynr.SubscriptionRequest) TypeLiteral(com.google.inject.TypeLiteral) MutableMessage(joynr.MutableMessage) Injector(com.google.inject.Injector) JoynrPropertiesModule(io.joynr.common.JoynrPropertiesModule) SubscriptionPublication(joynr.SubscriptionPublication) ImmutableMessage(joynr.ImmutableMessage) Reply(joynr.Reply) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Aggregations

MessagingQos (io.joynr.messaging.MessagingQos)55 Test (org.junit.Test)23 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)19 MutableMessage (joynr.MutableMessage)15 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)11 Matchers.anyString (org.mockito.Matchers.anyString)11 OnChangeSubscriptionQos (joynr.OnChangeSubscriptionQos)9 SubscriptionRequest (joynr.SubscriptionRequest)9 Before (org.junit.Before)8 Properties (java.util.Properties)6 ImmutableMessage (joynr.ImmutableMessage)6 Request (joynr.Request)6 Injector (com.google.inject.Injector)5 BroadcastSubscriptionRequest (joynr.BroadcastSubscriptionRequest)5 MulticastSubscriptionRequest (joynr.MulticastSubscriptionRequest)5 joynr.tests.testProxy (joynr.tests.testProxy)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 AbstractModule (com.google.inject.AbstractModule)4 IOException (java.io.IOException)4 OneWayRequest (joynr.OneWayRequest)4