use of org.opendaylight.netconf.api.NetconfMessage in project netconf by opendaylight.
the class SendErrorExceptionUtil method sendErrorMessage.
public static void sendErrorMessage(final NetconfSession session, final DocumentedException sendErrorException) {
LOG.trace("Sending error", sendErrorException);
final Document errorDocument = createDocument(sendErrorException);
ChannelFuture channelFuture = session.sendMessage(new NetconfMessage(errorDocument));
channelFuture.addListener(new SendErrorVerifyingListener(sendErrorException));
}
use of org.opendaylight.netconf.api.NetconfMessage in project netconf by opendaylight.
the class NetconfNestedNotificationTest method testNestedNotificationToNotificationFunction.
@Test
public void testNestedNotificationToNotificationFunction() throws Exception {
final EffectiveModelContext schemaContext = getNotificationSchemaContext(Collections.singleton("/schemas/nested-notification.yang"));
final NetconfMessage notificationMessage = prepareNotification("/nested-notification-payload.xml");
NetconfMessageTransformer messageTransformer = new NetconfMessageTransformer(new EmptyMountPointContext(schemaContext), true, BASE_SCHEMAS.getBaseSchema());
final DOMNotification domNotification = messageTransformer.toNotification(notificationMessage);
final ContainerNode root = domNotification.getBody();
assertNotNull(root);
assertEquals(1, root.body().size());
assertEquals("interface-enabled", root.getIdentifier().getNodeType().getLocalName());
assertEquals(NetconfNotification.RFC3339_DATE_PARSER.apply("2008-07-08T00:01:00Z").toInstant(), ((DOMEvent) domNotification).getEventInstant());
assertEquals(Absolute.of(INTERFACES_QNAME, INTERFACE_QNAME, INTERFACE_ENABLED_NOTIFICATION_QNAME), domNotification.getType());
}
use of org.opendaylight.netconf.api.NetconfMessage in project netconf by opendaylight.
the class SchemalessMessageTransformer method toRpcRequest.
@Override
public NetconfMessage toRpcRequest(final QName rpc, final NormalizedNode input) {
final DOMSource payload = (DOMSource) input.body();
wrapPayload((Document) payload.getNode());
return new NetconfMessage((Document) ((DOMSourceAnyxmlNode) input).body().getNode());
}
use of org.opendaylight.netconf.api.NetconfMessage in project netconf by opendaylight.
the class NetconfToNotificationTest method setup.
@Before
public void setup() throws Exception {
InputStream notifyPayloadStream = getClass().getResourceAsStream("/notification-payload.xml");
assertNotNull(notifyPayloadStream);
final Document doc = XmlUtil.readXmlToDocument(notifyPayloadStream);
assertNotNull(doc);
userNotification = new NetconfMessage(doc);
}
use of org.opendaylight.netconf.api.NetconfMessage in project netconf by opendaylight.
the class NetconfToRpcRequestTest method testUserDefinedRpcCall.
@Test
public void testUserDefinedRpcCall() throws Exception {
final ContainerNode root = Builders.containerBuilder().withNodeIdentifier(toId(SUBSCRIBE_RPC_NAME)).withChild(ImmutableNodes.leafNode(STREAM_NAME, "NETCONF")).build();
final NetconfMessage message = messageTransformer.toRpcRequest(SUBSCRIBE_RPC_NAME, root);
assertNotNull(message);
final Document xmlDoc = message.getDocument();
final org.w3c.dom.Node rpcChild = xmlDoc.getFirstChild();
assertEquals(rpcChild.getLocalName(), "rpc");
final org.w3c.dom.Node subscribeName = rpcChild.getFirstChild();
assertEquals(subscribeName.getLocalName(), "subscribe");
final org.w3c.dom.Node streamName = subscribeName.getFirstChild();
assertEquals(streamName.getLocalName(), "stream-name");
}
Aggregations