use of joynr.OnChangeSubscriptionQos in project joynr by bmwcarit.
the class PublicationManagerTest method broadcastPublicationNotSentWhenFiltersFail.
@SuppressWarnings("unchecked")
@Test
public void broadcastPublicationNotSentWhenFiltersFail() throws Exception {
publicationManager = new PublicationManagerImpl(attributePollInterpreter, dispatcher, providerDirectory, cleanupScheduler, Mockito.mock(SubscriptionRequestStorage.class), shutdownNotifier);
long minInterval_ms = 0;
long ttl = 1000;
testBroadcastInterface.LocationUpdateSelectiveBroadcastFilterParameters filterParameters = new testBroadcastInterface.LocationUpdateSelectiveBroadcastFilterParameters();
OnChangeSubscriptionQos qos = new OnChangeSubscriptionQos().setMinIntervalMs(minInterval_ms).setExpiryDateMs(SubscriptionQos.NO_EXPIRY_DATE).setPublicationTtlMs(ttl);
SubscriptionRequest subscriptionRequest = new BroadcastSubscriptionRequest(SUBSCRIPTION_ID, "subscribedToName", filterParameters, 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);
GpsLocation eventValue = new GpsLocation();
ArrayList<BroadcastFilter> filters = new ArrayList<BroadcastFilter>();
testLocationUpdateSelectiveBroadcastFilter filterTrue = mock(testLocationUpdateSelectiveBroadcastFilter.class);
when(filterTrue.filter(any(GpsLocation.class), any(testBroadcastInterface.LocationUpdateSelectiveBroadcastFilterParameters.class))).thenReturn(true);
filters.add(filterTrue);
testLocationUpdateSelectiveBroadcastFilter filterFalse = mock(testLocationUpdateSelectiveBroadcastFilter.class);
when(filterFalse.filter(any(GpsLocation.class), any(testBroadcastInterface.LocationUpdateSelectiveBroadcastFilterParameters.class))).thenReturn(false);
filters.add(filterFalse);
publicationManager.broadcastOccurred(subscriptionRequest.getSubscriptionId(), filters, eventValue);
verify(dispatcher, never()).sendSubscriptionPublication(any(String.class), any(Set.class), any(SubscriptionPublication.class), any(MessagingQos.class));
}
use of joynr.OnChangeSubscriptionQos in project joynr by bmwcarit.
the class PublicationManagerTest method broadcastPublicationCallsAllFiltersWithFilterParametersAndValues.
@SuppressWarnings("unchecked")
@Test
public void broadcastPublicationCallsAllFiltersWithFilterParametersAndValues() throws Exception {
publicationManager = new PublicationManagerImpl(attributePollInterpreter, dispatcher, providerDirectory, cleanupScheduler, Mockito.mock(SubscriptionRequestStorage.class), shutdownNotifier);
long minInterval_ms = 0;
long ttl = 1000;
testBroadcastInterface.LocationUpdateSelectiveBroadcastFilterParameters filterParameters = new testBroadcastInterface.LocationUpdateSelectiveBroadcastFilterParameters();
filterParameters.setCountry("Germany");
filterParameters.setStartTime("4:00");
OnChangeSubscriptionQos qos = new OnChangeSubscriptionQos().setMinIntervalMs(minInterval_ms).setExpiryDateMs(SubscriptionQos.NO_EXPIRY_DATE).setPublicationTtlMs(ttl);
SubscriptionRequest subscriptionRequest = new BroadcastSubscriptionRequest(SUBSCRIPTION_ID, "subscribedToName", filterParameters, 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);
GpsLocation eventValue = new GpsLocation();
ArrayList<BroadcastFilter> filters = new ArrayList<BroadcastFilter>();
testLocationUpdateSelectiveBroadcastFilter filter1 = mock(testLocationUpdateSelectiveBroadcastFilter.class);
when(filter1.filter(any(GpsLocation.class), any(testBroadcastInterface.LocationUpdateSelectiveBroadcastFilterParameters.class))).thenReturn(true);
filters.add(filter1);
testLocationUpdateSelectiveBroadcastFilter filter2 = mock(testLocationUpdateSelectiveBroadcastFilter.class);
when(filter2.filter(any(GpsLocation.class), any(testBroadcastInterface.LocationUpdateSelectiveBroadcastFilterParameters.class))).thenReturn(true);
filters.add(filter2);
publicationManager.broadcastOccurred(subscriptionRequest.getSubscriptionId(), filters, eventValue);
ArgumentCaptor<SubscriptionPublication> publicationCaptured = ArgumentCaptor.forClass(SubscriptionPublication.class);
ArgumentCaptor<MessagingQos> qosCaptured = ArgumentCaptor.forClass(MessagingQos.class);
verify(dispatcher).sendSubscriptionPublication(eq(PROVIDER_PARTICIPANT_ID), (Set<String>) argThat(contains(PROXY_PARTICIPANT_ID)), publicationCaptured.capture(), qosCaptured.capture());
verify(filter1).filter(eventValue, filterParameters);
verify(filter2).filter(eventValue, filterParameters);
}
use of joynr.OnChangeSubscriptionQos in project joynr by bmwcarit.
the class PublicationManagerTest method stopAllPublicationsFromProvider.
@SuppressWarnings("unchecked")
@Test(timeout = 3000)
public void stopAllPublicationsFromProvider() throws Exception {
String subscriptionId1 = "subscriptionid1";
String subscriptionId2 = "subscriptionid2";
OnChangeSubscriptionQos qos = new OnChangeSubscriptionQos();
qos.setMinIntervalMs(0).setValidityMs(3000).setPublicationTtlMs(1000);
SubscriptionRequest subscriptionRequest1 = new SubscriptionRequest(subscriptionId1, "location", qos);
SubscriptionRequest subscriptionRequest2 = new SubscriptionRequest(subscriptionId2, "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, subscriptionRequest1);
publicationManager.addSubscriptionRequest(PROXY_PARTICIPANT_ID, PROVIDER_PARTICIPANT_ID, subscriptionRequest2);
publicationManager.attributeValueChanged(subscriptionId1, valueToPublish);
publicationManager.attributeValueChanged(subscriptionId2, valueToPublish);
// sending initial values for 2 subscriptions, plus the 2 attributeValueChanged
verify(dispatcher, times(4)).sendSubscriptionPublication(eq(PROVIDER_PARTICIPANT_ID), (Set<String>) argThat(contains(PROXY_PARTICIPANT_ID)), any(SubscriptionPublication.class), any(MessagingQos.class));
reset(dispatcher);
publicationManager.entryRemoved(PROVIDER_PARTICIPANT_ID);
publicationManager.attributeValueChanged(subscriptionId1, valueToPublish);
publicationManager.attributeValueChanged(subscriptionId2, valueToPublish);
verify(dispatcher, timeout(300).times(0)).sendSubscriptionPublication(eq(PROVIDER_PARTICIPANT_ID), (Set<String>) argThat(contains(PROXY_PARTICIPANT_ID)), any(SubscriptionPublication.class), any(MessagingQos.class));
}
use of joynr.OnChangeSubscriptionQos in project joynr by bmwcarit.
the class PublicationManagerTest method doNotDelayBroadcastPublicationBurstsForOnChangeSubscriptionsWithoutMinInterval.
@SuppressWarnings("unchecked")
@Test(timeout = 4000)
public void doNotDelayBroadcastPublicationBurstsForOnChangeSubscriptionsWithoutMinInterval() throws Exception {
int subscriptionLength = 500;
OnChangeSubscriptionQos qos = new OnChangeSubscriptionQos();
qos.setMinIntervalMs(0);
qos.setValidityMs(subscriptionLength);
qos.setPublicationTtlMs(400);
String subscriptionId = "subscriptionId";
String proxyId = "proxyId";
String providerId = "providerId";
String broadcastName = "location";
ProviderDirectory requestCallerDirectory = mock(ProviderDirectory.class);
SubscriptionRequest subscriptionRequest = new BroadcastSubscriptionRequest(subscriptionId, broadcastName, new BroadcastFilterParameters(), qos);
PublicationManager publicationManager = new PublicationManagerImpl(attributePollInterpreter, dispatcher, requestCallerDirectory, cleanupScheduler, Mockito.mock(SubscriptionRequestStorage.class), shutdownNotifier);
when(requestCallerDirectory.get(eq(providerId))).thenReturn(providerContainer);
when(requestCallerDirectory.contains(eq(providerId))).thenReturn(true);
publicationManager.addSubscriptionRequest(proxyId, providerId, subscriptionRequest);
List<BroadcastFilter> noFilters = Lists.newArrayList();
int nrBroadcasts = 100;
for (int i = 0; i < nrBroadcasts; i++) {
publicationManager.broadcastOccurred(subscriptionId, noFilters, 2 * i + 1);
}
Thread.sleep(subscriptionLength);
verify(dispatcher, times(nrBroadcasts)).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));
// (eq(subscriptionRequest), eq(proxyId), eq(providerId));
verifyNoMoreInteractions(dispatcher);
}
use of joynr.OnChangeSubscriptionQos in project joynr by bmwcarit.
the class PublicationManagerTest method modifySubscriptionTypeForExistingSubscription.
@SuppressWarnings("unchecked")
@Test(timeout = 3000)
public void modifySubscriptionTypeForExistingSubscription() throws Exception {
publicationManager = new PublicationManagerImpl(attributePollInterpreter, dispatcher, providerDirectory, cleanupScheduler, Mockito.mock(SubscriptionRequestStorage.class), shutdownNotifier);
int period = 200;
int testLengthMax = 3000;
long validityMs = testLengthMax;
long publicationTtl = testLengthMax;
SubscriptionQos qos = new PeriodicSubscriptionQos().setPeriodMs(period).setValidityMs(validityMs).setPublicationTtlMs(publicationTtl);
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));
qos = new OnChangeSubscriptionQos().setMinIntervalMs(0).setValidityMs(validityMs).setPublicationTtlMs(publicationTtl);
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);
reset(dispatcher);
publicationManager.attributeValueChanged(SUBSCRIPTION_ID, valueToPublish);
verify(dispatcher, timeout(testLengthMax).times(1)).sendSubscriptionPublication(eq(PROVIDER_PARTICIPANT_ID), (Set<String>) argThat(contains(PROXY_PARTICIPANT_ID)), any(SubscriptionPublication.class), any(MessagingQos.class));
}
Aggregations