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