use of io.joynr.pubsub.publication.BroadcastListener in project joynr by bmwcarit.
the class PublicationManagerImpl method handleBroadcastSubscriptionRequest.
private void handleBroadcastSubscriptionRequest(String proxyParticipantId, String providerParticipantId, BroadcastSubscriptionRequest subscriptionRequest, ProviderContainer providerContainer) {
logger.trace("adding broadcast publication: {}", subscriptionRequest);
BroadcastListener broadcastListener = new BroadcastListenerImpl(subscriptionRequest.getSubscriptionId(), this);
String broadcastName = subscriptionRequest.getSubscribedToName();
providerContainer.getSubscriptionPublisher().registerBroadcastListener(broadcastName, broadcastListener);
unregisterBroadcastListeners.put(subscriptionRequest.getSubscriptionId(), new UnregisterBroadcastListener(providerContainer.getSubscriptionPublisher(), broadcastName, broadcastListener));
final String subscriptionId = subscriptionRequest.getSubscriptionId();
SubscriptionQos subscriptionQos = subscriptionRequest.getQos();
MessagingQos messagingQos = createMessagingQos(subscriptionQos);
SubscriptionReply subscriptionReply = new SubscriptionReply(subscriptionId);
dispatcher.sendSubscriptionReply(providerParticipantId, proxyParticipantId, subscriptionReply, messagingQos);
}
use of io.joynr.pubsub.publication.BroadcastListener in project joynr by bmwcarit.
the class SubscriptionPublisherTest method unregisteredBroadcastListenerNotCalledOnBroadcast.
@Test
public void unregisteredBroadcastListenerNotCalledOnBroadcast() throws Exception {
String broadcastName = "mybroadcast";
String value1 = "value1";
String value2 = "value2";
MySubscriptionPublisher subscriptionPublisher = new MySubscriptionPublisher();
BroadcastListener broadcastListener = mock(BroadcastListener.class);
subscriptionPublisher.registerBroadcastListener(broadcastName, broadcastListener);
subscriptionPublisher.unregisterBroadcastListener(broadcastName, broadcastListener);
List<BroadcastFilter> broadcastFilters = new ArrayList<BroadcastFilter>();
BroadcastFilter broadcastFilter = mock(BroadcastFilter.class);
broadcastFilters.add(broadcastFilter);
subscriptionPublisher.fireBroadcast(broadcastName, broadcastFilters, value1, value2);
verify(broadcastListener, never()).broadcastOccurred(eq(broadcastFilters), eq(value1), eq(value2));
}
use of io.joynr.pubsub.publication.BroadcastListener in project joynr by bmwcarit.
the class SubscriptionPublisherTest method registeredBroadcastListenerIsCalledOnBroadcast.
@Test
public void registeredBroadcastListenerIsCalledOnBroadcast() throws Exception {
String broadcastName = "mybroadcast";
String value1 = "value1";
String value2 = "value2";
MySubscriptionPublisher subscriptionPublisher = new MySubscriptionPublisher();
BroadcastListener broadcastListener = mock(BroadcastListener.class);
subscriptionPublisher.registerBroadcastListener(broadcastName, broadcastListener);
List<BroadcastFilter> broadcastFilters = new ArrayList<BroadcastFilter>();
BroadcastFilter broadcastFilter = mock(BroadcastFilter.class);
broadcastFilters.add(broadcastFilter);
subscriptionPublisher.fireBroadcast(broadcastName, broadcastFilters, value1, value2);
verify(broadcastListener).broadcastOccurred(eq(broadcastFilters), eq(value1), eq(value2));
}
Aggregations