use of joynr.SubscriptionPublication in project joynr by bmwcarit.
the class PublicationManagerImpl method sendPublicationError.
private void sendPublicationError(JoynrRuntimeException error, PublicationInformation publicationInformation) {
SubscriptionPublication publication = new SubscriptionPublication(error, publicationInformation.getSubscriptionId());
sendPublication(publication, publicationInformation);
}
use of joynr.SubscriptionPublication in project joynr by bmwcarit.
the class SerializationTest method serializePublication.
@Test
public void serializePublication() throws JsonGenerationException, JsonMappingException, IOException {
Object response = new GpsPosition(49.0065, 11.65);
String subscriptionId = "1234";
SubscriptionPublication publication = new SubscriptionPublication(Arrays.asList(response), subscriptionId);
String writeValueAsString = objectMapper.writeValueAsString(publication);
SubscriptionPublication receivedPublication = objectMapper.readValue(writeValueAsString, SubscriptionPublication.class);
Assert.assertEquals(publication, receivedPublication);
}
use of joynr.SubscriptionPublication in project joynr by bmwcarit.
the class TtlUpliftTest method testTtlUpliftMs_Publication.
@Test
public void testTtlUpliftMs_Publication() {
SubscriptionPublication subscriptionPublication = new SubscriptionPublication();
expiryDate = DispatcherUtils.convertTtlToExpirationDate(messagingQos.getRoundTripTtl_ms());
MutableMessage message = messageFactoryWithTtlUplift.createPublication(fromParticipantId, toParticipantId, subscriptionPublication, messagingQos);
long expiryDateValue = expiryDate.getValue() + TTL_UPLIFT_MS;
MutableMessageFactoryTest.assertExpiryDateEquals(expiryDateValue, message);
}
use of joynr.SubscriptionPublication 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.SubscriptionPublication in project joynr by bmwcarit.
the class PublicationManagerImpl method attributeValueChanged.
@Override
public void attributeValueChanged(String subscriptionId, Object value) {
if (subscriptionId2PublicationInformation.containsKey(subscriptionId)) {
PublicationInformation publicationInformation = subscriptionId2PublicationInformation.get(subscriptionId);
if (isExpired(publicationInformation)) {
removePublication(subscriptionId);
} else {
PublicationTimer publicationTimer = publicationTimers.get(subscriptionId);
SubscriptionPublication publication = prepareAttributePublication(value, subscriptionId);
if (publicationTimer != null) {
// used by OnChangedWithKeepAlive
publicationTimer.sendPublicationNow(publication);
} else {
sendPublication(publication, publicationInformation);
}
logger.trace("attribute changed for subscription id: {} sending publication if delay > minInterval.", subscriptionId);
}
} else {
logger.trace("subscription {} has expired but attributeValueChanged has been called", subscriptionId);
}
}
Aggregations