use of joynr.OnChangeSubscriptionQos in project joynr by bmwcarit.
the class AbstractSubscriptionEnd2EndTest method testExpiredOnChangeSubscription.
@Ignore
@Test
public void testExpiredOnChangeSubscription() throws InterruptedException, ApplicationException {
Semaphore onReceiveSemaphore = new Semaphore(0);
AttributeSubscriptionListener<Integer> integerListener = prepareOnReceiveListenerMock(onReceiveSemaphore);
// Only get onChange messages
long minInterval_ms = 0;
// Expire quickly
long duration = 500;
OnChangeSubscriptionQos subscriptionQos = new OnChangeSubscriptionQos();
subscriptionQos.setMinIntervalMs(minInterval_ms);
subscriptionQos.setValidityMs(duration);
subscriptionQos.setPublicationTtlMs(10000);
Future<String> subscriptionId = proxy.subscribeToTestAttribute(integerListener, subscriptionQos);
getSubscriptionTestsPublisher().waitForAttributeSubscription("testAttribute");
// There should have only been one call - the automatic publication when a subscription is made
assertTrue(onReceiveSemaphore.tryAcquire(1000, TimeUnit.MILLISECONDS));
verifyNoMoreInteractions(integerListener);
Thread.sleep(duration + EXPECTED_LATENCY_MS);
// We should now have an expired onChange subscription
provider.setTestAttribute(5);
assertFalse(onReceiveSemaphore.tryAcquire(100, TimeUnit.MILLISECONDS));
proxy.unsubscribeFromTestAttribute(subscriptionId.get(FUTURE_SUBSCRIPTION_ID_TIMEOUTMS));
getSubscriptionTestsPublisher().waitForAttributeUnsubscription("testAttribute");
}
use of joynr.OnChangeSubscriptionQos in project joynr by bmwcarit.
the class ConnectorTest method subscribeToBroadcastCallCallsSubscriptionManagerWithCorrectArguments.
@Test
public void subscribeToBroadcastCallCallsSubscriptionManagerWithCorrectArguments() {
TestBroadcastListener listener = new TestBroadcastInterface.TestBroadcastAdapter();
OnChangeSubscriptionQos subscriptionQos = new OnChangeSubscriptionQos();
ConnectorInvocationHandler connector = createConnector();
assertNotNull(connector);
try {
Method method = TestBroadcastInterface.class.getDeclaredMethod("subscribeToTestBroadcast", TestBroadcastListener.class, OnChangeSubscriptionQos.class, BroadcastFilterParameters.class);
BroadcastSubscribeInvocation invocation = new BroadcastSubscribeInvocation(method, new Object[] { listener, subscriptionQos, new BroadcastFilterParameters() }, null);
connector.executeSubscriptionMethod(invocation);
verify(subscriptionManager, times(1)).registerBroadcastSubscription(fromParticipantId, toDiscoveryEntries, invocation);
} catch (Exception e) {
fail("Unexpected exception from broadcast subscribe call: " + e);
}
}
use of joynr.OnChangeSubscriptionQos in project joynr by bmwcarit.
the class ConnectorTest method subscribeToAttributeCallCallsSubscriptionManagerWithCorrectArguments.
@Test
public void subscribeToAttributeCallCallsSubscriptionManagerWithCorrectArguments() {
AttributeSubscriptionListener<String> listener = new AttributeSubscriptionAdapter<>();
SubscriptionQos subscriptionQos = new OnChangeSubscriptionQos();
ConnectorInvocationHandler connector = createConnector();
assertNotNull(connector);
try {
Method method = TestSubscriptionInterface.class.getDeclaredMethod("subscribeToTestAttribute", AttributeSubscriptionListener.class, SubscriptionQos.class);
AttributeSubscribeInvocation invocation = new AttributeSubscribeInvocation(method, new Object[] { listener, subscriptionQos }, null);
connector.executeSubscriptionMethod(invocation);
verify(subscriptionManager, times(1)).registerAttributeSubscription(fromParticipantId, toDiscoveryEntries, invocation);
} catch (Exception e) {
fail("Unexpected exception from attribute subscribe call: " + e);
}
}
use of joynr.OnChangeSubscriptionQos in project joynr by bmwcarit.
the class ProxyTest method createProxySubscribeAndUnsubscribeFromSelectiveBroadcast.
@Test
public void createProxySubscribeAndUnsubscribeFromSelectiveBroadcast() throws Exception {
NavigationProxy proxy = getNavigationProxy();
long minInterval_ms = 0;
long expiryDate = System.currentTimeMillis() + 30000;
long publicationTtl_ms = 5000;
OnChangeSubscriptionQos subscriptionQos = new OnChangeSubscriptionQos().setMinIntervalMs(minInterval_ms).setExpiryDateMs(expiryDate).setPublicationTtlMs(publicationTtl_ms);
LocationUpdateSelectiveBroadcastFilterParameters filterParameter = new LocationUpdateSelectiveBroadcastFilterParameters();
Future<String> subscriptionId = proxy.subscribeToLocationUpdateSelectiveBroadcast(mock(LocationUpdateSelectiveBroadcastListener.class), subscriptionQos, filterParameter);
ArgumentCaptor<BroadcastSubscribeInvocation> subscriptionRequest = ArgumentCaptor.forClass(BroadcastSubscribeInvocation.class);
verify(subscriptionManager, times(1)).registerBroadcastSubscription(eq(fromParticipantId), eq(Sets.newHashSet(toDiscoveryEntry)), subscriptionRequest.capture());
assertEquals("locationUpdateSelective", subscriptionRequest.getValue().getBroadcastName());
// now, let's remove the previous subscriptionRequest
proxy.unsubscribeFromGuidanceActive(subscriptionId.get(100L));
verify(subscriptionManager, times(1)).unregisterSubscription(eq(fromParticipantId), eq(Sets.newHashSet(toDiscoveryEntry)), eq(subscriptionId.get()), any(MessagingQos.class));
}
use of joynr.OnChangeSubscriptionQos in project joynr by bmwcarit.
the class ProxyTest method createProxySubscribeAndUnsubscribeFromAttribute.
@Test
public void createProxySubscribeAndUnsubscribeFromAttribute() throws Exception {
NavigationProxy proxy = getNavigationProxy();
long minInterval_ms = 0;
long expiryDate = System.currentTimeMillis() + 30000;
long publicationTtl_ms = 5000;
SubscriptionQos subscriptionQos = new OnChangeSubscriptionQos().setMinIntervalMs(minInterval_ms).setExpiryDateMs(expiryDate).setPublicationTtlMs(publicationTtl_ms);
abstract class BooleanSubscriptionListener implements AttributeSubscriptionListener<Boolean> {
}
Future<String> subscriptionId = proxy.subscribeToGuidanceActive(mock(BooleanSubscriptionListener.class), subscriptionQos);
ArgumentCaptor<AttributeSubscribeInvocation> subscriptionRequest = ArgumentCaptor.forClass(AttributeSubscribeInvocation.class);
verify(subscriptionManager, times(1)).registerAttributeSubscription(eq(fromParticipantId), eq(Sets.newHashSet(toDiscoveryEntry)), subscriptionRequest.capture());
assertEquals("guidanceActive", subscriptionRequest.getValue().getAttributeName());
assertEquals(subscriptionId.get(), subscriptionRequest.getValue().getSubscriptionId());
// now, let's remove the previous subscriptionRequest
proxy.unsubscribeFromGuidanceActive(subscriptionId.get());
verify(subscriptionManager, times(1)).unregisterSubscription(eq(fromParticipantId), eq(Sets.newHashSet(toDiscoveryEntry)), eq(subscriptionId.get()), any(MessagingQos.class));
}
Aggregations