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));
}
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);
}
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));
}
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));
}
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);
}
Aggregations