* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.yangtools.yang.data.codec.xml;
import static java.util.Objects.requireNonNull;
XML_FACTORY.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.FALSE);
}
- private final QNameModule fooModuleQName;
- private final QName rootQName;
- private final QName ipAddressQName;
- private final SchemaContext schemaContext;
-
- public Bug5446Test() throws Exception {
- fooModuleQName = QNameModule.create(URI.create("foo"), Revision.of("2015-11-05"));
- rootQName = QName.create(fooModuleQName, "root");
- ipAddressQName = QName.create(fooModuleQName, "ip-address");
-
- schemaContext = YangParserTestUtils.parseYangResource("/bug5446/yang/foo.yang");
- }
+ private static final QNameModule FOO_MODULE = QNameModule.create(URI.create("foo"), Revision.of("2015-11-05"));
+ private static final QName ROOT_QNAME = QName.create(FOO_MODULE, "root");
+ private static final QName IP_ADDRESS_QNAME = QName.create(FOO_MODULE, "ip-address");
@Test
public void test() throws Exception {
+ final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/bug5446/yang/foo.yang");
final Document doc = loadDocument("/bug5446/xml/foo.xml");
final ContainerNode docNode = createDocNode();
- Optional<DataContainerChild<? extends PathArgument, ?>> root = docNode.getChild(new NodeIdentifier(rootQName));
+ Optional<DataContainerChild<? extends PathArgument, ?>> root = docNode.getChild(new NodeIdentifier(ROOT_QNAME));
assertTrue(root.orElse(null) instanceof ContainerNode);
Optional<DataContainerChild<? extends PathArgument, ?>> child = ((ContainerNode) root.orElse(null))
- .getChild(new NodeIdentifier(ipAddressQName));
+ .getChild(new NodeIdentifier(IP_ADDRESS_QNAME));
assertTrue(child.orElse(null) instanceof LeafNode);
LeafNode<?> ipAdress = (LeafNode<?>) child.get();
assertXMLEqual(expectedXMLString, serializationResultXMLString);
}
- private ContainerNode createDocNode() {
- LeafNode<byte[]> ipAddress = ImmutableNodes.leafNode(ipAddressQName, BaseEncoding.base64().decode("fwAAAQ=="));
- ContainerNode root = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(rootQName))
+ private static ContainerNode createDocNode() {
+ LeafNode<byte[]> ipAddress = ImmutableNodes.leafNode(IP_ADDRESS_QNAME, BaseEncoding.base64()
+ .decode("fwAAAQ=="));
+ ContainerNode root = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(ROOT_QNAME))
.withChild(ipAddress).build();
- return ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(rootQName)).withChild(root)
+ return ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(ROOT_QNAME)).withChild(root)
.build();
}