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");
}
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");
}
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");
}
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));
}
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));
}
Aggregations