Search in sources :

Example 1 with BaseNotificationPublisherRegistration

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);
}
Also used : StreamNameType(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType) BaseNotificationPublisherRegistration(org.opendaylight.netconf.notifications.BaseNotificationPublisherRegistration) NetconfNotificationCollector(org.opendaylight.netconf.notifications.NetconfNotificationCollector) Stream(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.Stream) Test(org.junit.Test)

Example 2 with BaseNotificationPublisherRegistration

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");
}
Also used : StreamNameType(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType) BaseNotificationPublisherRegistration(org.opendaylight.netconf.notifications.BaseNotificationPublisherRegistration) NetconfCapabilityChangeBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChangeBuilder) NetconfNotificationListener(org.opendaylight.netconf.notifications.NetconfNotificationListener) NetconfNotificationCollector(org.opendaylight.netconf.notifications.NetconfNotificationCollector) Stream(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.Stream) Test(org.junit.Test)

Example 3 with BaseNotificationPublisherRegistration

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);
}
Also used : StreamNameType(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType) BaseNotificationPublisherRegistration(org.opendaylight.netconf.notifications.BaseNotificationPublisherRegistration) NetconfCapabilityChangeBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChangeBuilder) NetconfNotificationListener(org.opendaylight.netconf.notifications.NetconfNotificationListener) NotificationListenerRegistration(org.opendaylight.netconf.notifications.NotificationListenerRegistration) NetconfCapabilityChange(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChange) NetconfNotification(org.opendaylight.netconf.notifications.NetconfNotification) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 BaseNotificationPublisherRegistration (org.opendaylight.netconf.notifications.BaseNotificationPublisherRegistration)3 StreamNameType (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType)3 NetconfNotificationCollector (org.opendaylight.netconf.notifications.NetconfNotificationCollector)2 NetconfNotificationListener (org.opendaylight.netconf.notifications.NetconfNotificationListener)2 Stream (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.Stream)2 NetconfCapabilityChangeBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChangeBuilder)2 NetconfNotification (org.opendaylight.netconf.notifications.NetconfNotification)1 NotificationListenerRegistration (org.opendaylight.netconf.notifications.NotificationListenerRegistration)1 NetconfCapabilityChange (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChange)1