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;
16 import javax.ws.rs.WebApplicationException;
18 import org.junit.BeforeClass;
19 import org.junit.Test;
20 import org.opendaylight.controller.sal.rest.impl.StructuredDataToXmlProvider;
21 import org.opendaylight.controller.sal.restconf.impl.CompositeNodeWrapper;
22 import org.opendaylight.controller.sal.restconf.impl.SimpleNodeWrapper;
23 import org.opendaylight.controller.sal.restconf.impl.test.TestUtils;
24 import org.opendaylight.controller.sal.restconf.impl.test.YangAndXmlAndDataSchemaLoader;
25 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
29 * CnSn = Composite node and Simple node data structure Class contains test of
30 * serializing simple nodes data values according data types from YANG schema to
34 public class CnSnInstanceIdentifierToXmlTest extends YangAndXmlAndDataSchemaLoader {
37 public static void initialization() throws URISyntaxException {
38 dataLoad("/instanceidentifier/yang", 4, "instance-identifier-module", "cont");
42 public void snAsYangInstanceIdentifier() throws WebApplicationException, IOException, URISyntaxException {
43 CompositeNode cnSnData = prepareCnStructForYangData( );
44 String xmlOutput = TestUtils.writeCompNodeWithSchemaContextToOutput(cnSnData, modules, dataSchemaNode,
45 StructuredDataToXmlProvider.INSTANCE);
46 assertNotNull(xmlOutput);
49 private CompositeNode prepareCnStructForYangData() throws URISyntaxException {
50 CompositeNodeWrapper cont = new CompositeNodeWrapper(new URI("instance:identifier:module"), "cont");
51 CompositeNodeWrapper cont1 = new CompositeNodeWrapper(new URI("augment:module"), "cont1");
53 SimpleNodeWrapper lf11 = new SimpleNodeWrapper(new URI("augment:augment:module"), "lf11", "/cont/cont1/lf12");
54 SimpleNodeWrapper lf12 = new SimpleNodeWrapper(new URI("augment:augment:module"), "lf12", "lf12 value");