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