Search in sources :

Example 66 with NetconfMessage

use of org.opendaylight.netconf.api.NetconfMessage in project netconf by opendaylight.

the class NetconfDataTreeServiceImplTest method merge.

@Test
public void merge() {
    netconService.merge(LogicalDatastoreType.CONFIGURATION, TxTestUtils.getLeafId(), TxTestUtils.getLeafNode(), Optional.empty());
    verify(rpcService).invokeRpc(eq(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME), captor.capture());
    final NetconfMessage netconfMessage = netconfMessageTransformer.toRpcRequest(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME, captor.getValue());
    Assert.assertTrue(netconfMessage.toString().contains("operation=\"merge\""));
}
Also used : NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) AbstractTestModelTest(org.opendaylight.netconf.sal.connect.netconf.AbstractTestModelTest) Test(org.junit.Test)

Example 67 with NetconfMessage

use of org.opendaylight.netconf.api.NetconfMessage in project netconf by opendaylight.

the class NetconfDataTreeServiceImplTest method replace.

@Test
public void replace() {
    netconService.replace(LogicalDatastoreType.CONFIGURATION, TxTestUtils.getLeafId(), TxTestUtils.getLeafNode(), Optional.empty());
    verify(rpcService).invokeRpc(eq(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME), captor.capture());
    final NetconfMessage netconfMessage = netconfMessageTransformer.toRpcRequest(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME, captor.getValue());
    Assert.assertTrue(netconfMessage.toString().contains("operation=\"replace\""));
}
Also used : NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) AbstractTestModelTest(org.opendaylight.netconf.sal.connect.netconf.AbstractTestModelTest) Test(org.junit.Test)

Example 68 with NetconfMessage

use of org.opendaylight.netconf.api.NetconfMessage in project netconf by opendaylight.

the class NetconfDataTreeServiceImplTest method delete.

@Test
public void delete() {
    netconService.delete(LogicalDatastoreType.CONFIGURATION, TxTestUtils.getLeafId().getParent());
    verify(rpcService).invokeRpc(eq(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME), captor.capture());
    final NetconfMessage netconfMessage = netconfMessageTransformer.toRpcRequest(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME, captor.getValue());
    Assert.assertTrue(netconfMessage.toString().contains("operation=\"delete\""));
}
Also used : NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) AbstractTestModelTest(org.opendaylight.netconf.sal.connect.netconf.AbstractTestModelTest) Test(org.junit.Test)

Example 69 with NetconfMessage

use of org.opendaylight.netconf.api.NetconfMessage in project netconf by opendaylight.

the class NetconfDataTreeServiceImplTest method create.

@Test
public void create() {
    netconService.create(LogicalDatastoreType.CONFIGURATION, TxTestUtils.getLeafId(), TxTestUtils.getLeafNode(), Optional.empty());
    verify(rpcService).invokeRpc(eq(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME), captor.capture());
    final NetconfMessage netconfMessage = netconfMessageTransformer.toRpcRequest(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME, captor.getValue());
    Assert.assertTrue(netconfMessage.toString().contains("operation=\"create\""));
}
Also used : NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) AbstractTestModelTest(org.opendaylight.netconf.sal.connect.netconf.AbstractTestModelTest) Test(org.junit.Test)

Example 70 with NetconfMessage

use of org.opendaylight.netconf.api.NetconfMessage in project lighty-netconf-simulator by PANTHEONtech.

the class ToasterDeviceTest method toasterNotificationTest.

@Test
public void toasterNotificationTest() throws ExecutionException, InterruptedException, URISyntaxException, SAXException, TimeoutException, IOException {
    final CountDownLatch notificationReceivedLatch = new CountDownLatch(1);
    final NotificationNetconfSessionListener sessionListenerNotification = new NotificationNetconfSessionListener(notificationReceivedLatch);
    final SimpleNetconfClientSessionListener sessionListenerSimple = new SimpleNetconfClientSessionListener();
    try (NetconfClientSession sessionNotification = dispatcher.createClient(createSHHConfig(sessionListenerNotification)).get(TimeoutUtil.TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
        NetconfClientSession sessionSimple = dispatcher.createClient(createSHHConfig(sessionListenerSimple)).get(TimeoutUtil.TIMEOUT_MILLIS, TimeUnit.MILLISECONDS)) {
        final NetconfMessage subscribeResponse = sentRequestToDevice(SUBSCRIBE_TO_NOTIFICATIONS_REQUEST_XML, sessionListenerNotification);
        assertTrue(containsOkElement(subscribeResponse));
        final NetconfMessage restockToastResponse = sentRequestToDevice(RESTOCK_TOAST_REQUEST_XML, sessionListenerSimple);
        assertTrue(containsOkElement(restockToastResponse));
        final boolean await = notificationReceivedLatch.await(REQUEST_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
        assertTrue(await);
        NetconfMessage restockToastNotification = sessionListenerNotification.getReceivedNotificationMessage();
        assertNotNull(restockToastNotification);
        assertTrue(containsNotificationElement(restockToastNotification));
        final String amountOfBreadExpected = XmlUtil.readXmlToDocument(xmlFileToInputStream(RESTOCK_TOAST_REQUEST_XML)).getElementsByTagName("amountOfBreadToStock").item(0).getTextContent();
        final String amountOfBread = restockToastNotification.getDocument().getElementsByTagName("amountOfBread").item(0).getTextContent();
        assertEquals(amountOfBreadExpected, amountOfBread);
    }
}
Also used : NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) SimpleNetconfClientSessionListener(org.opendaylight.netconf.client.SimpleNetconfClientSessionListener) CountDownLatch(java.util.concurrent.CountDownLatch) NetconfClientSession(org.opendaylight.netconf.client.NetconfClientSession) Test(org.junit.jupiter.api.Test)

Aggregations

NetconfMessage (org.opendaylight.netconf.api.NetconfMessage)125 Test (org.junit.Test)72 AbstractBaseSchemasTest (org.opendaylight.netconf.sal.connect.netconf.AbstractBaseSchemasTest)40 Document (org.w3c.dom.Document)28 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)23 QName (org.opendaylight.yangtools.yang.common.QName)17 DOMSourceAnyxmlNode (org.opendaylight.yangtools.yang.data.api.schema.DOMSourceAnyxmlNode)15 Test (org.junit.jupiter.api.Test)13 SimpleNetconfClientSessionListener (org.opendaylight.netconf.client.SimpleNetconfClientSessionListener)13 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)13 Node (org.w3c.dom.Node)13 NetconfClientSession (org.opendaylight.netconf.client.NetconfClientSession)12 ArrayList (java.util.ArrayList)11 Element (org.w3c.dom.Element)11 DOMRpcResult (org.opendaylight.mdsal.dom.api.DOMRpcResult)10 UnkeyedListNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode)10 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)9 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)9 ChannelFuture (io.netty.channel.ChannelFuture)8 MapNode (org.opendaylight.yangtools.yang.data.api.schema.MapNode)8