Search in sources :

Example 16 with MessagingQos

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);
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) MutableMessage(joynr.MutableMessage) Test(org.junit.Test)

Example 17 with MessagingQos

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);
}
Also used : OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) ArrayList(java.util.ArrayList) GpsLocation(joynr.types.Localisation.GpsLocation) joynr.tests.testLocationUpdateSelectiveBroadcastFilter(joynr.tests.testLocationUpdateSelectiveBroadcastFilter) Matchers.anyString(org.mockito.Matchers.anyString) joynr.tests.testBroadcastInterface(joynr.tests.testBroadcastInterface) SubscriptionRequest(joynr.SubscriptionRequest) BroadcastSubscriptionRequest(joynr.BroadcastSubscriptionRequest) MessagingQos(io.joynr.messaging.MessagingQos) BroadcastSubscriptionRequest(joynr.BroadcastSubscriptionRequest) SubscriptionPublication(joynr.SubscriptionPublication) BroadcastFilter(io.joynr.pubsub.publication.BroadcastFilter) joynr.tests.testLocationUpdateWithSpeedSelectiveBroadcastFilter(joynr.tests.testLocationUpdateWithSpeedSelectiveBroadcastFilter) joynr.tests.testLocationUpdateSelectiveBroadcastFilter(joynr.tests.testLocationUpdateSelectiveBroadcastFilter) Test(org.junit.Test)

Example 18 with MessagingQos

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));
}
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 19 with MessagingQos

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());
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) MutableMessage(joynr.MutableMessage) Test(org.junit.Test)

Example 20 with MessagingQos

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"));
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) MutableMessage(joynr.MutableMessage) MulticastSubscriptionRequest(joynr.MulticastSubscriptionRequest) SubscriptionRequest(joynr.SubscriptionRequest) Request(joynr.Request) Test(org.junit.Test)

Aggregations

MessagingQos (io.joynr.messaging.MessagingQos)55 Test (org.junit.Test)23 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)19 MutableMessage (joynr.MutableMessage)15 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)11 Matchers.anyString (org.mockito.Matchers.anyString)11 OnChangeSubscriptionQos (joynr.OnChangeSubscriptionQos)9 SubscriptionRequest (joynr.SubscriptionRequest)9 Before (org.junit.Before)8 Properties (java.util.Properties)6 ImmutableMessage (joynr.ImmutableMessage)6 Request (joynr.Request)6 Injector (com.google.inject.Injector)5 BroadcastSubscriptionRequest (joynr.BroadcastSubscriptionRequest)5 MulticastSubscriptionRequest (joynr.MulticastSubscriptionRequest)5 joynr.tests.testProxy (joynr.tests.testProxy)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 AbstractModule (com.google.inject.AbstractModule)4 IOException (java.io.IOException)4 OneWayRequest (joynr.OneWayRequest)4