use of org.opendaylight.netconf.notifications.BaseNotificationPublisherRegistration in project netconf by opendaylight.
the class NetconfNotificationManagerTest method testStreamListeners.
@Test
public void testStreamListeners() throws Exception {
final NetconfNotificationManager netconfNotificationManager = createManager();
final NetconfNotificationCollector.NetconfNotificationStreamListener streamListener = mock(NetconfNotificationCollector.NetconfNotificationStreamListener.class);
doNothing().when(streamListener).onStreamRegistered(any(Stream.class));
doNothing().when(streamListener).onStreamUnregistered(any(StreamNameType.class));
netconfNotificationManager.registerStreamListener(streamListener);
final BaseNotificationPublisherRegistration baseNotificationPublisherRegistration = netconfNotificationManager.registerBaseNotificationPublisher();
verify(streamListener).onStreamRegistered(NetconfNotificationManager.BASE_NETCONF_STREAM);
baseNotificationPublisherRegistration.close();
verify(streamListener).onStreamUnregistered(NetconfNotificationManager.BASE_STREAM_NAME);
}
use of org.opendaylight.netconf.notifications.BaseNotificationPublisherRegistration in project netconf by opendaylight.
the class NetconfNotificationManagerTest method testClose.
@Test
public void testClose() throws Exception {
final NetconfNotificationManager netconfNotificationManager = createManager();
final BaseNotificationPublisherRegistration baseNotificationPublisherRegistration = netconfNotificationManager.registerBaseNotificationPublisher();
final NetconfNotificationListener listener = mock(NetconfNotificationListener.class);
netconfNotificationManager.registerNotificationListener(NetconfNotificationManager.BASE_NETCONF_STREAM.getName(), listener);
final NetconfNotificationCollector.NetconfNotificationStreamListener streamListener = mock(NetconfNotificationCollector.NetconfNotificationStreamListener.class);
doNothing().when(streamListener).onStreamUnregistered(any(StreamNameType.class));
doNothing().when(streamListener).onStreamRegistered(any(Stream.class));
netconfNotificationManager.registerStreamListener(streamListener);
verify(streamListener).onStreamRegistered(NetconfNotificationManager.BASE_NETCONF_STREAM);
netconfNotificationManager.close();
verify(streamListener).onStreamUnregistered(NetconfNotificationManager.BASE_NETCONF_STREAM.getName());
try {
baseNotificationPublisherRegistration.onCapabilityChanged(new NetconfCapabilityChangeBuilder().build());
} catch (final IllegalStateException e) {
// Exception should be thrown after manager is closed
return;
}
fail("Publishing into a closed manager should fail");
}
use of org.opendaylight.netconf.notifications.BaseNotificationPublisherRegistration in project netconf by opendaylight.
the class NetconfNotificationManagerTest method testNotificationListeners.
@Test
public void testNotificationListeners() throws Exception {
final NetconfNotificationManager netconfNotificationManager = createManager();
final BaseNotificationPublisherRegistration baseNotificationPublisherRegistration = netconfNotificationManager.registerBaseNotificationPublisher();
final NetconfCapabilityChangeBuilder capabilityChangedBuilder = new NetconfCapabilityChangeBuilder();
final NetconfNotificationListener listener = mock(NetconfNotificationListener.class);
doNothing().when(listener).onNotification(any(StreamNameType.class), any(NetconfNotification.class));
final NotificationListenerRegistration notificationListenerRegistration = netconfNotificationManager.registerNotificationListener(NetconfNotificationManager.BASE_NETCONF_STREAM.getName(), listener);
final NetconfCapabilityChange notification = capabilityChangedBuilder.build();
baseNotificationPublisherRegistration.onCapabilityChanged(notification);
verify(listener).onNotification(any(StreamNameType.class), any(NetconfNotification.class));
notificationListenerRegistration.close();
baseNotificationPublisherRegistration.onCapabilityChanged(notification);
verifyNoMoreInteractions(listener);
}
Aggregations