1 package org.opendaylight.controller.sal.restconf.impl.test;
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNotNull;
5 import static org.junit.Assert.assertNull;
8 import java.net.URISyntaxException;
10 import org.junit.BeforeClass;
11 import org.junit.Test;
12 import org.opendaylight.controller.sal.restconf.impl.CompositeNodeWrapper;
13 import org.opendaylight.controller.sal.restconf.impl.ResponseException;
14 import org.opendaylight.controller.sal.restconf.impl.SimpleNodeWrapper;
15 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
17 public class NormalizeNodeTest extends YangAndXmlAndDataSchemaLoader {
20 public static void initialization() {
21 dataLoad("/normalize-node/yang/");
25 public void namespaceNotNullAndInvalidNamespaceAndNoModuleNameTest() {
26 String exceptionMessage = null;
28 TestUtils.normalizeCompositeNode(prepareCnSn("wrongnamespace"), modules, schemaNodePath);
29 } catch (ResponseException e) {
30 exceptionMessage = String.valueOf(e.getResponse().getEntity());
34 "Data has bad format.\nIf data is in XML format then namespace for cont should be normalize:node:module.\nIf data is in Json format then module name for cont should be normalize-node-module.");
38 public void namespaceNullTest() {
39 String exceptionMessage = null;
41 TestUtils.normalizeCompositeNode(prepareCnSn(null), modules, schemaNodePath);
42 } catch (ResponseException e) {
43 exceptionMessage = String.valueOf(e.getResponse().getEntity());
45 assertNull(exceptionMessage);
49 public void namespaceValidNamespaceTest() {
50 String exceptionMessage = null;
52 TestUtils.normalizeCompositeNode(prepareCnSn("normalize:node:module"), modules, schemaNodePath);
53 } catch (ResponseException e) {
54 exceptionMessage = String.valueOf(e.getResponse().getEntity());
56 assertNull(exceptionMessage);
60 public void namespaceValidModuleNameTest() {
61 String exceptionMessage = null;
63 TestUtils.normalizeCompositeNode(prepareCnSn("normalize-node-module"), modules, schemaNodePath);
64 } catch (ResponseException e) {
65 exceptionMessage = String.valueOf(e.getResponse().getEntity());
67 assertNull(exceptionMessage);
70 private CompositeNode prepareCnSn(String namespace) {
72 if (namespace != null) {
74 uri = new URI(namespace);
75 } catch (URISyntaxException e) {
80 SimpleNodeWrapper lf1 = new SimpleNodeWrapper(uri, "lf1", 43);
81 CompositeNodeWrapper cont = new CompositeNodeWrapper(uri, "cont");