Search in sources :

Example 21 with PeriodicSubscriptionQos

use of joynr.PeriodicSubscriptionQos in project joynr by bmwcarit.

the class PublicationManagerTest method startAndStopPeriodicPublication.

@SuppressWarnings("unchecked")
@Test(timeout = 3000)
public void startAndStopPeriodicPublication() throws Exception {
    int period = 200;
    int testLengthMax = 3000;
    PeriodicSubscriptionQos qos = new PeriodicSubscriptionQos();
    qos.setPeriodMs(200).setValidityMs(testLengthMax).setPublicationTtlMs(testLengthMax);
    SubscriptionRequest subscriptionRequest = new SubscriptionRequest(SUBSCRIPTION_ID, "location", 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);
    verify(dispatcher, timeout(period * 5).times(6)).sendSubscriptionPublication(eq(PROVIDER_PARTICIPANT_ID), (Set<String>) argThat(contains(PROXY_PARTICIPANT_ID)), any(SubscriptionPublication.class), any(MessagingQos.class));
    reset(dispatcher);
    publicationManager.stopPublication(SUBSCRIPTION_ID);
    verify(dispatcher, timeout(testLengthMax).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) Matchers.anyString(org.mockito.Matchers.anyString) PeriodicSubscriptionQos(joynr.PeriodicSubscriptionQos) Test(org.junit.Test)

Example 22 with PeriodicSubscriptionQos

use of joynr.PeriodicSubscriptionQos in project joynr by bmwcarit.

the class PublicationManagerTest method addPublicationWithoutExpiryDate.

@SuppressWarnings("unchecked")
@Test(timeout = 3000)
public void addPublicationWithoutExpiryDate() throws Exception {
    int period = 200;
    PeriodicSubscriptionQos qos = new PeriodicSubscriptionQos();
    qos.setPeriodMs(period).setValidityMs(SubscriptionQos.IGNORE_VALUE);
    qos.setAlertAfterIntervalMs(500).setPublicationTtlMs(1000);
    SubscriptionRequest subscriptionRequest = new SubscriptionRequest(SUBSCRIPTION_ID, "location", 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);
    verify(dispatcher, timeout(period * 5).times(6)).sendSubscriptionPublication(eq(PROVIDER_PARTICIPANT_ID), (Set<String>) argThat(contains(PROXY_PARTICIPANT_ID)), any(SubscriptionPublication.class), any(MessagingQos.class));
    reset(dispatcher);
    publicationManager.stopPublication(SUBSCRIPTION_ID);
    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) SubscriptionPublication(joynr.SubscriptionPublication) Matchers.anyString(org.mockito.Matchers.anyString) PeriodicSubscriptionQos(joynr.PeriodicSubscriptionQos) Test(org.junit.Test)

Example 23 with PeriodicSubscriptionQos

use of joynr.PeriodicSubscriptionQos 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)

Aggregations

PeriodicSubscriptionQos (joynr.PeriodicSubscriptionQos)23 Test (org.junit.Test)20 MessagingQos (io.joynr.messaging.MessagingQos)10 SubscriptionPublication (joynr.SubscriptionPublication)8 SubscriptionRequest (joynr.SubscriptionRequest)8 Matchers.anyString (org.mockito.Matchers.anyString)7 Semaphore (java.util.concurrent.Semaphore)6 BroadcastSubscriptionRequest (joynr.BroadcastSubscriptionRequest)6 SubscriptionQos (io.joynr.pubsub.SubscriptionQos)5 OnChangeSubscriptionQos (joynr.OnChangeSubscriptionQos)5 InvocationOnMock (org.mockito.invocation.InvocationOnMock)4 AttributeSubscribeInvocation (io.joynr.proxy.invocation.AttributeSubscribeInvocation)3 Ignore (org.junit.Ignore)3 ProviderDirectory (io.joynr.dispatching.ProviderDirectory)2 JoynrIllegalStateException (io.joynr.exceptions.JoynrIllegalStateException)2 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)2 AttributeSubscriptionAdapter (io.joynr.pubsub.subscription.AttributeSubscriptionAdapter)2 Method (java.lang.reflect.Method)2 ProviderRuntimeException (joynr.exceptions.ProviderRuntimeException)2 PublicationMissedException (joynr.exceptions.PublicationMissedException)2