Search in sources :

Example 26 with Address

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

the class RoutingTableImplTest method testContainsKeyForExistingEntry.

@Test
public void testContainsKeyForExistingEntry() {
    String participantId = "participantId";
    final boolean isGloballyVisible = false;
    final long expiryDateMs = Long.MAX_VALUE;
    final boolean isSticky = false;
    final boolean allowUpdate = false;
    subject.put(participantId, new Address(), isGloballyVisible, expiryDateMs, isSticky, allowUpdate);
    assertTrue(subject.containsKey(participantId));
}
Also used : Address(joynr.system.RoutingTypes.Address) Test(org.junit.Test)

Example 27 with Address

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

the class RoutingTableImplTest method testUpdateExpiryDateOfExistingRoutingEntry.

@Test
public void testUpdateExpiryDateOfExistingRoutingEntry() throws Exception {
    Address address = new Address();
    boolean isGloballyVisible = false;
    boolean isSticky = false;
    long expiryDateMs1 = 1;
    long expiryDateMs2 = 2;
    String participantId = "participantId";
    final boolean allowUpdate = false;
    subject.put(participantId, address, isGloballyVisible, expiryDateMs1, isSticky, allowUpdate);
    assertEquals(subject.getExpiryDateMs(participantId), expiryDateMs1);
    subject.put(participantId, address, isGloballyVisible, expiryDateMs2, isSticky, allowUpdate);
    assertEquals(subject.getExpiryDateMs(participantId), expiryDateMs2);
    // Lower expiry dates shall be ignored
    subject.put(participantId, address, isGloballyVisible, expiryDateMs1, isSticky, allowUpdate);
    assertEquals(subject.getExpiryDateMs(participantId), expiryDateMs2);
}
Also used : Address(joynr.system.RoutingTypes.Address) Test(org.junit.Test)

Example 28 with Address

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

the class RoutingTableImplTest method testGetIsGloballyVisible.

@Test
public void testGetIsGloballyVisible() {
    String participantId = "participantId";
    final boolean allowUpdate = false;
    try {
        // empty routing table
        subject.getIsGloballyVisible(participantId);
        fail("Expected exception was not thrown");
    } catch (JoynrRuntimeException e) {
    }
    Address address = new Address();
    final boolean isGloballyVisible = false;
    final long expiryDateMs = Long.MAX_VALUE;
    final boolean isSticky = false;
    subject.put(participantId, address, isGloballyVisible, expiryDateMs, isSticky, allowUpdate);
    assertEquals(false, subject.getIsGloballyVisible(participantId));
    String participantId1 = "participantId1";
    Address address1 = new Address();
    final boolean isGloballyVisible1 = false;
    final long expiryDateMs1 = Long.MAX_VALUE;
    final boolean isSticky1 = false;
    subject.put(participantId1, address1, isGloballyVisible1, expiryDateMs1, isSticky1, allowUpdate);
    assertEquals(false, subject.getIsGloballyVisible(participantId1));
    String participantId2 = "participantId2";
    Address address2 = new Address();
    final boolean isGloballyVisible2 = true;
    final long expiryDateMs2 = Long.MAX_VALUE;
    final boolean isSticky2 = false;
    subject.put(participantId2, address2, isGloballyVisible2, expiryDateMs2, isSticky2, allowUpdate);
    assertEquals(true, subject.getIsGloballyVisible(participantId2));
}
Also used : Address(joynr.system.RoutingTypes.Address) JoynrRuntimeException(io.joynr.exceptions.JoynrRuntimeException) Test(org.junit.Test)

Example 29 with Address

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

the class RoutingTableImplTest method testAllowUpdate.

public void testAllowUpdate() throws Exception {
    final boolean NO_UPDATE = false;
    final boolean DO_UPDATE = true;
    Address address1 = new Address();
    Address address2 = new Address();
    boolean isGloballyVisible = true;
    boolean isSticky = true;
    long expiryDateMs = System.currentTimeMillis();
    String participantId = "participantId";
    subject.put(participantId, address1, isGloballyVisible, expiryDateMs, isSticky, NO_UPDATE);
    assertNotNull(subject.containsKey(participantId));
    subject.put(participantId, address2, isGloballyVisible, expiryDateMs, isSticky, NO_UPDATE);
    assertEquals(address1, subject.get(participantId));
    subject.put(participantId, address2, isGloballyVisible, expiryDateMs, isSticky, DO_UPDATE);
    assertEquals(address2, subject.get(participantId));
}
Also used : Address(joynr.system.RoutingTypes.Address)

Example 30 with Address

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

the class RoutingTableImplTest method testUpdateStickFlagOfExistingRoutingEntry.

@Test
public void testUpdateStickFlagOfExistingRoutingEntry() throws Exception {
    Address address = new Address();
    boolean isGloballyVisible = false;
    boolean isNotSticky = false;
    boolean isSticky = true;
    long expiryDateMs = 0;
    String participantId = "participantId";
    final boolean allowUpdate = false;
    subject.put(participantId, address, isGloballyVisible, expiryDateMs, isNotSticky, allowUpdate);
    assertEquals(subject.getIsSticky(participantId), isNotSticky);
    subject.put(participantId, address, isGloballyVisible, expiryDateMs, isSticky, allowUpdate);
    assertEquals(subject.getIsSticky(participantId), isSticky);
    // Stick flag shall not be removed by an update.
    subject.put(participantId, address, isGloballyVisible, expiryDateMs, isNotSticky, allowUpdate);
    assertEquals(subject.getIsSticky(participantId), isSticky);
}
Also used : Address(joynr.system.RoutingTypes.Address) Test(org.junit.Test)

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