Search in sources :

Example 1 with AttributeSubscriptionListener

use of io.joynr.pubsub.subscription.AttributeSubscriptionListener in project joynr by bmwcarit.

the class ProxyTest method createProxySubscribeToAttributeWithSubscriptionId.

@Test
public void createProxySubscribeToAttributeWithSubscriptionId() 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> {
    }
    String subscriptionId = UUID.randomUUID().toString();
    Future<String> subscriptionId2 = proxy.subscribeToGuidanceActive(subscriptionId, mock(BooleanSubscriptionListener.class), subscriptionQos);
    assertEquals(subscriptionId, subscriptionId2.get());
    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, subscriptionRequest.getValue().getSubscriptionId());
}
Also used : 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)

Example 2 with AttributeSubscriptionListener

use of io.joynr.pubsub.subscription.AttributeSubscriptionListener 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

AttributeSubscribeInvocation (io.joynr.proxy.invocation.AttributeSubscribeInvocation)2 SubscriptionQos (io.joynr.pubsub.SubscriptionQos)2 AttributeSubscriptionListener (io.joynr.pubsub.subscription.AttributeSubscriptionListener)2 MulticastSubscriptionQos (joynr.MulticastSubscriptionQos)2 OnChangeSubscriptionQos (joynr.OnChangeSubscriptionQos)2 NavigationProxy (joynr.vehicle.NavigationProxy)2 Test (org.junit.Test)2 Matchers.anyString (org.mockito.Matchers.anyString)2 MessagingQos (io.joynr.messaging.MessagingQos)1