Search in sources :

Example 16 with SubscriptionRequest

use of joynr.SubscriptionRequest in project joynr by bmwcarit.

the class PushingPublicationTest method setupPureOnChangedQos.

void setupPureOnChangedQos() {
    OnChangeSubscriptionQos qos = new OnChangeSubscriptionQos();
    qos.setMinIntervalMs(SubscriptionQos.IGNORE_VALUE).setValidityMs(19000).setPublicationTtlMs(1000);
    subscriptionRequest = new SubscriptionRequest(subscriptionId, attributeName, qos);
}
Also used : SubscriptionRequest(joynr.SubscriptionRequest) OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos)

Example 17 with SubscriptionRequest

use of joynr.SubscriptionRequest in project joynr by bmwcarit.

the class DispatcherImplTest method testReceiveMulticastSubscription.

@Test
public void testReceiveMulticastSubscription() throws Exception {
    String from = "from";
    String to = "to";
    MulticastSubscriptionRequest subscriptionRequest = new MulticastSubscriptionRequest("multicastId", "subscriptionId", "multicastName", new OnChangeSubscriptionQos());
    MutableMessage joynrMessage = messageFactory.createSubscriptionRequest(from, to, subscriptionRequest, new MessagingQos(1000L));
    MutableMessageFactory messageFactoryMock = mock(MutableMessageFactory.class);
    ObjectMapper objectMapperMock = mock(ObjectMapper.class);
    when(objectMapperMock.readValue(anyString(), eq(SubscriptionRequest.class))).thenReturn(subscriptionRequest);
    fixture = new DispatcherImpl(requestReplyManagerMock, subscriptionManagerMock, publicationManagerMock, messageRouterMock, messageSenderMock, messageFactoryMock, objectMapperMock);
    fixture.messageArrived(joynrMessage.getImmutableMessage());
    verify(publicationManagerMock).addSubscriptionRequest(eq(from), eq(to), eq(subscriptionRequest));
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) SubscriptionRequest(joynr.SubscriptionRequest) MulticastSubscriptionRequest(joynr.MulticastSubscriptionRequest) MutableMessage(joynr.MutableMessage) OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) Matchers.anyString(org.mockito.Matchers.anyString) MulticastSubscriptionRequest(joynr.MulticastSubscriptionRequest) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 18 with SubscriptionRequest

use of joynr.SubscriptionRequest in project joynr by bmwcarit.

the class PublicationTimersTest method publicationsSentUntilExpiryDate.

@SuppressWarnings("unchecked")
@Test(timeout = 4000)
public void publicationsSentUntilExpiryDate() throws InterruptedException, JoynrSendBufferFullException, JoynrMessageNotSentException, JsonGenerationException, JsonMappingException, IOException {
    LOG.debug("Starting PublicationTimersTest.timerIsStoppedWhenEnddateIsReached test");
    int period = 500;
    int subscriptionLength = 1100;
    PeriodicSubscriptionQos qos = new PeriodicSubscriptionQos();
    qos.setPeriodMs(period).setValidityMs(subscriptionLength).setPublicationTtlMs(1000);
    String subscriptionId = "subscriptionId";
    String proxyId = "proxyId";
    String providerId = "providerId";
    ProviderDirectory providerDirectory = Mockito.mock(ProviderDirectory.class);
    SubscriptionRequest subscriptionRequest = new SubscriptionRequest(subscriptionId, attributeName, qos);
    PublicationManager publicationManager = new PublicationManagerImpl(attributePollInterpreter, dispatcher, providerDirectory, cleanupScheduler, Mockito.mock(SubscriptionRequestStorage.class), shutdownNotifier);
    when(providerDirectory.get(eq(providerId))).thenReturn(providerContainer);
    when(providerDirectory.contains(eq(providerId))).thenReturn(true);
    publicationManager.addSubscriptionRequest(proxyId, providerId, subscriptionRequest);
    Thread.sleep(subscriptionLength + period / 2);
    int publicationTimes = 1 + (subscriptionLength / period);
    verify(dispatcher, times(publicationTimes)).sendSubscriptionPublication(eq(providerId), (Set<String>) argThat(contains(proxyId)), any(SubscriptionPublication.class), any(MessagingQos.class));
    Thread.sleep(subscriptionLength);
    verify(dispatcher).sendSubscriptionReply(eq(providerId), eq(proxyId), any(SubscriptionReply.class), any(MessagingQos.class));
    verifyNoMoreInteractions(dispatcher);
}
Also used : SubscriptionReply(joynr.SubscriptionReply) SubscriptionRequest(joynr.SubscriptionRequest) MessagingQos(io.joynr.messaging.MessagingQos) SubscriptionPublication(joynr.SubscriptionPublication) ProviderDirectory(io.joynr.dispatching.ProviderDirectory) PeriodicSubscriptionQos(joynr.PeriodicSubscriptionQos) Test(org.junit.Test)

Example 19 with SubscriptionRequest

use of joynr.SubscriptionRequest in project joynr by bmwcarit.

the class SubscriptionManagerTest method registerSubscription.

@SuppressWarnings("unchecked")
@Test
public void registerSubscription() throws JoynrSendBufferFullException, JoynrMessageNotSentException, JsonGenerationException, JsonMappingException, IOException {
    class IntegerReference extends TypeReference<Integer> {
    }
    Future<String> future = mock(Future.class);
    AttributeSubscribeInvocation subscriptionRequest = new AttributeSubscribeInvocation(attributeName, IntegerReference.class, attributeSubscriptionCallback, qos, future);
    subscriptionManager.registerAttributeSubscription(fromParticipantId, Sets.newHashSet(toDiscoveryEntry), subscriptionRequest);
    subscriptionId = subscriptionRequest.getSubscriptionId();
    verify(attributeSubscriptionDirectory).put(Mockito.anyString(), Mockito.eq(attributeSubscriptionCallback));
    verify(subscriptionStates).put(Mockito.anyString(), Mockito.any(PubSubState.class));
    verify(cleanupScheduler).schedule(Mockito.any(Runnable.class), Mockito.eq(qos.getExpiryDateMs()), Mockito.eq(TimeUnit.MILLISECONDS));
    verify(subscriptionEndFutures, Mockito.times(1)).put(Mockito.eq(subscriptionId), Mockito.any(ScheduledFuture.class));
    verify(dispatcher).sendSubscriptionRequest(eq(fromParticipantId), eq(Sets.newHashSet(toDiscoveryEntry)), any(SubscriptionRequest.class), any(MessagingQos.class));
}
Also used : SubscriptionRequest(joynr.SubscriptionRequest) MessagingQos(io.joynr.messaging.MessagingQos) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Matchers.anyString(org.mockito.Matchers.anyString) AttributeSubscribeInvocation(io.joynr.proxy.invocation.AttributeSubscribeInvocation) ScheduledFuture(java.util.concurrent.ScheduledFuture) Test(org.junit.Test)

Example 20 with SubscriptionRequest

use of joynr.SubscriptionRequest in project joynr by bmwcarit.

the class SubscriptionManagerTest method registerBroadcastSubscription.

@Test
public void registerBroadcastSubscription() throws JoynrSendBufferFullException, JoynrMessageNotSentException, JsonGenerationException, JsonMappingException, IOException {
    String broadcastName = "broadcastName";
    BroadcastSubscriptionListener broadcastSubscriptionListener = mock(LocationUpdateBroadcastListener.class);
    BroadcastSubscribeInvocation subscriptionRequest = new BroadcastSubscribeInvocation(broadcastName, broadcastSubscriptionListener, onChangeQos, future);
    subscriptionManager.registerBroadcastSubscription(fromParticipantId, Sets.newHashSet(toDiscoveryEntry), subscriptionRequest);
    subscriptionId = subscriptionRequest.getSubscriptionId();
    verify(broadcastSubscriptionDirectory).put(Mockito.anyString(), Mockito.eq(broadcastSubscriptionListener));
    verify(subscriptionStates).put(Mockito.anyString(), Mockito.any(PubSubState.class));
    verify(cleanupScheduler).schedule(Mockito.any(Runnable.class), Mockito.eq(onChangeQos.getExpiryDateMs()), Mockito.eq(TimeUnit.MILLISECONDS));
    verify(subscriptionEndFutures, Mockito.times(1)).put(Mockito.eq(subscriptionId), Mockito.any(ScheduledFuture.class));
    verify(dispatcher).sendSubscriptionRequest(eq(fromParticipantId), eq(Sets.newHashSet(toDiscoveryEntry)), any(SubscriptionRequest.class), any(MessagingQos.class));
}
Also used : SubscriptionRequest(joynr.SubscriptionRequest) MessagingQos(io.joynr.messaging.MessagingQos) BroadcastSubscribeInvocation(io.joynr.proxy.invocation.BroadcastSubscribeInvocation) Matchers.anyString(org.mockito.Matchers.anyString) BroadcastSubscriptionListener(io.joynr.pubsub.subscription.BroadcastSubscriptionListener) ScheduledFuture(java.util.concurrent.ScheduledFuture) Test(org.junit.Test)

Aggregations

SubscriptionRequest (joynr.SubscriptionRequest)32 BroadcastSubscriptionRequest (joynr.BroadcastSubscriptionRequest)24 Test (org.junit.Test)24 MessagingQos (io.joynr.messaging.MessagingQos)23 SubscriptionPublication (joynr.SubscriptionPublication)22 OnChangeSubscriptionQos (joynr.OnChangeSubscriptionQos)19 Matchers.anyString (org.mockito.Matchers.anyString)18 PeriodicSubscriptionQos (joynr.PeriodicSubscriptionQos)8 SubscriptionQos (io.joynr.pubsub.SubscriptionQos)7 BroadcastFilter (io.joynr.pubsub.publication.BroadcastFilter)6 joynr.tests.testLocationUpdateSelectiveBroadcastFilter (joynr.tests.testLocationUpdateSelectiveBroadcastFilter)6 joynr.tests.testLocationUpdateWithSpeedSelectiveBroadcastFilter (joynr.tests.testLocationUpdateWithSpeedSelectiveBroadcastFilter)6 ProviderDirectory (io.joynr.dispatching.ProviderDirectory)5 MulticastSubscriptionRequest (joynr.MulticastSubscriptionRequest)5 ArrayList (java.util.ArrayList)4 SubscriptionReply (joynr.SubscriptionReply)4 joynr.tests.testBroadcastInterface (joynr.tests.testBroadcastInterface)4 GpsLocation (joynr.types.Localisation.GpsLocation)4 MutableMessage (joynr.MutableMessage)3 OnChangeWithKeepAliveSubscriptionQos (joynr.OnChangeWithKeepAliveSubscriptionQos)3