use of io.joynr.pubsub.SubscriptionQos in project joynr by bmwcarit.
the class SerializationTest method serializeSubscriptionRequest.
@Test
public void serializeSubscriptionRequest() throws JsonGenerationException, JsonMappingException, IOException {
String subscriptionId = "1234";
String subscribedToName = "myAttribute";
long expiryDate = System.currentTimeMillis() + 60000;
SubscriptionQos qos = new OnChangeSubscriptionQos().setMinIntervalMs(0).setExpiryDateMs(expiryDate).setPublicationTtlMs(1000);
SubscriptionRequest request = new SubscriptionRequest(subscriptionId, subscribedToName, qos);
String writeValueAsString = objectMapper.writeValueAsString(request);
SubscriptionRequest receivedRequest = objectMapper.readValue(writeValueAsString, SubscriptionRequest.class);
Assert.assertEquals(request, receivedRequest);
}
use of io.joynr.pubsub.SubscriptionQos 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 io.joynr.pubsub.SubscriptionQos 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 io.joynr.pubsub.SubscriptionQos in project joynr by bmwcarit.
the class PublicationManagerTest method restorePublications.
@SuppressWarnings("unchecked")
@Test(timeout = 3000)
public void restorePublications() throws Exception {
int period = 200;
String subscriptionId1 = "subscriptionid1";
String subscriptionId2 = "subscriptionid2";
long validityMs = 3000;
SubscriptionQos qosNoExpiry = new PeriodicSubscriptionQos().setPeriodMs(100).setExpiryDateMs(SubscriptionQos.NO_EXPIRY_DATE).setAlertAfterIntervalMs(500).setPublicationTtlMs(1000);
SubscriptionQos qosExpires = new PeriodicSubscriptionQos().setPeriodMs(100).setValidityMs(validityMs).setAlertAfterIntervalMs(500).setPublicationTtlMs(1000);
SubscriptionRequest subscriptionRequest1 = new SubscriptionRequest(subscriptionId1, "location", qosNoExpiry);
SubscriptionRequest subscriptionRequest2 = new SubscriptionRequest(subscriptionId2, "location", qosExpires);
publicationManager.addSubscriptionRequest(PROXY_PARTICIPANT_ID, PROVIDER_PARTICIPANT_ID, subscriptionRequest1);
publicationManager.addSubscriptionRequest(PROXY_PARTICIPANT_ID, PROVIDER_PARTICIPANT_ID, subscriptionRequest2);
Thread.sleep(period);
verify(dispatcher, times(0)).sendSubscriptionPublication(eq(PROVIDER_PARTICIPANT_ID), (Set<String>) argThat(contains(PROXY_PARTICIPANT_ID)), any(SubscriptionPublication.class), any(MessagingQos.class));
publicationManager.entryAdded(PROVIDER_PARTICIPANT_ID, providerContainer);
verify(dispatcher, timeout(period * 5).times(12)).sendSubscriptionPublication(eq(PROVIDER_PARTICIPANT_ID), (Set<String>) argThat(contains(PROXY_PARTICIPANT_ID)), any(SubscriptionPublication.class), any(MessagingQos.class));
}
use of io.joynr.pubsub.SubscriptionQos in project joynr by bmwcarit.
the class PublicationManagerTest method removeQueuedSubscriptionsProperly.
@SuppressWarnings("unchecked")
@Test(timeout = 3000)
public void removeQueuedSubscriptionsProperly() throws Exception {
int period = 200;
String subscriptionId1 = "subscriptionid_removeQueuedSubscriptionsProperly";
SubscriptionQos qosNoExpiry = new PeriodicSubscriptionQos().setPeriodMs(100).setExpiryDateMs(SubscriptionQos.NO_EXPIRY_DATE).setAlertAfterIntervalMs(500).setPublicationTtlMs(1000);
SubscriptionRequest subscriptionRequest1 = new SubscriptionRequest(subscriptionId1, "location", qosNoExpiry);
publicationManager.addSubscriptionRequest(PROXY_PARTICIPANT_ID, PROVIDER_PARTICIPANT_ID, subscriptionRequest1);
publicationManager.stopPublication(subscriptionId1);
publicationManager.entryAdded(PROVIDER_PARTICIPANT_ID, providerContainer);
Thread.sleep(period);
verify(dispatcher, times(0)).sendSubscriptionPublication(eq(PROVIDER_PARTICIPANT_ID), (Set<String>) argThat(contains(PROXY_PARTICIPANT_ID)), any(SubscriptionPublication.class), any(MessagingQos.class));
}
Aggregations