Search in sources :

Example 1 with LocationUpdateWithSpeedBroadcastAdapter

use of joynr.tests.testBroadcastInterface.LocationUpdateWithSpeedBroadcastAdapter 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)

Aggregations

Semaphore (java.util.concurrent.Semaphore)1 MulticastSubscriptionQos (joynr.MulticastSubscriptionQos)1 LocationUpdateWithSpeedBroadcastAdapter (joynr.tests.testBroadcastInterface.LocationUpdateWithSpeedBroadcastAdapter)1 joynr.tests.testProxy (joynr.tests.testProxy)1 GpsLocation (joynr.types.Localisation.GpsLocation)1 Test (org.junit.Test)1