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.cnsn.to.xml.test;
10 import static org.junit.Assert.assertNotNull;
12 import java.io.IOException;
14 import java.net.URISyntaxException;
15 import javax.ws.rs.WebApplicationException;
16 import org.junit.BeforeClass;
17 import org.junit.Test;
18 import org.opendaylight.controller.sal.rest.impl.StructuredDataToXmlProvider;
19 import org.opendaylight.controller.sal.restconf.impl.CompositeNodeWrapper;
20 import org.opendaylight.controller.sal.restconf.impl.SimpleNodeWrapper;
21 import org.opendaylight.controller.sal.restconf.impl.test.TestUtils;
22 import org.opendaylight.controller.sal.restconf.impl.test.YangAndXmlAndDataSchemaLoader;
23 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
27 * CnSn = Composite node and Simple node data structure Class contains test of serializing simple nodes data values
28 * according data types from YANG schema to XML file
31 public class CnSnInstanceIdentifierToXmlTest extends YangAndXmlAndDataSchemaLoader {
34 public static void initialization() throws URISyntaxException {
35 dataLoad("/instanceidentifier/yang", 4, "instance-identifier-module", "cont");
39 public void snAsYangInstanceIdentifier() throws WebApplicationException, IOException, URISyntaxException {
40 CompositeNode cnSnData = prepareCnStructForYangData();
41 String xmlOutput = TestUtils.writeCompNodeWithSchemaContextToOutput(cnSnData, modules, dataSchemaNode,
42 StructuredDataToXmlProvider.INSTANCE);
43 assertNotNull(xmlOutput);
46 private CompositeNode prepareCnStructForYangData() throws URISyntaxException {
47 CompositeNodeWrapper cont = new CompositeNodeWrapper(new URI("instance:identifier:module"), "cont");
48 CompositeNodeWrapper cont1 = new CompositeNodeWrapper(new URI("augment:module"), "cont1");
50 SimpleNodeWrapper lf11 = new SimpleNodeWrapper(new URI("augment:augment:module"), "lf11", "/cont/cont1/lf12");
51 SimpleNodeWrapper lf12 = new SimpleNodeWrapper(new URI("augment:augment:module"), "lf12", "lf12 value");