Search in sources :

Example 6 with NavigationProxy

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));
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) BroadcastSubscribeInvocation(io.joynr.proxy.invocation.BroadcastSubscribeInvocation) OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) LocationUpdateSelectiveBroadcastListener(joynr.vehicle.NavigationBroadcastInterface.LocationUpdateSelectiveBroadcastListener) NavigationProxy(joynr.vehicle.NavigationProxy) LocationUpdateSelectiveBroadcastFilterParameters(joynr.vehicle.NavigationBroadcastInterface.LocationUpdateSelectiveBroadcastFilterParameters) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 7 with NavigationProxy

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));
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) NavigationProxy(joynr.vehicle.NavigationProxy) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 8 with NavigationProxy

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;
}
Also used : NavigationProxy(joynr.vehicle.NavigationProxy)

Example 9 with NavigationProxy

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));
}
Also used : MessagingQos(io.joynr.messaging.MessagingQos) OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) OnChangeSubscriptionQos(joynr.OnChangeSubscriptionQos) MulticastSubscriptionQos(joynr.MulticastSubscriptionQos) SubscriptionQos(io.joynr.pubsub.SubscriptionQos) NavigationProxy(joynr.vehicle.NavigationProxy) Matchers.anyString(org.mockito.Matchers.anyString) AttributeSubscribeInvocation(io.joynr.proxy.invocation.AttributeSubscribeInvocation) AttributeSubscriptionListener(io.joynr.pubsub.subscription.AttributeSubscriptionListener) Test(org.junit.Test)

Aggregations

NavigationProxy (joynr.vehicle.NavigationProxy)9 Test (org.junit.Test)7 Matchers.anyString (org.mockito.Matchers.anyString)7 MessagingQos (io.joynr.messaging.MessagingQos)5 MulticastSubscriptionQos (joynr.MulticastSubscriptionQos)5 MulticastSubscribeInvocation (io.joynr.proxy.invocation.MulticastSubscribeInvocation)4 AttributeSubscribeInvocation (io.joynr.proxy.invocation.AttributeSubscribeInvocation)3 OnChangeSubscriptionQos (joynr.OnChangeSubscriptionQos)3 LocationUpdateBroadcastListener (joynr.vehicle.NavigationBroadcastInterface.LocationUpdateBroadcastListener)3 BroadcastSubscribeInvocation (io.joynr.proxy.invocation.BroadcastSubscribeInvocation)2 SubscriptionQos (io.joynr.pubsub.SubscriptionQos)2 AttributeSubscriptionListener (io.joynr.pubsub.subscription.AttributeSubscriptionListener)2 AbstractModule (com.google.inject.AbstractModule)1 Injector (com.google.inject.Injector)1 Provides (com.google.inject.Provides)1 Singleton (com.google.inject.Singleton)1 FactoryModuleBuilder (com.google.inject.assistedinject.FactoryModuleBuilder)1 Named (com.google.inject.name.Named)1 JoynrVersion (io.joynr.JoynrVersion)1 DiscoveryQos (io.joynr.arbitration.DiscoveryQos)1