2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.sal.restconf.impl.xml.to.cnsn.test;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
14 import org.junit.BeforeClass;
15 import org.junit.Test;
16 import org.opendaylight.controller.sal.rest.impl.XmlToCompositeNodeProvider;
17 import org.opendaylight.controller.sal.restconf.impl.test.TestUtils;
18 import org.opendaylight.controller.sal.restconf.impl.test.YangAndXmlAndDataSchemaLoader;
19 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
20 import org.opendaylight.yangtools.yang.data.api.Node;
21 import org.opendaylight.yangtools.yang.data.api.SimpleNode;
23 public class XmlToCnSnTest extends YangAndXmlAndDataSchemaLoader {
26 public static void initialize() {
27 dataLoad("/xml-to-cnsn/leafref");
31 public void testXmlLeafrefToCnSn() {
32 CompositeNode compositeNode = TestUtils.readInputToCnSn("/xml-to-cnsn/leafref/xml/data.xml", false,
33 XmlToCompositeNodeProvider.INSTANCE);
34 assertNotNull(compositeNode);
35 assertNotNull(dataSchemaNode);
36 TestUtils.normalizeCompositeNode(compositeNode, modules, schemaNodePath);
38 assertEquals("cont", compositeNode.getNodeType().getLocalName());
40 SimpleNode<?> lf2 = null;
41 for (Node<?> childNode : compositeNode.getValue()) {
42 if (childNode instanceof SimpleNode) {
43 if (childNode.getNodeType().getLocalName().equals("lf2")) {
44 lf2 = (SimpleNode<?>) childNode;
51 assertTrue(lf2.getValue() instanceof String);
52 assertEquals("121", lf2.getValue());