Search in sources :

Example 6 with MulticastSubscriptionQos

use of joynr.MulticastSubscriptionQos in project joynr by bmwcarit.

the class ProxyTest method createProxySubscribeAndUnsubscribeFromBroadcast.

@Test
public void createProxySubscribeAndUnsubscribeFromBroadcast() throws Exception {
    NavigationProxy proxy = getNavigationProxy();
    long expiryDate = System.currentTimeMillis() + 30000;
    MulticastSubscriptionQos subscriptionQos = new MulticastSubscriptionQos().setExpiryDateMs(expiryDate);
    Future<String> subscriptionId = proxy.subscribeToLocationUpdateBroadcast(mock(LocationUpdateBroadcastListener.class), subscriptionQos);
    ArgumentCaptor<MulticastSubscribeInvocation> subscriptionRequest = ArgumentCaptor.forClass(MulticastSubscribeInvocation.class);
    verify(subscriptionManager, times(1)).registerMulticastSubscription(eq(fromParticipantId), eq(Sets.newHashSet(toDiscoveryEntry)), subscriptionRequest.capture());
    assertEquals("locationUpdate", subscriptionRequest.getValue().getSubscriptionName());
    // 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) MulticastSubscribeInvocation(io.joynr.proxy.invocation.MulticastSubscribeInvocation) NavigationProxy(joynr.vehicle.NavigationProxy) Matchers.anyString(org.mockito.Matchers.anyString) LocationUpdateBroadcastListener(joynr.vehicle.NavigationBroadcastInterface.LocationUpdateBroadcastListener) MulticastSubscriptionQos(joynr.MulticastSubscriptionQos) Test(org.junit.Test)

Example 7 with MulticastSubscriptionQos

use of joynr.MulticastSubscriptionQos in project joynr by bmwcarit.

the class AbstractProviderProxyEnd2EndTest method testBroadcastWithMapParameter.

@Ignore
@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void testBroadcastWithMapParameter() throws DiscoveryException, JoynrIllegalStateException, InterruptedException {
    final Semaphore broadcastReceived = new Semaphore(0);
    ProxyBuilder<testProxy> proxyBuilder = consumerRuntime.getProxyBuilder(domain, testProxy.class);
    testProxy proxy = proxyBuilder.setMessagingQos(messagingQos).setDiscoveryQos(discoveryQos).build();
    final TStringKeyMap mapParam = new TStringKeyMap();
    mapParam.put("key", "value");
    proxy.subscribeToBroadcastWithMapParametersBroadcast(new BroadcastWithMapParametersBroadcastAdapter() {

        @Override
        public void onReceive(TStringKeyMap receivedMapParam) {
            assertEquals(mapParam, receivedMapParam);
            broadcastReceived.release();
        }
    }, new MulticastSubscriptionQos());
    // wait to allow the subscription request to arrive at the provider
    getSubscriptionTestsPublisher().waitForBroadcastSubscription();
    provider.fireBroadcastWithMapParameters(mapParam);
    broadcastReceived.acquire();
}
Also used : TStringKeyMap(joynr.types.TestTypes.TStringKeyMap) BroadcastWithMapParametersBroadcastAdapter(joynr.tests.testBroadcastInterface.BroadcastWithMapParametersBroadcastAdapter) joynr.tests.testProxy(joynr.tests.testProxy) Semaphore(java.util.concurrent.Semaphore) MulticastSubscriptionQos(joynr.MulticastSubscriptionQos) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 8 with MulticastSubscriptionQos

use of joynr.MulticastSubscriptionQos in project joynr by bmwcarit.

the class AbstractProviderProxyEnd2EndTest method testSimpleBroadcast.

@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void testSimpleBroadcast() throws InterruptedException, JoynrWaitExpiredException, JoynrRuntimeException, ApplicationException {
    final Semaphore broadcastReceived = new Semaphore(0);
    final GpsLocation gpsLocation = new GpsLocation(1.0, 2.0, 3.0, GpsFixEnum.MODE3D, 4.0, 5.0, 6.0, 7.0, 8L, 9L, 10);
    final Float currentSpeed = Float.MAX_VALUE;
    ProxyBuilder<testProxy> proxyBuilder = consumerRuntime.getProxyBuilder(domain, testProxy.class);
    testProxy proxy = proxyBuilder.setMessagingQos(messagingQos).setDiscoveryQos(discoveryQos).build();
    Future<String> subscriptionIdFuture = proxy.subscribeToLocationUpdateWithSpeedBroadcast(new LocationUpdateWithSpeedBroadcastAdapter() {

        @Override
        public void onReceive(GpsLocation receivedGpsLocation, Float receivedCurrentSpeed) {
            assertEquals(gpsLocation, receivedGpsLocation);
            assertEquals(currentSpeed, receivedCurrentSpeed);
            broadcastReceived.release();
        }
    }, new MulticastSubscriptionQos());
    // wait to allow the subscription request to arrive at the provider
    subscriptionIdFuture.get();
    provider.fireLocationUpdateWithSpeed(gpsLocation, currentSpeed);
    broadcastReceived.acquire();
}
Also used : joynr.tests.testProxy(joynr.tests.testProxy) GpsLocation(joynr.types.Localisation.GpsLocation) Semaphore(java.util.concurrent.Semaphore) LocationUpdateWithSpeedBroadcastAdapter(joynr.tests.testBroadcastInterface.LocationUpdateWithSpeedBroadcastAdapter) MulticastSubscriptionQos(joynr.MulticastSubscriptionQos) Test(org.junit.Test)

Example 9 with MulticastSubscriptionQos

use of joynr.MulticastSubscriptionQos in project joynr by bmwcarit.

the class AbstractBroadcastEnd2EndTest method subscribeToBroadcastOneOutput.

@Ignore
@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void subscribeToBroadcastOneOutput() throws InterruptedException {
    final Semaphore broadcastReceived = new Semaphore(0);
    proxy.subscribeToLocationUpdateBroadcast(new testBroadcastInterface.LocationUpdateBroadcastAdapter() {

        @Override
        public void onReceive(GpsLocation location) {
            assertEquals(expectedLocation, location);
            broadcastReceived.release();
        }
    }, new MulticastSubscriptionQos());
    Thread.sleep(300);
    provider.fireLocationUpdate(expectedLocation);
    broadcastReceived.acquire();
}
Also used : GpsLocation(joynr.types.Localisation.GpsLocation) Semaphore(java.util.concurrent.Semaphore) joynr.tests.testBroadcastInterface(joynr.tests.testBroadcastInterface) MulticastSubscriptionQos(joynr.MulticastSubscriptionQos) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 10 with MulticastSubscriptionQos

use of joynr.MulticastSubscriptionQos in project joynr by bmwcarit.

the class AbstractBroadcastEnd2EndTest method subscribeToBroadcastWithByteBufferOutput.

@Ignore
@Test(timeout = CONST_DEFAULT_TEST_TIMEOUT)
public void subscribeToBroadcastWithByteBufferOutput() throws InterruptedException {
    final Semaphore broadcastReceived = new Semaphore(0);
    final Byte[] expectedByteBuffer = { 1, 2, 3 };
    proxy.subscribeToBroadcastWithByteBufferParameterBroadcast(new testBroadcastInterface.BroadcastWithByteBufferParameterBroadcastAdapter() {

        @Override
        public void onError(SubscriptionException error) {
            fail("Error subscribing to broadcast");
        }

        @Override
        public void onReceive(Byte[] byteBufferParameter) {
            assertArrayEquals(expectedByteBuffer, byteBufferParameter);
            broadcastReceived.release();
        }
    }, new MulticastSubscriptionQos());
    Thread.sleep(300);
    provider.fireBroadcastWithByteBufferParameter(expectedByteBuffer);
    broadcastReceived.acquire();
}
Also used : SubscriptionException(io.joynr.exceptions.SubscriptionException) Semaphore(java.util.concurrent.Semaphore) joynr.tests.testBroadcastInterface(joynr.tests.testBroadcastInterface) MulticastSubscriptionQos(joynr.MulticastSubscriptionQos) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

MulticastSubscriptionQos (joynr.MulticastSubscriptionQos)22 Test (org.junit.Test)19 Semaphore (java.util.concurrent.Semaphore)15 joynr.tests.testBroadcastInterface (joynr.tests.testBroadcastInterface)11 joynr.tests.testProxy (joynr.tests.testProxy)7 Ignore (org.junit.Ignore)7 SubscriptionException (io.joynr.exceptions.SubscriptionException)5 ArrayList (java.util.ArrayList)4 GpsLocation (joynr.types.Localisation.GpsLocation)4 MulticastSubscribeInvocation (io.joynr.proxy.invocation.MulticastSubscribeInvocation)3 LocationUpdateBroadcastListener (joynr.vehicle.NavigationBroadcastInterface.LocationUpdateBroadcastListener)3 NavigationProxy (joynr.vehicle.NavigationProxy)3 JoynrRuntimeException (io.joynr.exceptions.JoynrRuntimeException)2 MessagingQos (io.joynr.messaging.MessagingQos)2 ApplicationException (joynr.exceptions.ApplicationException)2 Matchers.anyString (org.mockito.Matchers.anyString)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 SuppressWarnings (edu.umd.cs.findbugs.annotations.SuppressWarnings)1 LdacDomainRoleEntryChangedBroadcastListener (io.joynr.accesscontrol.broadcastlistener.LdacDomainRoleEntryChangedBroadcastListener)1 LdacMasterAccessControlEntryChangedBroadcastListener (io.joynr.accesscontrol.broadcastlistener.LdacMasterAccessControlEntryChangedBroadcastListener)1