Search in sources :

Example 86 with NetconfMessage

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

the class NetconfDataTreeServiceImplTest method remove.

@Test
public void remove() {
    netconService.remove(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=\"remove\""));
}
Also used : NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) AbstractTestModelTest(org.opendaylight.netconf.sal.connect.netconf.AbstractTestModelTest) Test(org.junit.Test)

Example 87 with NetconfMessage

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

the class SchemalessNetconfDeviceRpcTest method setUp.

@Before
public void setUp() throws Exception {
    RpcResult<NetconfMessage> msg = null;
    ListenableFuture<RpcResult<NetconfMessage>> future = Futures.immediateFuture(msg);
    doReturn(future).when(listener).sendRequest(any(), any());
    final MessageCounter counter = new MessageCounter();
    deviceRpc = new SchemalessNetconfDeviceRpc(new RemoteDeviceId("device1", InetSocketAddress.createUnresolved("0.0.0.0", 17830)), listener, new BaseRpcSchemalessTransformer(BASE_SCHEMAS, counter), new SchemalessMessageTransformer(counter));
}
Also used : RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) MessageCounter(org.opendaylight.netconf.sal.connect.util.MessageCounter) SchemalessMessageTransformer(org.opendaylight.netconf.sal.connect.netconf.schema.mapping.SchemalessMessageTransformer) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) BaseRpcSchemalessTransformer(org.opendaylight.netconf.sal.connect.netconf.schema.mapping.BaseRpcSchemalessTransformer) Before(org.junit.Before)

Example 88 with NetconfMessage

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

the class NetconfServerSessionListenerTest method testOnMessage.

@Test
public void testOnMessage() throws Exception {
    final Document reply = XmlUtil.readXmlToDocument("<rpc-reply message-id=\"101\" " + "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><example/></rpc-reply>");
    doReturn(reply).when(router).onNetconfMessage(any(), any());
    final NetconfMessage msg = new NetconfMessage(XmlUtil.readXmlToDocument("<rpc message-id=\"101\" " + "xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"><example/></rpc>"));
    listener.onMessage(session, msg);
    verify(monitoringListener).onSessionEvent(argThat(sessionEventIs(SessionEvent.Type.IN_RPC_SUCCESS)));
    channel.runPendingTasks();
    final NetconfMessage sentMsg = channel.readOutbound();
    final Diff diff = XMLUnit.compareXML(reply, sentMsg.getDocument());
    assertTrue(diff.toString(), diff.similar());
}
Also used : Diff(org.custommonkey.xmlunit.Diff) NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 89 with NetconfMessage

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

the class NetconfServerSessionTest method setUp.

@Before
public void setUp() throws Exception {
    final NetconfHelloMessageAdditionalHeader header = new NetconfHelloMessageAdditionalHeader(USER, HOST, PORT, SSH_TRANSPORT, SESSION_ID);
    channel = new EmbeddedChannel();
    session = new NetconfServerSession(listener, channel, 1L, header);
    doNothing().when(listener).onSessionUp(any());
    msg = new NetconfMessage(XmlUtil.readXmlToDocument("<rpc-reply></rpc-reply>"));
}
Also used : NetconfHelloMessageAdditionalHeader(org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader) NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) Before(org.junit.Before)

Example 90 with NetconfMessage

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

the class SendErrorExceptionUtilTest method testSendErrorMessage4.

@Test
public void testSendErrorMessage4() throws Exception {
    SendErrorExceptionUtil.sendErrorMessage(netconfSession, exception, readMessage("rpc_ns.xml"));
    final ArgumentCaptor<NetconfMessage> messageCaptor = ArgumentCaptor.forClass(NetconfMessage.class);
    verify(netconfSession, times(1)).sendMessage(messageCaptor.capture());
    final Element rpcReply = messageCaptor.getValue().getDocument().getDocumentElement();
    assertEquals("Invalid value of message-id attribute in the reply message", "a", rpcReply.getAttribute("message-id"));
}
Also used : NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) Element(org.w3c.dom.Element) Test(org.junit.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