Search in sources :

Example 6 with SubscriptionQos

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);
}
Also used : SubscriptionRequest(joynr.SubscriptionRequest) PersistedSubscriptionRequest(io.joynr.dispatching.subscription.PersistedSubscriptionRequest) BroadcastSubscriptionRequest(joynr.BroadcastSubscriptionRequest) OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) SubscriptionQos(io.joynr.pubsub.SubscriptionQos) OnChangeWithKeepAliveSubscriptionQos(joynr.OnChangeWithKeepAliveSubscriptionQos) Test(org.junit.Test)

Example 7 with SubscriptionQos

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

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

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));
}
Also used : SubscriptionRequest(joynr.SubscriptionRequest) BroadcastSubscriptionRequest(joynr.BroadcastSubscriptionRequest) MessagingQos(io.joynr.messaging.MessagingQos) SubscriptionPublication(joynr.SubscriptionPublication) OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) PeriodicSubscriptionQos(joynr.PeriodicSubscriptionQos) SubscriptionQos(io.joynr.pubsub.SubscriptionQos) Matchers.anyString(org.mockito.Matchers.anyString) PeriodicSubscriptionQos(joynr.PeriodicSubscriptionQos) Test(org.junit.Test)

Example 10 with SubscriptionQos

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));
}
Also used : SubscriptionRequest(joynr.SubscriptionRequest) BroadcastSubscriptionRequest(joynr.BroadcastSubscriptionRequest) MessagingQos(io.joynr.messaging.MessagingQos) SubscriptionPublication(joynr.SubscriptionPublication) OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) PeriodicSubscriptionQos(joynr.PeriodicSubscriptionQos) SubscriptionQos(io.joynr.pubsub.SubscriptionQos) Matchers.anyString(org.mockito.Matchers.anyString) PeriodicSubscriptionQos(joynr.PeriodicSubscriptionQos) Test(org.junit.Test)

Aggregations

SubscriptionQos (io.joynr.pubsub.SubscriptionQos)25 OnChangeSubscriptionQos (joynr.OnChangeSubscriptionQos)18 Test (org.junit.Test)17 MessagingQos (io.joynr.messaging.MessagingQos)10 PeriodicSubscriptionQos (joynr.PeriodicSubscriptionQos)10 SubscriptionRequest (joynr.SubscriptionRequest)8 BroadcastSubscriptionRequest (joynr.BroadcastSubscriptionRequest)7 Matchers.anyString (org.mockito.Matchers.anyString)7 OnChangeWithKeepAliveSubscriptionQos (joynr.OnChangeWithKeepAliveSubscriptionQos)5 UnicastSubscriptionQos (joynr.UnicastSubscriptionQos)5 Method (java.lang.reflect.Method)4 SubscriptionPublication (joynr.SubscriptionPublication)4 SubscriptionException (io.joynr.exceptions.SubscriptionException)3 AttributeSubscribeInvocation (io.joynr.proxy.invocation.AttributeSubscribeInvocation)3 MulticastSubscriptionQos (joynr.MulticastSubscriptionQos)3 SubscriptionReply (joynr.SubscriptionReply)3 PersistedSubscriptionRequest (io.joynr.dispatching.subscription.PersistedSubscriptionRequest)2 MulticastSubscribeInvocation (io.joynr.proxy.invocation.MulticastSubscribeInvocation)2 AttributeSubscriptionAdapter (io.joynr.pubsub.subscription.AttributeSubscriptionAdapter)2 AttributeSubscriptionListener (io.joynr.pubsub.subscription.AttributeSubscriptionListener)2