use of org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListener in project mdsal by opendaylight.
the class DOMNotificationRouter method notifyListenerTypesChanged.
@SuppressWarnings("checkstyle:IllegalCatch")
private void notifyListenerTypesChanged(final Set<Absolute> typesAfter) {
final List<? extends DOMNotificationSubscriptionListener> listenersAfter = subscriptionListeners.streamListeners().collect(ImmutableList.toImmutableList());
executor.execute(() -> {
for (final DOMNotificationSubscriptionListener subListener : listenersAfter) {
try {
subListener.onSubscriptionChanged(typesAfter);
} catch (final Exception e) {
LOG.warn("Uncaught exception during invoking listener {}", subListener, e);
}
}
});
}
use of org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListener in project mdsal by opendaylight.
the class DOMNotificationRouterTest method complexTest.
@SuppressWarnings("checkstyle:IllegalCatch")
@Test
public void complexTest() throws Exception {
final DOMNotificationSubscriptionListener domNotificationSubscriptionListener = mock(DOMNotificationSubscriptionListener.class);
doNothing().when(domNotificationSubscriptionListener).onSubscriptionChanged(any());
final CountDownLatch latch = new CountDownLatch(1);
final DOMNotificationListener domNotificationListener = new TestListener(latch);
final DOMNotificationRouter domNotificationRouter = DOMNotificationRouter.create(1024);
Multimap<Absolute, ?> listeners = domNotificationRouter.listeners();
assertTrue(listeners.isEmpty());
assertNotNull(domNotificationRouter.registerNotificationListener(domNotificationListener, Absolute.of(TestModel.TEST_QNAME)));
assertNotNull(domNotificationRouter.registerNotificationListener(domNotificationListener, Absolute.of(TestModel.TEST2_QNAME)));
listeners = domNotificationRouter.listeners();
assertFalse(listeners.isEmpty());
ListenerRegistry<DOMNotificationSubscriptionListener> subscriptionListeners = domNotificationRouter.subscriptionListeners();
assertEquals(0, subscriptionListeners.streamListeners().count());
assertNotNull(domNotificationRouter.registerSubscriptionListener(domNotificationSubscriptionListener));
subscriptionListeners = domNotificationRouter.subscriptionListeners();
assertSame(domNotificationSubscriptionListener, subscriptionListeners.streamListeners().findAny().orElseThrow());
final DOMNotification domNotification = mock(DOMNotification.class);
doReturn("test").when(domNotification).toString();
doReturn(Absolute.of(TestModel.TEST_QNAME)).when(domNotification).getType();
doReturn(TEST_CHILD).when(domNotification).getBody();
assertNotNull(domNotificationRouter.offerNotification(domNotification));
try {
assertNotNull(domNotificationRouter.offerNotification(domNotification, 1, TimeUnit.SECONDS));
assertNotNull(domNotificationRouter.offerNotification(domNotification, 1, TimeUnit.SECONDS));
} catch (Exception e) {
// FIXME: what is the point here?!
assertTrue(e instanceof UnsupportedOperationException);
}
assertNotNull(domNotificationRouter.putNotification(domNotification));
}
Aggregations