use of io.joynr.messaging.MessagingQos in project joynr by bmwcarit.
the class TtlUpliftTest method testTtlUpliftMsWithLargeTtl.
@Test
public void testTtlUpliftMsWithLargeTtl() {
MessagingQos messagingQos = new MessagingQos(LARGE_EXPIRY_DATE_MS);
MutableMessage message = messageFactoryWithTtlUplift.createRequest(fromParticipantId, toParticipantId, request, messagingQos);
long expiryDateValue = LARGE_EXPIRY_DATE_MS;
MutableMessageFactoryTest.assertExpiryDateEquals(expiryDateValue, message);
messagingQos = new MessagingQos(LARGE_EXPIRY_DATE_MS - TTL_UPLIFT_MS);
message = messageFactoryWithTtlUplift.createRequest(fromParticipantId, toParticipantId, request, messagingQos);
MutableMessageFactoryTest.assertExpiryDateEquals(expiryDateValue, message);
messagingQos = new MessagingQos(LARGE_EXPIRY_DATE_MS - TTL_UPLIFT_MS - System.currentTimeMillis());
message = messageFactoryWithTtlUplift.createRequest(fromParticipantId, toParticipantId, request, messagingQos);
MutableMessageFactoryTest.assertExpiryDateEquals(expiryDateValue, message);
messagingQos = new MessagingQos(LARGE_EXPIRY_DATE_MS - TTL_UPLIFT_MS - System.currentTimeMillis() + 1);
message = messageFactoryWithTtlUplift.createRequest(fromParticipantId, toParticipantId, request, messagingQos);
MutableMessageFactoryTest.assertExpiryDateEquals(expiryDateValue, message);
}
use of io.joynr.messaging.MessagingQos 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 io.joynr.messaging.MessagingQos 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));
}
use of io.joynr.messaging.MessagingQos in project joynr by bmwcarit.
the class MutableMessageFactoryTest method createRequestWithCustomEffort.
@Test
public void createRequestWithCustomEffort() {
MessagingQos customMessagingQos = new MessagingQos();
customMessagingQos.setEffort(MessagingQosEffort.BEST_EFFORT);
MutableMessage message = mutableMessageFactory.createRequest(fromParticipantId, toParticipantId, request, customMessagingQos);
expiryDate = DispatcherUtils.convertTtlToExpirationDate(customMessagingQos.getRoundTripTtl_ms());
assertExpiryDateEquals(expiryDate.getValue(), message);
assertEquals(String.valueOf(MessagingQosEffort.BEST_EFFORT), message.getEffort());
}
use of io.joynr.messaging.MessagingQos in project joynr by bmwcarit.
the class MutableMessageFactoryTest method testMessageProcessorUsed.
@Test
public void testMessageProcessorUsed() {
MutableMessage message = mutableMessageFactory.createRequest("from", "to", new Request("name", new Object[0], new Class[0]), new MessagingQos());
assertNotNull(message.getCustomHeaders().get("test"));
assertEquals("test", message.getCustomHeaders().get("test"));
}
Aggregations