use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.
the class TestXmlBodyReaderMountPoint method moduleDataTest.
@Test
public void moduleDataTest() throws Exception {
final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont";
mockBodyReader(uri, this.xmlBodyReader, false);
final InputStream inputStream = TestXmlBodyReaderMountPoint.class.getResourceAsStream("/instanceidentifier/xml/xmldata.xml");
final NormalizedNodeContext returnValue = this.xmlBodyReader.readFrom(null, null, null, this.mediaType, null, inputStream);
checkMountPointNormalizedNodeContext(returnValue);
checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue);
}
use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.
the class TestXmlBodyReaderMountPoint method rpcModuleInputTest.
@Test
public void rpcModuleInputTest() throws Exception {
final String uri = "instance-identifier-module:cont/yang-ext:mount/invoke-rpc-module:rpc-test";
mockBodyReader(uri, this.xmlBodyReader, true);
final InputStream inputStream = TestXmlBodyReaderMountPoint.class.getResourceAsStream("/invoke-rpc/xml/rpc-input.xml");
final NormalizedNodeContext returnValue = this.xmlBodyReader.readFrom(null, null, null, this.mediaType, null, inputStream);
checkNormalizedNodeContext(returnValue);
final ContainerNode contNode = (ContainerNode) returnValue.getData();
final YangInstanceIdentifier yangCont = YangInstanceIdentifier.of(QName.create(contNode.getIdentifier().getNodeType(), "cont"));
final Optional<DataContainerChild> contDataNodePotential = contNode.findChildByArg(yangCont.getLastPathArgument());
assertTrue(contDataNodePotential.isPresent());
final ContainerNode contDataNode = (ContainerNode) contDataNodePotential.get();
final YangInstanceIdentifier yangLeaf = YangInstanceIdentifier.of(QName.create(contDataNode.getIdentifier().getNodeType(), "lf"));
final Optional<DataContainerChild> leafDataNode = contDataNode.findChildByArg(yangLeaf.getLastPathArgument());
assertTrue(leafDataNode.isPresent());
assertTrue("lf-test".equalsIgnoreCase(leafDataNode.get().body().toString()));
}
use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.
the class TestXmlBodyWriter method rpcModuleInputTest.
@Test
public void rpcModuleInputTest() throws Exception {
final String uri = "invoke-rpc-module:rpc-test";
final String pathToInputFile = "/invoke-rpc/xml/rpc-output.xml";
final NormalizedNodeContext nnContext = TestRestconfUtils.loadNormalizedContextFromXmlFile(pathToInputFile, uri, controllerContext);
final OutputStream output = new ByteArrayOutputStream();
this.xmlBodyWriter.writeTo(nnContext, null, null, null, this.mediaType, null, output);
assertTrue(output.toString().contains("lf-test"));
}
use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.
the class NnToXmlWithDataFromSeveralModulesTest method dataFromSeveralModulesToXmlTest.
@Test
public void dataFromSeveralModulesToXmlTest() throws WebApplicationException, IOException, URISyntaxException {
final NormalizedNodeContext normalizedNodeContext = prepareNormalizedNodeContext();
final OutputStream output = new ByteArrayOutputStream();
xmlBodyWriter.writeTo(normalizedNodeContext, null, null, null, mediaType, null, output);
final String outputString = output.toString();
// data
assertTrue(outputString.contains("<data xmlns=" + '"' + "urn:ietf:params:xml:ns:netconf:base:1.0" + '"' + '>'));
// cont m2
assertTrue(outputString.contains("<cont_m2 xmlns=" + '"' + "module:two" + '"' + '>'));
assertTrue(outputString.contains("<lf1_m2>lf1 m2 value</lf1_m2>"));
assertTrue(outputString.contains("<contB_m2/>"));
assertTrue(outputString.contains("</cont_m2>"));
// cont m1
assertTrue(outputString.contains("<cont_m1 xmlns=" + '"' + "module:one" + '"' + '>'));
assertTrue(outputString.contains("<contB_m1/>"));
assertTrue(outputString.contains("<lf1_m1>lf1 m1 value</lf1_m1>"));
assertTrue(outputString.contains("</cont_m1>"));
// end
assertTrue(output.toString().contains("</data>"));
}
use of org.opendaylight.netconf.sal.rest.impl.NormalizedNodeContext in project netconf by opendaylight.
the class TestJsonBodyReaderMountPoint method moduleDataTest.
@Test
public void moduleDataTest() throws Exception {
final DataSchemaNode dataSchemaNode = schemaContext.getDataChildByName(QName.create(INSTANCE_IDENTIFIER_MODULE_QNAME, "cont"));
final String uri = "instance-identifier-module:cont/yang-ext:mount/instance-identifier-module:cont";
mockBodyReader(uri, this.jsonBodyReader, false);
final InputStream inputStream = TestJsonBodyReaderMountPoint.class.getResourceAsStream("/instanceidentifier/json/jsondata.json");
final NormalizedNodeContext returnValue = this.jsonBodyReader.readFrom(null, null, null, this.mediaType, null, inputStream);
checkMountPointNormalizedNodeContext(returnValue);
checkExpectValueNormalizeNodeContext(dataSchemaNode, returnValue);
}
Aggregations