Search in sources :

Example 1 with NetconfNotification

use of org.opendaylight.netconf.notifications.NetconfNotification in project netconf by opendaylight.

the class NotificationsTransformUtilTest method testTransformFromDOM.

@Test
public void testTransformFromDOM() throws Exception {
    final NetconfNotification netconfNotification = new NetconfNotification(XmlUtil.readXmlToDocument(INNER_NOTIFICATION), DATE);
    XMLUnit.setIgnoreWhitespace(true);
    compareXml(EXPECTED_NOTIFICATION, netconfNotification.toString());
}
Also used : NetconfNotification(org.opendaylight.netconf.notifications.NetconfNotification) Test(org.junit.Test)

Example 2 with NetconfNotification

use of org.opendaylight.netconf.notifications.NetconfNotification in project netconf by opendaylight.

the class NotificationsTransformUtilTest method testTransform.

@Test
public void testTransform() throws Exception {
    final NetconfCapabilityChangeBuilder netconfCapabilityChangeBuilder = new NetconfCapabilityChangeBuilder();
    netconfCapabilityChangeBuilder.setAddedCapability(Lists.newArrayList(new Uri("uri1"), new Uri("uri1")));
    netconfCapabilityChangeBuilder.setDeletedCapability(Lists.newArrayList(new Uri("uri4"), new Uri("uri3")));
    final NetconfCapabilityChange capabilityChange = netconfCapabilityChangeBuilder.build();
    final NetconfNotification transform = UTIL.transform(capabilityChange, DATE, SchemaPath.create(true, NetconfCapabilityChange.QNAME));
    final String serialized = XmlUtil.toString(transform.getDocument());
    compareXml(EXPECTED_NOTIFICATION, serialized);
}
Also used : NetconfCapabilityChangeBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChangeBuilder) NetconfCapabilityChange(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChange) Uri(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri) NetconfNotification(org.opendaylight.netconf.notifications.NetconfNotification) Test(org.junit.Test)

Example 3 with NetconfNotification

use of org.opendaylight.netconf.notifications.NetconfNotification in project netconf by opendaylight.

the class NetconfServerSession method sendMessage.

@Override
public ChannelFuture sendMessage(final NetconfMessage netconfMessage) {
    final ChannelFuture channelFuture = super.sendMessage(netconfMessage);
    if (netconfMessage instanceof NetconfNotification) {
        outNotification++;
        sessionListener.onNotification(this, (NetconfNotification) netconfMessage);
    }
    // delayed close was set, close after the message was sent
    if (delayedClose) {
        channelFuture.addListener(future -> close());
    }
    return channelFuture;
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) NetconfNotification(org.opendaylight.netconf.notifications.NetconfNotification)

Example 4 with NetconfNotification

use of org.opendaylight.netconf.notifications.NetconfNotification in project netconf by opendaylight.

the class NetconfServerSessionListenerTest method testOnNotification.

@Test
public void testOnNotification() throws Exception {
    listener.onNotification(session, new NetconfNotification(XmlUtil.readXmlToDocument("<notification/>")));
    verify(monitoringListener).onSessionEvent(argThat(sessionEventIs(SessionEvent.Type.NOTIFICATION)));
}
Also used : NetconfNotification(org.opendaylight.netconf.notifications.NetconfNotification) Test(org.junit.Test)

Example 5 with NetconfNotification

use of org.opendaylight.netconf.notifications.NetconfNotification in project netconf by opendaylight.

the class NetconfServerSessionTest method testSendNotification.

@Test
public void testSendNotification() throws Exception {
    doNothing().when(listener).onNotification(any(), any());
    final Document msgDoc = XmlUtil.readXmlToDocument("<notification></notification>");
    final NetconfNotification notif = new NetconfNotification(msgDoc);
    session.sendMessage(notif);
    channel.runPendingTasks();
    final Object o = channel.readOutbound();
    assertEquals(notif, o);
    verify(listener).onNotification(session, notif);
}
Also used : Document(org.w3c.dom.Document) NetconfNotification(org.opendaylight.netconf.notifications.NetconfNotification) Test(org.junit.Test)

Aggregations

NetconfNotification (org.opendaylight.netconf.notifications.NetconfNotification)7 Test (org.junit.Test)5 Document (org.w3c.dom.Document)2 ChannelFuture (io.netty.channel.ChannelFuture)1 IOException (java.io.IOException)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 DOMResult (javax.xml.transform.dom.DOMResult)1 NetconfNotificationListener (org.opendaylight.netconf.notifications.NetconfNotificationListener)1 StreamNameType (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType)1 Stream (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.Stream)1 StreamBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.StreamBuilder)1 Uri (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri)1 NetconfCapabilityChange (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChange)1 NetconfCapabilityChangeBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChangeBuilder)1 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)1