Search in sources :

Example 51 with MessagingQos

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

the class TtlUpliftTest method verifySubscriptionReplyTtl.

private void verifySubscriptionReplyTtl(long expectedSubscriptionReplyTtl, long toleranceMs) {
    verify(dispatcher, times(1)).sendSubscriptionReply(eq(PROVIDER_PARTICIPANT_ID), eq(PROXY_PARTICIPANT_ID), any(SubscriptionReply.class), messagingQosCaptor.capture());
    MessagingQos capturedMessagingQos = messagingQosCaptor.getValue();
    long diff = Math.abs(expectedSubscriptionReplyTtl - capturedMessagingQos.getRoundTripTtl_ms());
    assertTrue("TTL of subscriptionReply=" + capturedMessagingQos.getRoundTripTtl_ms() + " differs " + diff + "ms (more than " + toleranceMs + "ms) from the expected value=" + expectedSubscriptionReplyTtl, (diff <= toleranceMs));
}
Also used : SubscriptionReply(joynr.SubscriptionReply) MessagingQos(io.joynr.messaging.MessagingQos)

Example 52 with MessagingQos

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

the class PublicationManagerTest method broadcastPublicationIsSentWhenFiltersPass.

@SuppressWarnings("unchecked")
@Test
public void broadcastPublicationIsSentWhenFiltersPass() throws Exception {
    publicationManager = new PublicationManagerImpl(attributePollInterpreter, dispatcher, providerDirectory, cleanupScheduler, Mockito.mock(SubscriptionRequestStorage.class), shutdownNotifier);
    long minInterval_ms = 0;
    long ttl = 1000;
    testBroadcastInterface.LocationUpdateWithSpeedSelectiveBroadcastFilterParameters filterParameters = new testBroadcastInterface.LocationUpdateWithSpeedSelectiveBroadcastFilterParameters();
    OnChangeSubscriptionQos qos = new OnChangeSubscriptionQos().setMinIntervalMs(minInterval_ms).setExpiryDateMs(SubscriptionQos.NO_EXPIRY_DATE).setPublicationTtlMs(ttl);
    SubscriptionRequest subscriptionRequest = new BroadcastSubscriptionRequest(SUBSCRIPTION_ID, "subscribedToName", filterParameters, qos);
    when(providerDirectory.get(eq(PROVIDER_PARTICIPANT_ID))).thenReturn(providerContainer);
    when(providerDirectory.contains(eq(PROVIDER_PARTICIPANT_ID))).thenReturn(true);
    publicationManager.addSubscriptionRequest(PROXY_PARTICIPANT_ID, PROVIDER_PARTICIPANT_ID, subscriptionRequest);
    GpsLocation location = new GpsLocation(1.0, 2.0, 3.0, GpsFixEnum.MODE2D, 4.0, 5.0, 6.0, 7.0, 9l, 10l, 11);
    float speed = 100;
    ArrayList<BroadcastFilter> filters = new ArrayList<BroadcastFilter>();
    testLocationUpdateWithSpeedSelectiveBroadcastFilter filterTrue = mock(testLocationUpdateWithSpeedSelectiveBroadcastFilter.class);
    when(filterTrue.filter(any(GpsLocation.class), any(Float.class), any(testBroadcastInterface.LocationUpdateWithSpeedSelectiveBroadcastFilterParameters.class))).thenReturn(true);
    filters.add(filterTrue);
    publicationManager.broadcastOccurred(subscriptionRequest.getSubscriptionId(), filters, location, speed);
    ArgumentCaptor<SubscriptionPublication> publicationCaptured = ArgumentCaptor.forClass(SubscriptionPublication.class);
    ArgumentCaptor<MessagingQos> qosCaptured = ArgumentCaptor.forClass(MessagingQos.class);
    verify(dispatcher).sendSubscriptionPublication(eq(PROVIDER_PARTICIPANT_ID), (Set<String>) argThat(contains(PROXY_PARTICIPANT_ID)), publicationCaptured.capture(), qosCaptured.capture());
    List<?> response = (List<?>) publicationCaptured.getValue().getResponse();
    assertEquals(location, response.get(0));
    assertEquals(speed, response.get(1));
}
Also used : OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) ArrayList(java.util.ArrayList) GpsLocation(joynr.types.Localisation.GpsLocation) joynr.tests.testLocationUpdateWithSpeedSelectiveBroadcastFilter(joynr.tests.testLocationUpdateWithSpeedSelectiveBroadcastFilter) Matchers.anyString(org.mockito.Matchers.anyString) joynr.tests.testBroadcastInterface(joynr.tests.testBroadcastInterface) SubscriptionRequest(joynr.SubscriptionRequest) BroadcastSubscriptionRequest(joynr.BroadcastSubscriptionRequest) MessagingQos(io.joynr.messaging.MessagingQos) BroadcastSubscriptionRequest(joynr.BroadcastSubscriptionRequest) SubscriptionPublication(joynr.SubscriptionPublication) List(java.util.List) ArrayList(java.util.ArrayList) BroadcastFilter(io.joynr.pubsub.publication.BroadcastFilter) joynr.tests.testLocationUpdateWithSpeedSelectiveBroadcastFilter(joynr.tests.testLocationUpdateWithSpeedSelectiveBroadcastFilter) joynr.tests.testLocationUpdateSelectiveBroadcastFilter(joynr.tests.testLocationUpdateSelectiveBroadcastFilter) Test(org.junit.Test)

Example 53 with MessagingQos

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

the class PublicationManagerTest method broadcastPublicationIsSent.

@SuppressWarnings("unchecked")
@Test
public void broadcastPublicationIsSent() throws Exception {
    publicationManager = new PublicationManagerImpl(attributePollInterpreter, dispatcher, providerDirectory, cleanupScheduler, Mockito.mock(SubscriptionRequestStorage.class), shutdownNotifier);
    long minInterval_ms = 0;
    long ttl = 1000;
    testBroadcastInterface.LocationUpdateWithSpeedSelectiveBroadcastFilterParameters filterParameters = new testBroadcastInterface.LocationUpdateWithSpeedSelectiveBroadcastFilterParameters();
    OnChangeSubscriptionQos qos = new OnChangeSubscriptionQos().setMinIntervalMs(minInterval_ms).setExpiryDateMs(SubscriptionQos.NO_EXPIRY_DATE).setPublicationTtlMs(ttl);
    ;
    SubscriptionRequest subscriptionRequest = new BroadcastSubscriptionRequest(SUBSCRIPTION_ID, "subscribedToName", filterParameters, qos);
    when(providerDirectory.get(eq(PROVIDER_PARTICIPANT_ID))).thenReturn(providerContainer);
    when(providerDirectory.contains(eq(PROVIDER_PARTICIPANT_ID))).thenReturn(true);
    publicationManager.addSubscriptionRequest(PROXY_PARTICIPANT_ID, PROVIDER_PARTICIPANT_ID, subscriptionRequest);
    GpsLocation location = new GpsLocation(1.0, 2.0, 3.0, GpsFixEnum.MODE2D, 4.0, 5.0, 6.0, 7.0, 9l, 10l, 11);
    double speed = 100;
    publicationManager.broadcastOccurred(subscriptionRequest.getSubscriptionId(), new ArrayList<BroadcastFilter>(), location, speed);
    ArgumentCaptor<SubscriptionPublication> publicationCaptured = ArgumentCaptor.forClass(SubscriptionPublication.class);
    ArgumentCaptor<MessagingQos> qosCaptured = ArgumentCaptor.forClass(MessagingQos.class);
    verify(dispatcher).sendSubscriptionPublication(eq(PROVIDER_PARTICIPANT_ID), (Set<String>) argThat(contains(PROXY_PARTICIPANT_ID)), publicationCaptured.capture(), qosCaptured.capture());
    List<?> response = (List<?>) publicationCaptured.getValue().getResponse();
    assertEquals(location, response.get(0));
    assertEquals(speed, response.get(1));
    assertEquals(ttl, qosCaptured.getValue().getRoundTripTtl_ms());
}
Also used : OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) GpsLocation(joynr.types.Localisation.GpsLocation) Matchers.anyString(org.mockito.Matchers.anyString) joynr.tests.testBroadcastInterface(joynr.tests.testBroadcastInterface) SubscriptionRequest(joynr.SubscriptionRequest) BroadcastSubscriptionRequest(joynr.BroadcastSubscriptionRequest) MessagingQos(io.joynr.messaging.MessagingQos) BroadcastSubscriptionRequest(joynr.BroadcastSubscriptionRequest) SubscriptionPublication(joynr.SubscriptionPublication) List(java.util.List) ArrayList(java.util.ArrayList) BroadcastFilter(io.joynr.pubsub.publication.BroadcastFilter) joynr.tests.testLocationUpdateWithSpeedSelectiveBroadcastFilter(joynr.tests.testLocationUpdateWithSpeedSelectiveBroadcastFilter) joynr.tests.testLocationUpdateSelectiveBroadcastFilter(joynr.tests.testLocationUpdateSelectiveBroadcastFilter) Test(org.junit.Test)

Example 54 with MessagingQos

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

the class SubscriptionManagerTest method setUp.

@Before
public void setUp() {
    subscriptionManager = new SubscriptionManagerImpl(attributeSubscriptionDirectory, broadcastSubscriptionDirectory, multicastSubscribersDirectory, subscriptionStates, missedPublicationTimers, subscriptionEndFutures, subscriptionAttributeTypes, unicastBroadcastTypes, multicastBroadcastTypes, subscriptionFutureMap, cleanupScheduler, dispatcher, multicastWildcardRegexFactory);
    subscriptionId = "testSubscription";
    attributeName = "testAttribute";
    attributeSubscriptionCallback = new AttributeSubscriptionAdapter<Integer>();
    long minInterval_ms = 100;
    long maxInterval_ms = 5000;
    long subscriptionDuration = 20000;
    long alertInterval_ms = 6000;
    long publicationTtl_ms = 1000;
    qos = new PeriodicSubscriptionQos();
    qos.setPeriodMs(maxInterval_ms);
    qos.setValidityMs(subscriptionDuration);
    qos.setAlertAfterIntervalMs(alertInterval_ms);
    qos.setPublicationTtlMs(publicationTtl_ms);
    onChangeQos = new OnChangeSubscriptionQos();
    onChangeQos.setMinIntervalMs(minInterval_ms);
    onChangeQos.setValidityMs(subscriptionDuration);
    onChangeQos.setPublicationTtlMs(publicationTtl_ms);
    qosWithoutExpiryDate = new PeriodicSubscriptionQos();
    qosWithoutExpiryDate.setPeriodMs(maxInterval_ms);
    qosWithoutExpiryDate.setValidityMs(SubscriptionQos.IGNORE_VALUE);
    qosWithoutExpiryDate.setAlertAfterIntervalMs(alertInterval_ms);
    qosWithoutExpiryDate.setPublicationTtlMs(publicationTtl_ms);
    missedPublicationTimer = new MissedPublicationTimer(System.currentTimeMillis() + subscriptionDuration, maxInterval_ms, alertInterval_ms, attributeSubscriptionCallback, subscriptionState, subscriptionId);
    qosSettings = new MessagingQos();
    fromParticipantId = "fromParticipantId";
    toParticipantId = "toParticipantId";
    toDiscoveryEntry = new DiscoveryEntryWithMetaInfo();
    toDiscoveryEntry.setParticipantId(toParticipantId);
    future = new Future<String>();
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) Matchers.anyString(org.mockito.Matchers.anyString) DiscoveryEntryWithMetaInfo(joynr.types.DiscoveryEntryWithMetaInfo) PeriodicSubscriptionQos(joynr.PeriodicSubscriptionQos) Before(org.junit.Before)

Example 55 with MessagingQos

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

the class GlobalDomainAccessControllerClient method getGlobalDomainRoleControllerProxy.

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

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