use of joynr.types.DiscoveryEntryWithMetaInfo in project joynr by bmwcarit.
the class DiscoveryEntryVersionFilterTest method testEmptySetUnchanged.
@Test
public void testEmptySetUnchanged() {
Version callerVersion = new Version(0, 0);
Set<DiscoveryEntryWithMetaInfo> discoveryEntries = new HashSet<>();
Set<DiscoveryEntryWithMetaInfo> result = subject.filter(callerVersion, discoveryEntries, null);
assertNotNull(result);
assertEquals(discoveryEntries, result);
}
use of joynr.types.DiscoveryEntryWithMetaInfo in project joynr by bmwcarit.
the class DiscoveryEntryVersionFilterTest method testIncompatibleVersionFilteredOut.
@Test
public void testIncompatibleVersionFilteredOut() {
Version callerVersion = new Version(1, 0);
DiscoveryEntryWithMetaInfo discoveryEntry = mock(DiscoveryEntryWithMetaInfo.class);
Version providerVersion = new Version(2, 0);
when(discoveryEntry.getProviderVersion()).thenReturn(providerVersion);
Set<DiscoveryEntryWithMetaInfo> discoveryEntries = Sets.newHashSet(discoveryEntry);
Set<DiscoveryEntryWithMetaInfo> result = subject.filter(callerVersion, discoveryEntries, null);
assertNotNull(result);
assertTrue(result.isEmpty());
}
use of joynr.types.DiscoveryEntryWithMetaInfo in project joynr by bmwcarit.
the class DiscoveryEntryVersionFilterTest method testCompatibleVersionLeftIn.
@Test
public void testCompatibleVersionLeftIn() {
Version callerVersion = new Version(1, 0);
DiscoveryEntryWithMetaInfo discoveryEntry = mock(DiscoveryEntryWithMetaInfo.class);
Version providerVersion = new Version(1, 0);
when(discoveryEntry.getProviderVersion()).thenReturn(providerVersion);
Set<DiscoveryEntryWithMetaInfo> discoveryEntries = Sets.newHashSet(discoveryEntry);
when(versionCompatibilityChecker.check(eq(callerVersion), eq(providerVersion))).thenReturn(true);
Set<DiscoveryEntryWithMetaInfo> result = subject.filter(callerVersion, discoveryEntries, null);
assertNotNull(result);
assertEquals(1, result.size());
assertEquals(discoveryEntries, result);
}
use of joynr.types.DiscoveryEntryWithMetaInfo in project joynr by bmwcarit.
the class SubscriptionManagerTest method testRegisterMulticastSubscription.
@SuppressWarnings("unchecked")
private void testRegisterMulticastSubscription(String subscriptionId, String... partitions) throws Exception {
Method method = TestMulticastSubscriptionInterface.class.getMethod("subscribeToMyMulticast", new Class[0]);
BroadcastSubscriptionListener listener = spy(new BroadcastSubscriptionListener() {
@Override
public void onError(SubscriptionException error) {
}
@Override
public void onSubscribed(String subscriptionId) {
}
@SuppressWarnings("unused")
public void onReceive() {
}
});
SubscriptionQos subscriptionQos = mock(MulticastSubscriptionQos.class);
Object[] args;
if (subscriptionId == null) {
args = new Object[] { listener, subscriptionQos, partitions };
} else {
args = new Object[] { subscriptionId, listener, subscriptionQos, partitions };
}
String multicastId = MulticastIdUtil.createMulticastId(toParticipantId, "myMulticast", partitions);
Set<String> subscriptionIdSet = new HashSet<>();
Pattern multicastIdPattern = Pattern.compile(multicastId);
multicastSubscribersDirectory.put(multicastIdPattern, subscriptionIdSet);
when(multicastWildcardRegexFactory.createIdPattern(multicastId)).thenReturn(multicastIdPattern);
MulticastSubscribeInvocation invocation = new MulticastSubscribeInvocation(method, args, future);
DiscoveryEntryWithMetaInfo toDiscoveryEntry = new DiscoveryEntryWithMetaInfo();
toDiscoveryEntry.setParticipantId(toParticipantId);
subscriptionManager.registerMulticastSubscription(fromParticipantId, Sets.newHashSet(toDiscoveryEntry), invocation);
verify(multicastSubscribersDirectory).put(any(Pattern.class), anySet());
assertEquals(1, subscriptionIdSet.size());
if (subscriptionId != null) {
assertEquals(subscriptionId, subscriptionIdSet.iterator().next());
}
verify(dispatcher).sendSubscriptionRequest(eq(fromParticipantId), eq(Sets.newHashSet(toDiscoveryEntry)), any(SubscriptionRequest.class), any(MessagingQos.class));
}
use of joynr.types.DiscoveryEntryWithMetaInfo in project joynr by bmwcarit.
the class SubscriptionManagerTest method setUp.
@Before
public void setUp() {
subscriptionManager = new SubscriptionManagerImpl(attributeSubscriptionDirectory, broadcastSubscriptionDirectory, multicastSubscribersDirectory, subscriptionStates, missedPublicationTimers, subscriptionEndFutures, subscriptionAttributeTypes, unicastBroadcastTypes, multicastBroadcastTypes, subscriptionFutureMap, cleanupScheduler, dispatcher, multicastWildcardRegexFactory);
subscriptionId = "testSubscription";
attributeName = "testAttribute";
attributeSubscriptionCallback = new AttributeSubscriptionAdapter<Integer>();
long minInterval_ms = 100;
long maxInterval_ms = 5000;
long subscriptionDuration = 20000;
long alertInterval_ms = 6000;
long publicationTtl_ms = 1000;
qos = new PeriodicSubscriptionQos();
qos.setPeriodMs(maxInterval_ms);
qos.setValidityMs(subscriptionDuration);
qos.setAlertAfterIntervalMs(alertInterval_ms);
qos.setPublicationTtlMs(publicationTtl_ms);
onChangeQos = new OnChangeSubscriptionQos();
onChangeQos.setMinIntervalMs(minInterval_ms);
onChangeQos.setValidityMs(subscriptionDuration);
onChangeQos.setPublicationTtlMs(publicationTtl_ms);
qosWithoutExpiryDate = new PeriodicSubscriptionQos();
qosWithoutExpiryDate.setPeriodMs(maxInterval_ms);
qosWithoutExpiryDate.setValidityMs(SubscriptionQos.IGNORE_VALUE);
qosWithoutExpiryDate.setAlertAfterIntervalMs(alertInterval_ms);
qosWithoutExpiryDate.setPublicationTtlMs(publicationTtl_ms);
missedPublicationTimer = new MissedPublicationTimer(System.currentTimeMillis() + subscriptionDuration, maxInterval_ms, alertInterval_ms, attributeSubscriptionCallback, subscriptionState, subscriptionId);
qosSettings = new MessagingQos();
fromParticipantId = "fromParticipantId";
toParticipantId = "toParticipantId";
toDiscoveryEntry = new DiscoveryEntryWithMetaInfo();
toDiscoveryEntry.setParticipantId(toParticipantId);
future = new Future<String>();
}
Aggregations