Change unprotected netconf address from 0.0.0.0 to 127.0.0.1 .
[controller.git] / opendaylight / md-sal / sal-rest-connector / src / test / java / org / opendaylight / controller / sal / restconf / impl / cnsn / to / json / test / CnSnToJsonNotExistingLeafTypeTest.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.sal.restconf.impl.cnsn.to.json.test;
9
10 import static org.junit.Assert.assertNotNull;
11 import static org.junit.Assert.assertTrue;
12
13 import java.io.IOException;
14 import java.util.Collections;
15 import java.util.Set;
16
17 import javax.ws.rs.WebApplicationException;
18
19 import org.junit.BeforeClass;
20 import org.junit.Ignore;
21 import org.junit.Test;
22 import org.opendaylight.controller.sal.rest.impl.StructuredDataToJsonProvider;
23 import org.opendaylight.controller.sal.restconf.impl.test.*;
24 import org.opendaylight.yangtools.yang.data.api.*;
25 import org.opendaylight.yangtools.yang.data.impl.NodeFactory;
26 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
27 import org.opendaylight.yangtools.yang.model.api.Module;
28 import org.opendaylight.yangtools.yang.parser.builder.impl.ContainerSchemaNodeBuilder;
29 import org.opendaylight.yangtools.yang.parser.builder.impl.LeafSchemaNodeBuilder;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
32
33 public class CnSnToJsonNotExistingLeafTypeTest extends YangAndXmlAndDataSchemaLoader {
34
35     private static final Logger LOG = LoggerFactory.getLogger(CnSnToJsonNotExistingLeafTypeTest.class);
36
37     @BeforeClass
38     public static void initialize() {
39         dataLoad("/cnsn-to-json/simple-data-types");
40     }
41
42     // FIXME
43     @Ignore
44     @Test
45     public void incorrectTopLevelElementTest() {
46
47         String jsonOutput = null;
48         try {
49             jsonOutput = TestUtils
50                     .writeCompNodeWithSchemaContextToOutput(prepareCompositeNode(),
51                             (Set<Module>) Collections.EMPTY_SET, prepareDataSchemaNode(),
52                             StructuredDataToJsonProvider.INSTANCE);
53         } catch (WebApplicationException | IOException e) {
54             LOG.error("WebApplicationException or IOException was raised");
55         }
56         assertNotNull(jsonOutput);
57         assertTrue(jsonOutput.contains("\"lf1\": \"\""));
58     }
59
60     private CompositeNode prepareCompositeNode() {
61         MutableCompositeNode cont = NodeFactory.createMutableCompositeNode(
62                 TestUtils.buildQName("cont", "simple:uri", "2012-12-17"), null, null, ModifyAction.CREATE, null);
63         MutableSimpleNode<?> lf1 = NodeFactory.createMutableSimpleNode(
64                 TestUtils.buildQName("lf1", "simple:uri", "2012-12-17"), cont, "any value", ModifyAction.CREATE, null);
65         cont.getChildren().add(lf1);
66         cont.init();
67         return cont;
68     }
69
70     private DataSchemaNode prepareDataSchemaNode() {
71         ContainerSchemaNodeBuilder contBuild = new ContainerSchemaNodeBuilder("module", 1, TestUtils.buildQName("cont",
72                 "simple:uri", "2012-12-17"), null);
73         LeafSchemaNodeBuilder leafBuild = new LeafSchemaNodeBuilder("module", 2, TestUtils.buildQName("lf1",
74                 "simple:uri", "2012-12-17"), null);
75         leafBuild.setType(new DummyType());
76         leafBuild.setConfiguration(true);
77
78         contBuild.addChildNode(leafBuild);
79         return contBuild.build();
80     }
81
82 }