Search in sources :

Example 21 with OnChangeSubscriptionQos

use of joynr.OnChangeSubscriptionQos 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 22 with OnChangeSubscriptionQos

use of joynr.OnChangeSubscriptionQos 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 23 with OnChangeSubscriptionQos

use of joynr.OnChangeSubscriptionQos in project joynr by bmwcarit.

the class AbstractBroadcastEnd2EndTest method createDefaultOnChangeSubscriptionQos.

private OnChangeSubscriptionQos createDefaultOnChangeSubscriptionQos() {
    OnChangeSubscriptionQos onChangeSubscriptionQos = new OnChangeSubscriptionQos();
    onChangeSubscriptionQos.setMinIntervalMs(0).setValidityMs(CONST_DEFAULT_TEST_TIMEOUT).setPublicationTtlMs(CONST_DEFAULT_TEST_TIMEOUT);
    return onChangeSubscriptionQos;
}
Also used : OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos)

Example 24 with OnChangeSubscriptionQos

use of joynr.OnChangeSubscriptionQos in project joynr by bmwcarit.

the class AbstractBroadcastEnd2EndTest method subscribeToSelectiveBroadcast_FilterFalse.

@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void subscribeToSelectiveBroadcast_FilterFalse() throws InterruptedException {
    final Semaphore broadcastReceived = new Semaphore(0);
    final LocationUpdateSelectiveBroadcastFilterParameters testFilterParameters = new LocationUpdateSelectiveBroadcastFilterParameters();
    testFilterParameters.setCountry("Germany");
    testFilterParameters.setStartTime("4.00 pm");
    testLocationUpdateSelectiveBroadcastFilter filter1 = new testLocationUpdateSelectiveBroadcastFilter() {

        @Override
        public boolean filter(GpsLocation location, LocationUpdateSelectiveBroadcastFilterParameters filterParameters) {
            assertEquals(testFilterParameters, filterParameters);
            return true;
        }
    };
    testLocationUpdateSelectiveBroadcastFilter filter2 = new testLocationUpdateSelectiveBroadcastFilter() {

        @Override
        public boolean filter(GpsLocation location, LocationUpdateSelectiveBroadcastFilterParameters filterParameters) {
            assertEquals(testFilterParameters, filterParameters);
            return false;
        }
    };
    getSubscriptionTestsPublisher().addBroadcastFilter(filter1);
    getSubscriptionTestsPublisher().addBroadcastFilter(filter2);
    OnChangeSubscriptionQos subscriptionQos = createDefaultOnChangeSubscriptionQos();
    proxy.subscribeToLocationUpdateSelectiveBroadcast(new testBroadcastInterface.LocationUpdateSelectiveBroadcastAdapter() {

        @Override
        public void onReceive(GpsLocation location) {
            assertEquals(expectedLocation, location);
            broadcastReceived.release();
        }
    }, subscriptionQos, testFilterParameters);
    Thread.sleep(300);
    provider.fireLocationUpdateSelective(expectedLocation);
    assertFalse(broadcastReceived.tryAcquire(500, TimeUnit.MILLISECONDS));
}
Also used : OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) GpsLocation(joynr.types.Localisation.GpsLocation) LocationUpdateSelectiveBroadcastFilterParameters(joynr.tests.testBroadcastInterface.LocationUpdateSelectiveBroadcastFilterParameters) joynr.tests.testLocationUpdateSelectiveBroadcastFilter(joynr.tests.testLocationUpdateSelectiveBroadcastFilter) Semaphore(java.util.concurrent.Semaphore) joynr.tests.testBroadcastInterface(joynr.tests.testBroadcastInterface) Test(org.junit.Test)

Example 25 with OnChangeSubscriptionQos

use of joynr.OnChangeSubscriptionQos in project joynr by bmwcarit.

the class PublicationManagerImpl method handleSubscriptionRequest.

private void handleSubscriptionRequest(PublicationInformation publicationInformation, SubscriptionRequest subscriptionRequest, ProviderContainer providerContainer) {
    final String subscriptionId = subscriptionRequest.getSubscriptionId();
    SubscriptionQos subscriptionQos = subscriptionRequest.getQos();
    MessagingQos messagingQos = createMessagingQos(subscriptionQos);
    try {
        Method method = findGetterForAttributeName(providerContainer.getProviderProxy().getClass(), subscriptionRequest.getSubscribedToName());
        triggerPublication(publicationInformation, providerContainer, method);
        boolean hasSubscriptionHeartBeat = subscriptionQos instanceof HeartbeatSubscriptionInformation;
        boolean isOnChangeSubscription = subscriptionQos instanceof OnChangeSubscriptionQos;
        if (hasSubscriptionHeartBeat || isOnChangeSubscription) {
            // TODO: send error subscription reply is periodMs < MIN_PERIOD_MS or periodMs > MAX_PERIOD_MS?
            final PublicationTimer timer = new PublicationTimer(publicationInformation, method, providerContainer, this, attributePollInterpreter);
            timer.startTimer();
            publicationTimers.put(subscriptionId, timer);
        }
        if (subscriptionQos instanceof OnChangeSubscriptionQos) {
            handleOnChangeSubscription(subscriptionRequest, providerContainer, subscriptionId);
        }
        dispatcher.sendSubscriptionReply(publicationInformation.providerParticipantId, publicationInformation.proxyParticipantId, new SubscriptionReply(subscriptionId), messagingQos);
    } catch (NoSuchMethodException e) {
        cancelPublicationCreation(subscriptionId);
        logger.error("Error subscribing: {}. The provider does not have the requested attribute", subscriptionRequest);
        sendSubscriptionReplyWithError(publicationInformation, subscriptionId, e, messagingQos);
    }
}
Also used : SubscriptionReply(joynr.SubscriptionReply) MessagingQos(io.joynr.messaging.MessagingQos) OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) UnicastSubscriptionQos(joynr.UnicastSubscriptionQos) SubscriptionQos(io.joynr.pubsub.SubscriptionQos) Method(java.lang.reflect.Method) HeartbeatSubscriptionInformation(io.joynr.pubsub.HeartbeatSubscriptionInformation)

Aggregations

OnChangeSubscriptionQos (joynr.OnChangeSubscriptionQos)40 Test (org.junit.Test)35 MessagingQos (io.joynr.messaging.MessagingQos)20 SubscriptionPublication (joynr.SubscriptionPublication)18 SubscriptionRequest (joynr.SubscriptionRequest)16 BroadcastSubscriptionRequest (joynr.BroadcastSubscriptionRequest)15 Matchers.anyString (org.mockito.Matchers.anyString)15 SubscriptionQos (io.joynr.pubsub.SubscriptionQos)9 joynr.tests.testLocationUpdateSelectiveBroadcastFilter (joynr.tests.testLocationUpdateSelectiveBroadcastFilter)8 joynr.tests.testBroadcastInterface (joynr.tests.testBroadcastInterface)7 BroadcastFilter (io.joynr.pubsub.publication.BroadcastFilter)6 joynr.tests.testLocationUpdateWithSpeedSelectiveBroadcastFilter (joynr.tests.testLocationUpdateWithSpeedSelectiveBroadcastFilter)6 GpsLocation (joynr.types.Localisation.GpsLocation)6 Semaphore (java.util.concurrent.Semaphore)5 OnChangeWithKeepAliveSubscriptionQos (joynr.OnChangeWithKeepAliveSubscriptionQos)5 PeriodicSubscriptionQos (joynr.PeriodicSubscriptionQos)5 Method (java.lang.reflect.Method)4 ArrayList (java.util.ArrayList)4 Ignore (org.junit.Ignore)4 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)3