Search in sources :

Example 6 with OnChangeSubscriptionQos

use of joynr.OnChangeSubscriptionQos in project joynr by bmwcarit.

the class AbstractSubscriptionEnd2EndTest method testOnChangeSubscription.

@Test
public void testOnChangeSubscription() throws InterruptedException, ApplicationException {
    Semaphore onReceiveSemaphore = new Semaphore(0);
    AttributeSubscriptionListener<Integer> integerListener = prepareOnReceiveListenerMock(onReceiveSemaphore);
    long minInterval_ms = 0;
    OnChangeSubscriptionQos subscriptionQos = new OnChangeSubscriptionQos();
    subscriptionQos.setMinIntervalMs(minInterval_ms);
    subscriptionQos.setValidityMs(1000);
    // publications don't live
    subscriptionQos.setPublicationTtlMs(1000);
    Future<String> subscriptionId = proxy.subscribeToTestAttribute(integerListener, subscriptionQos);
    getSubscriptionTestsPublisher().waitForAttributeSubscription("testAttribute");
    verify(integerListener, times(0)).onError(null);
    assertTrue(onReceiveSemaphore.tryAcquire(1000, TimeUnit.MILLISECONDS));
    provider.setTestAttribute(5);
    assertTrue(onReceiveSemaphore.tryAcquire(1000, TimeUnit.MILLISECONDS));
    proxy.unsubscribeFromTestAttribute(subscriptionId.get(FUTURE_SUBSCRIPTION_ID_TIMEOUTMS));
    getSubscriptionTestsPublisher().waitForAttributeUnsubscription("testAttribute");
}
Also used : OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) Semaphore(java.util.concurrent.Semaphore) Test(org.junit.Test)

Example 7 with OnChangeSubscriptionQos

use of joynr.OnChangeSubscriptionQos in project joynr by bmwcarit.

the class AbstractSubscriptionEnd2EndTest method waitForSuccessfulSubscriptionRegistration.

@Test
@SuppressWarnings("unchecked")
public void waitForSuccessfulSubscriptionRegistration() throws InterruptedException, ApplicationException {
    AttributeSubscriptionListener<Integer> integerListener = mock(AttributeSubscriptionListener.class);
    SubscriptionQos subscriptionQos = new OnChangeSubscriptionQos();
    Future<String> subscriptionFuture = proxy.subscribeToTestAttribute(integerListener, subscriptionQos);
    String subscriptionId = subscriptionFuture.get(FUTURE_SUBSCRIPTION_ID_TIMEOUTMS);
    Thread.sleep(EXPECTED_LATENCY_MS);
    verify(integerListener).onSubscribed(eq(subscriptionId));
    verify(integerListener, times(0)).onError(null);
    verify(integerListener).onReceive(anyInt());
    proxy.unsubscribeFromTestAttribute(subscriptionId);
    verifyNoMoreInteractions(integerListener);
    getSubscriptionTestsPublisher().waitForAttributeUnsubscription("testAttribute");
}
Also used : OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) PeriodicSubscriptionQos(joynr.PeriodicSubscriptionQos) SubscriptionQos(io.joynr.pubsub.SubscriptionQos) OnChangeWithKeepAliveSubscriptionQos(joynr.OnChangeWithKeepAliveSubscriptionQos) Test(org.junit.Test)

Example 8 with OnChangeSubscriptionQos

use of joynr.OnChangeSubscriptionQos in project joynr by bmwcarit.

the class AbstractSubscriptionEnd2EndTest method waitForSuccessfulSubscriptionUpdate.

@Test
@SuppressWarnings("unchecked")
public void waitForSuccessfulSubscriptionUpdate() throws ApplicationException, InterruptedException {
    AttributeSubscriptionListener<Integer> integerListener = mock(AttributeSubscriptionListener.class);
    SubscriptionQos subscriptionQos = new OnChangeSubscriptionQos();
    Future<String> subscriptionFuture = proxy.subscribeToTestAttribute(integerListener, subscriptionQos);
    String subscriptionId = subscriptionFuture.get(FUTURE_SUBSCRIPTION_ID_TIMEOUTMS);
    subscriptionFuture = proxy.subscribeToTestAttribute(subscriptionId, integerListener, subscriptionQos);
    String subscriptionId2 = subscriptionFuture.get(FUTURE_SUBSCRIPTION_ID_TIMEOUTMS);
    assertEquals(subscriptionId, subscriptionId2);
    Thread.sleep(EXPECTED_LATENCY_MS);
    verify(integerListener, times(2)).onSubscribed(eq(subscriptionId));
    verify(integerListener, times(0)).onError(null);
    verify(integerListener, times(2)).onReceive(anyInt());
    proxy.unsubscribeFromTestAttribute(subscriptionId);
    verifyNoMoreInteractions(integerListener);
    getSubscriptionTestsPublisher().waitForAttributeUnsubscription("testAttribute");
}
Also used : OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) PeriodicSubscriptionQos(joynr.PeriodicSubscriptionQos) SubscriptionQos(io.joynr.pubsub.SubscriptionQos) OnChangeWithKeepAliveSubscriptionQos(joynr.OnChangeWithKeepAliveSubscriptionQos) Test(org.junit.Test)

Example 9 with OnChangeSubscriptionQos

use of joynr.OnChangeSubscriptionQos in project joynr by bmwcarit.

the class TtlUpliftTest method testBroadcastSubscriptionWithoutTtlUplift.

@SuppressWarnings("unchecked")
@Test(timeout = 3000)
public void testBroadcastSubscriptionWithoutTtlUplift() throws Exception {
    long validityMs = 300;
    long toleranceMs = 50;
    long publicationTtlMs = 1000;
    OnChangeSubscriptionQos qos = new OnChangeSubscriptionQos();
    qos.setMinIntervalMs(0);
    qos.setValidityMs(validityMs);
    qos.setPublicationTtlMs(publicationTtlMs);
    SubscriptionRequest subscriptionRequest = new BroadcastSubscriptionRequest(SUBSCRIPTION_ID, "location", null, 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);
    verifySubscriptionReplyTtl(validityMs, toleranceMs);
    verifyCleanupSchedulerDelay(validityMs, toleranceMs);
    publicationManager.broadcastOccurred(SUBSCRIPTION_ID, null, valueToPublish);
    // sending the broadcastOccurred
    verify(dispatcher, times(1)).sendSubscriptionPublication(eq(PROVIDER_PARTICIPANT_ID), (Set<String>) argThat(contains(PROXY_PARTICIPANT_ID)), any(SubscriptionPublication.class), argThat(new MessagingQosMatcher(publicationTtlMs)));
    Thread.sleep(validityMs + toleranceMs);
    reset(dispatcher);
    publicationManager.broadcastOccurred(SUBSCRIPTION_ID, null, valueToPublish);
    verify(dispatcher, timeout(300).times(0)).sendSubscriptionPublication(eq(PROVIDER_PARTICIPANT_ID), (Set<String>) argThat(contains(PROXY_PARTICIPANT_ID)), any(SubscriptionPublication.class), any(MessagingQos.class));
}
Also used : SubscriptionRequest(joynr.SubscriptionRequest) BroadcastSubscriptionRequest(joynr.BroadcastSubscriptionRequest) MessagingQos(io.joynr.messaging.MessagingQos) OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) BroadcastSubscriptionRequest(joynr.BroadcastSubscriptionRequest) SubscriptionPublication(joynr.SubscriptionPublication) Test(org.junit.Test)

Example 10 with OnChangeSubscriptionQos

use of joynr.OnChangeSubscriptionQos in project joynr by bmwcarit.

the class TtlUpliftTest method testAttributeSubscriptionWithTtlUplift.

@SuppressWarnings("unchecked")
@Test(timeout = 3000)
public void testAttributeSubscriptionWithTtlUplift() throws Exception {
    long validityMs = 300;
    long publicationTtlMs = 1000;
    OnChangeSubscriptionQos qos = new OnChangeSubscriptionQos();
    qos.setMinIntervalMs(0);
    qos.setValidityMs(validityMs);
    qos.setPublicationTtlMs(publicationTtlMs);
    long expectedSubscriptionReplyTtl = validityMs;
    long expectedPublicationTtlMs = publicationTtlMs;
    testAttributeSubscriptionWithTtlUplift(qos, validityMs, expectedSubscriptionReplyTtl, expectedPublicationTtlMs);
    publicationManagerWithTtlUplift.attributeValueChanged(SUBSCRIPTION_ID, valueToPublish);
    verify(dispatcher, timeout(300).times(0)).sendSubscriptionPublication(eq(PROVIDER_PARTICIPANT_ID), (Set<String>) argThat(contains(PROXY_PARTICIPANT_ID)), any(SubscriptionPublication.class), any(MessagingQos.class));
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) SubscriptionPublication(joynr.SubscriptionPublication) Test(org.junit.Test)

Aggregations

OnChangeSubscriptionQos (joynr.OnChangeSubscriptionQos)40 Test (org.junit.Test)35 MessagingQos (io.joynr.messaging.MessagingQos)20 SubscriptionPublication (joynr.SubscriptionPublication)18 SubscriptionRequest (joynr.SubscriptionRequest)16 BroadcastSubscriptionRequest (joynr.BroadcastSubscriptionRequest)15 Matchers.anyString (org.mockito.Matchers.anyString)15 SubscriptionQos (io.joynr.pubsub.SubscriptionQos)9 joynr.tests.testLocationUpdateSelectiveBroadcastFilter (joynr.tests.testLocationUpdateSelectiveBroadcastFilter)8 joynr.tests.testBroadcastInterface (joynr.tests.testBroadcastInterface)7 BroadcastFilter (io.joynr.pubsub.publication.BroadcastFilter)6 joynr.tests.testLocationUpdateWithSpeedSelectiveBroadcastFilter (joynr.tests.testLocationUpdateWithSpeedSelectiveBroadcastFilter)6 GpsLocation (joynr.types.Localisation.GpsLocation)6 Semaphore (java.util.concurrent.Semaphore)5 OnChangeWithKeepAliveSubscriptionQos (joynr.OnChangeWithKeepAliveSubscriptionQos)5 PeriodicSubscriptionQos (joynr.PeriodicSubscriptionQos)5 Method (java.lang.reflect.Method)4 ArrayList (java.util.ArrayList)4 Ignore (org.junit.Ignore)4 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)3