Search in sources :

Example 11 with Address

use of joynr.system.RoutingTypes.Address in project joynr by bmwcarit.

the class AddressManagerTest method testGetLocalMulticastParticipantAddresses.

@Test
public void testGetLocalMulticastParticipantAddresses() {
    createAddressManager(GLOBAL_TRANSPORT_MQTT, multicastAddressCalculator);
    when(joynrMessage.isReceivedFromGlobal()).thenReturn(true);
    when(joynrMessage.getSender()).thenReturn("from");
    String multicastId = "from/to";
    when(joynrMessage.getRecipient()).thenReturn(multicastId);
    Set<String> participantIds = Sets.newHashSet("one", "two");
    when(multicastReceiverRegistry.getReceivers(multicastId)).thenReturn(participantIds);
    Address addressOne = mock(Address.class);
    when(routingTable.get("one")).thenReturn(addressOne);
    Address addressTwo = mock(Address.class);
    when(routingTable.get("two")).thenReturn(addressTwo);
    when(multicastAddressCalculator.supports(GLOBAL_TRANSPORT_MQTT)).thenReturn(true);
    Set<Address> result = subject.getAddresses(joynrMessage);
    assertNotNull(result);
    assertEquals(2, result.size());
    assertTrue(result.contains(addressOne));
    assertTrue(result.contains(addressTwo));
}
Also used : Address(joynr.system.RoutingTypes.Address) Test(org.junit.Test)

Example 12 with Address

use of joynr.system.RoutingTypes.Address in project joynr by bmwcarit.

the class AddressManagerTest method testGetMulticastAddressGlobalVisibilityCheckThrowsException.

@Test
public void testGetMulticastAddressGlobalVisibilityCheckThrowsException() {
    createAddressManager(NO_PRIMARY_GLOBAL_TRANSPORT_SELECTED, multicastAddressCalculator);
    when(joynrMessage.getSender()).thenReturn(participantId + "/multicastname");
    when(routingTable.getIsGloballyVisible(participantId)).thenThrow(new JoynrRuntimeException());
    when(multicastAddressCalculator.createsGlobalTransportAddresses()).thenReturn(true);
    Set<Address> result = subject.getAddresses(joynrMessage);
    assertEquals(0, result.size());
}
Also used : Address(joynr.system.RoutingTypes.Address) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) Test(org.junit.Test)

Example 13 with Address

use of joynr.system.RoutingTypes.Address in project joynr by bmwcarit.

the class RoutingTableImplTest method testPutAndGet.

@Test
public void testPutAndGet() {
    Address address = new Address();
    String participantId = "participantId";
    final boolean isGloballyVisible = false;
    final long expiryDateMs = Long.MAX_VALUE;
    final boolean isSticky = false;
    final boolean allowUpdate = false;
    subject.put(participantId, address, isGloballyVisible, expiryDateMs, isSticky, allowUpdate);
    Address result = subject.get(participantId);
    assertNotNull(result);
    assertEquals(address, result);
    assertEquals(isGloballyVisible, subject.getIsGloballyVisible(participantId));
}
Also used : Address(joynr.system.RoutingTypes.Address) Test(org.junit.Test)

Example 14 with Address

use of joynr.system.RoutingTypes.Address in project joynr by bmwcarit.

the class RoutingTableImplTest method testPurge.

@Test
public void testPurge() throws Exception {
    Address address = new Address();
    String participantId = "participantId";
    String participantId2 = "participantId2";
    final boolean isGloballyVisible = false;
    final boolean allowUpdate = false;
    long expiryDateMs = System.currentTimeMillis() + 3000;
    boolean isSticky = false;
    boolean isSticky2 = true;
    subject.put(participantId, address, isGloballyVisible, expiryDateMs, isSticky, allowUpdate);
    subject.put(participantId2, address, isGloballyVisible, expiryDateMs, isSticky2, allowUpdate);
    Address result = subject.get(participantId);
    assertNotNull(result);
    assertEquals(address, result);
    assertEquals(isGloballyVisible, subject.getIsGloballyVisible(participantId));
    // entry should be still available after immediate purging
    subject.purge();
    result = subject.get(participantId);
    assertNotNull(result);
    assertEquals(address, result);
    assertEquals(isGloballyVisible, subject.getIsGloballyVisible(participantId));
    // entry should be purgable after 3000 msec
    Thread.sleep(3001);
    subject.purge();
    result = subject.get(participantId);
    assertNull(result);
    result = subject.get(participantId2);
    assertNotNull(result);
    assertEquals(address, result);
    assertEquals(isGloballyVisible, subject.getIsGloballyVisible(participantId2));
}
Also used : Address(joynr.system.RoutingTypes.Address) Test(org.junit.Test)

Example 15 with Address

use of joynr.system.RoutingTypes.Address in project joynr by bmwcarit.

the class AbstractMessageRouter method performSubscriptionOperation.

private void performSubscriptionOperation(String multicastId, String providerParticipantId, SubscriptionOperation operation) {
    Address providerAddress = routingTable.get(providerParticipantId);
    IMessagingSkeleton messagingSkeleton = messagingSkeletonFactory.getSkeleton(providerAddress);
    if (messagingSkeleton != null && messagingSkeleton instanceof IMessagingMulticastSubscriber) {
        operation.perform((IMessagingMulticastSubscriber) messagingSkeleton);
    } else {
        logger.trace("No messaging skeleton found for address {}, not performing multicast subscription.", providerAddress);
    }
}
Also used : IMessagingMulticastSubscriber(io.joynr.messaging.IMessagingMulticastSubscriber) IMessagingSkeleton(io.joynr.messaging.IMessagingSkeleton) Address(joynr.system.RoutingTypes.Address)

Aggregations

Address (joynr.system.RoutingTypes.Address)43 Test (org.junit.Test)21 ChannelAddress (joynr.system.RoutingTypes.ChannelAddress)15 MqttAddress (joynr.system.RoutingTypes.MqttAddress)13 ProviderQos (joynr.types.ProviderQos)9 Version (joynr.types.Version)9 InProcessAddress (io.joynr.messaging.inprocess.InProcessAddress)7 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)6 TypeLiteral (com.google.inject.TypeLiteral)5 GlobalDiscoveryEntry (joynr.types.GlobalDiscoveryEntry)5 AbstractModule (com.google.inject.AbstractModule)4 HashSet (java.util.HashSet)4 DiscoveryEntryWithMetaInfo (joynr.types.DiscoveryEntryWithMetaInfo)4 DiscoveryException (io.joynr.exceptions.DiscoveryException)3 AbstractMiddlewareMessagingStubFactory (io.joynr.messaging.AbstractMiddlewareMessagingStubFactory)3 IMessagingSkeleton (io.joynr.messaging.IMessagingSkeleton)3 IMessagingStub (io.joynr.messaging.IMessagingStub)3 CcMessageRouter (io.joynr.messaging.routing.CcMessageRouter)3 ArrayList (java.util.ArrayList)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2