Search in sources :

Example 21 with MessagingQos

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

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

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

the class GlobalDomainAccessControllerClient method getGlobalDomainAccessControllerProxy.

private GlobalDomainAccessControllerProxy getGlobalDomainAccessControllerProxy(long ttl) {
    ProxyBuilder<GlobalDomainAccessControllerProxy> accessControlProxyBuilder = proxyBuilderFactory.get(domain, GlobalDomainAccessControllerProxy.class);
    DiscoveryQos discoveryQos = new DiscoveryQos();
    discoveryQos.setDiscoveryScope(DiscoveryScope.GLOBAL_ONLY);
    discoveryQos.setCacheMaxAgeMs(DiscoveryQos.NO_MAX_AGE);
    MessagingQos messagingQos = new MessagingQos(ttl);
    return accessControlProxyBuilder.setDiscoveryQos(discoveryQos).setMessagingQos(messagingQos).build();
}
Also used : GlobalDomainAccessControllerProxy(joynr.infrastructure.GlobalDomainAccessControllerProxy) MessagingQos(io.joynr.messaging.MessagingQos) DiscoveryQos(io.joynr.arbitration.DiscoveryQos)

Example 24 with MessagingQos

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

the class GlobalDomainAccessControllerClient method getGlobalDomainAccessControlListEditorProxy.

private GlobalDomainAccessControlListEditorProxy getGlobalDomainAccessControlListEditorProxy(long ttl) {
    ProxyBuilder<GlobalDomainAccessControlListEditorProxy> accessControlListEditorProxyBuilder = proxyBuilderFactory.get(domain, GlobalDomainAccessControlListEditorProxy.class);
    DiscoveryQos discoveryQos = new DiscoveryQos();
    discoveryQos.setDiscoveryScope(DiscoveryScope.GLOBAL_ONLY);
    discoveryQos.setCacheMaxAgeMs(DiscoveryQos.NO_MAX_AGE);
    MessagingQos messagingQos = new MessagingQos(ttl);
    return accessControlListEditorProxyBuilder.setDiscoveryQos(discoveryQos).setMessagingQos(messagingQos).build();
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) GlobalDomainAccessControlListEditorProxy(joynr.infrastructure.GlobalDomainAccessControlListEditorProxy) DiscoveryQos(io.joynr.arbitration.DiscoveryQos)

Example 25 with MessagingQos

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

the class RoutingTableOverwriteEnd2EndTest method testProviderAddressCanBeOverwrittenAfterDiscovery.

@Test
public void testProviderAddressCanBeOverwrittenAfterDiscovery() throws Exception {
    // Tests that if a provider's address is changed in the discovery directory and a new proxy is
    // created for the provider, the routing table of the proxy's runtime will also be updated as long as
    // a new arbitration (cache max age = 0) is performed.
    final String providerDomain = "testDomain";
    final Properties fixedParticipantIdProperty = createFixedParticipantIdProperties(providerDomain, DefaulttestProvider.class, "fixedParticipantId");
    DiscoveryQos discoveryQos = new DiscoveryQos();
    discoveryQos.setArbitrationStrategy(ArbitrationStrategy.HighestPriority);
    discoveryQos.setCacheMaxAgeMs(0);
    JoynrRuntime runtimeProxy = createRuntime("proxy", null);
    JoynrRuntime runtimeProvider1 = createRuntime("provider_initial", fixedParticipantIdProperty);
    DefaulttestProvider provider1 = Mockito.spy(DefaulttestProvider.class);
    runtimeProvider1.registerProvider(providerDomain, provider1, createProviderQos()).get();
    testProxy proxy1 = runtimeProxy.getProxyBuilder(providerDomain, testProxy.class).setMessagingQos(new MessagingQos(2000)).setDiscoveryQos(discoveryQos).build();
    proxy1.addNumbers(1, 2, 3);
    verify(provider1).addNumbers(1, 2, 3);
    reset(provider1);
    JoynrRuntime runtimeProvider2 = createRuntime("provider_override", fixedParticipantIdProperty);
    DefaulttestProvider provider2 = Mockito.spy(DefaulttestProvider.class);
    runtimeProvider2.registerProvider(providerDomain, provider2, createProviderQos()).get();
    testProxy proxy2 = runtimeProxy.getProxyBuilder(providerDomain, testProxy.class).setMessagingQos(new MessagingQos(2000)).setDiscoveryQos(discoveryQos).build();
    proxy2.addNumbers(1, 2, 3);
    verify(provider1, never()).addNumbers(1, 2, 3);
    verify(provider2).addNumbers(1, 2, 3);
}
Also used : JoynrRuntime(io.joynr.runtime.JoynrRuntime) MessagingQos(io.joynr.messaging.MessagingQos) DefaulttestProvider(joynr.tests.DefaulttestProvider) joynr.tests.testProxy(joynr.tests.testProxy) Properties(java.util.Properties) DiscoveryQos(io.joynr.arbitration.DiscoveryQos) Test(org.junit.Test)

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