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();
}
Aggregations