use of joynr.vehicle.NavigationProxy 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.vehicle.NavigationProxy in project joynr by bmwcarit.
the class ProxyTest method createProxyUnSubscribeFromBroadcast.
@Test
public void createProxyUnSubscribeFromBroadcast() throws Exception {
NavigationProxy proxy = getNavigationProxy();
String subscriptionId = UUID.randomUUID().toString();
proxy.unsubscribeFromLocationUpdateBroadcast(subscriptionId);
verify(subscriptionManager, times(1)).unregisterSubscription(eq(fromParticipantId), eq(Sets.newHashSet(toDiscoveryEntry)), eq(subscriptionId), any(MessagingQos.class));
}
use of joynr.vehicle.NavigationProxy in project joynr by bmwcarit.
the class ProxyTest method getNavigationProxy.
private NavigationProxy getNavigationProxy() throws InterruptedException {
ProxyBuilder<NavigationProxy> proxyBuilder = getProxyBuilder(NavigationProxy.class);
proxyBuilder.setParticipantId(fromParticipantId);
NavigationProxy proxy = proxyBuilder.setMessagingQos(messagingQos).setDiscoveryQos(discoveryQos).build(navigationProxyCreatedCallback);
assertTrue(navigationProxyCreatedSemaphore.tryAcquire(1000, TimeUnit.MILLISECONDS));
return proxy;
}
use of joynr.vehicle.NavigationProxy 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