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.*;
12 import org.junit.BeforeClass;
13 import org.junit.Test;
14 import org.opendaylight.controller.sal.rest.impl.XmlToCompositeNodeProvider;
15 import org.opendaylight.controller.sal.restconf.impl.test.TestUtils;
16 import org.opendaylight.controller.sal.restconf.impl.test.YangAndXmlAndDataSchemaLoader;
17 import org.opendaylight.yangtools.yang.data.api.*;
19 public class XmlToCnSnTest extends YangAndXmlAndDataSchemaLoader {
22 public static void initialize() {
23 dataLoad("/xml-to-cnsn/leafref");
27 public void testXmlLeafrefToCnSn() {
28 CompositeNode compositeNode = TestUtils.readInputToCnSn("/xml-to-cnsn/leafref/xml/data.xml", false,
29 XmlToCompositeNodeProvider.INSTANCE);
30 assertNotNull(compositeNode);
31 assertNotNull(dataSchemaNode);
32 TestUtils.normalizeCompositeNode(compositeNode, modules, schemaNodePath);
34 assertEquals("cont", compositeNode.getNodeType().getLocalName());
36 SimpleNode<?> lf2 = null;
37 for (Node<?> childNode : compositeNode.getChildren()) {
38 if (childNode instanceof SimpleNode) {
39 if (childNode.getNodeType().getLocalName().equals("lf2")) {
40 lf2 = (SimpleNode<?>) childNode;
47 assertTrue(lf2.getValue() instanceof String);
48 assertEquals("121", (String) lf2.getValue());