- TestUtils.supplementNamespace(dataSchemaNode, compNode);
-
- String nameSpaceList = "data:list:yang";
- String nameSpaceCont = "data:container:yang";
- assertEquals(nameSpaceCont, compNode.getNodeType().getNamespace().toString());
- assertEquals("cont", compNode.getNodeType().getLocalName());
- assertEquals(3, compNode.getChildren().size());
- CompositeNode lst1_1 = null;
- CompositeNode lst1_2 = null;
- int loopCount = 0;
- for (Node<?> node : compNode.getChildren()) {
- if (node.getNodeType().getLocalName().equals("lf1")) {
- assertEquals(nameSpaceList, node.getNodeType().getNamespace().toString());
- assertTrue(node instanceof SimpleNode<?>);
- assertEquals("lf1", node.getValue());
- } else {
- assertTrue(node instanceof CompositeNode);
- switch (loopCount++) {
- case 0:
- lst1_1 = (CompositeNode) node;
- break;
- case 1:
- lst1_2 = (CompositeNode) node;
- break;
- }
- assertEquals(nameSpaceCont, node.getNodeType().getNamespace().toString());
- }
- }
- // lst1_1
- verifyCommonPartAOfXml(lst1_1, "1", nameSpaceCont);
- // :lst1_1
-
- // lst1_2
- SimpleNode<?> lflst11 = null;
- CompositeNode cont11 = null;
- for (Node<?> node : lst1_2.getChildren()) {
- String nodeName = node.getNodeType().getLocalName();
- if (nodeName.equals("lflst11")) {
- assertTrue(node instanceof SimpleNode<?>);
- lflst11 = (SimpleNode<?>) node;
-
- } else if (nodeName.equals("cont11")) {
- assertTrue(node instanceof CompositeNode);
- cont11 = (CompositeNode) node;
- }
- assertEquals(nameSpaceCont, compNode.getNodeType().getNamespace().toString());
- }
- assertEquals("221", lflst11.getValue());
-
- assertEquals(1, cont11.getChildren().size());
- assertTrue(cont11.getChildren().get(0) instanceof SimpleNode<?>);
- SimpleNode<?> cont11_lf111 = (SimpleNode<?>) cont11.getChildren().get(0);
- assertEquals(nameSpaceCont, cont11_lf111.getNodeType().getNamespace().toString());
- assertEquals("lf111", cont11_lf111.getNodeType().getLocalName());
- assertEquals((short) 100, cont11_lf111.getValue());
- // :lst1_2
-
- }
-
- @Test
- public void testXmlEmptyData() {
- CompositeNode compNode = compositeNodeFromXml("/xml-to-cnsn/empty-data.xml", true);
- assertEquals("cont", compNode.getNodeType().getLocalName());
- SimpleNode<?> lf1 = null;
- SimpleNode<?> lflst1_1 = null;
- SimpleNode<?> lflst1_2 = null;
- CompositeNode lst1 = null;
- int lflst1Count = 0;
- for (Node<?> node : compNode.getChildren()) {
- if (node.getNodeType().getLocalName().equals("lf1")) {
- assertTrue(node instanceof SimpleNode<?>);
- lf1 = (SimpleNode<?>) node;
- } else if (node.getNodeType().getLocalName().equals("lflst1")) {
- assertTrue(node instanceof SimpleNode<?>);
-
- switch (lflst1Count++) {
- case 0:
- lflst1_1 = (SimpleNode<?>) node;
- break;
- case 1:
- lflst1_2 = (SimpleNode<?>) node;
- break;
- }
- } else if (node.getNodeType().getLocalName().equals("lst1")) {
- assertTrue(node instanceof CompositeNode);
- lst1 = (CompositeNode) node;
- }
- }
-
- assertNotNull(lf1);
- assertNotNull(lflst1_1);
- assertNotNull(lflst1_2);
- assertNotNull(lst1);
-
- assertEquals("", lf1.getValue());
- assertEquals("", lflst1_1.getValue());
- assertEquals("", lflst1_2.getValue());
- assertEquals(1, lst1.getChildren().size());
- assertEquals("lf11", lst1.getChildren().get(0).getNodeType().getLocalName());
-
- assertTrue(lst1.getChildren().get(0) instanceof SimpleNode<?>);
- assertEquals("", lst1.getChildren().get(0).getValue());
-
- }
-
- /**
- * Test case like this <lf11 xmlns:x="namespace">x:identity</lf11>
- */
- @Test
- public void testIdentityrefNmspcInElement() {
- testIdentityrefToCnSn("/xml-to-cnsn/identityref/xml/data-nmspc-in-element.xml", "/xml-to-cnsn/identityref",
- "identityref-module", "cont", 2, "iden", "identity:module");
- }