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\""));
}
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));
}
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());
}
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>"));
}
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"));
}
Aggregations