1 package org.opendaylight.controller.sal.restconf.impl.test;
3 import static org.junit.Assert.*;
6 import java.net.URISyntaxException;
8 import org.junit.BeforeClass;
10 import org.opendaylight.controller.sal.restconf.impl.CompositeNodeWrapper;
11 import org.opendaylight.controller.sal.restconf.impl.ResponseException;
12 import org.opendaylight.controller.sal.restconf.impl.SimpleNodeWrapper;
13 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
15 public class NormalizeNodeTest extends YangAndXmlAndDataSchemaLoader {
18 public static void initialization() {
19 dataLoad("/normalize-node/yang/");
23 public void namespaceNotNullAndInvalidNamespaceAndNoModuleNameTest() {
24 boolean exceptionReised = false;
26 TestUtils.normalizeCompositeNode(prepareCnSn("wrongnamespace"), modules, schemaNodePath);
27 } catch (ResponseException e) {
28 exceptionReised = true;
30 assertTrue(exceptionReised);
34 public void namespaceNullTest() {
35 String exceptionMessage = null;
37 TestUtils.normalizeCompositeNode(prepareCnSn(null), modules, schemaNodePath);
38 } catch (ResponseException e) {
39 exceptionMessage = String.valueOf(e.getResponse().getEntity());
41 assertNull(exceptionMessage);
45 public void namespaceValidNamespaceTest() {
46 String exceptionMessage = null;
48 TestUtils.normalizeCompositeNode(prepareCnSn("normalize:node:module"), modules, schemaNodePath);
49 } catch (ResponseException e) {
50 exceptionMessage = String.valueOf(e.getResponse().getEntity());
52 assertNull(exceptionMessage);
56 public void namespaceValidModuleNameTest() {
57 String exceptionMessage = null;
59 TestUtils.normalizeCompositeNode(prepareCnSn("normalize-node-module"), modules, schemaNodePath);
60 } catch (ResponseException e) {
61 exceptionMessage = String.valueOf(e.getResponse().getEntity());
63 assertNull(exceptionMessage);
66 private CompositeNode prepareCnSn(String namespace) {
68 if (namespace != null) {
70 uri = new URI(namespace);
71 } catch (URISyntaxException e) {
76 SimpleNodeWrapper lf1 = new SimpleNodeWrapper(uri, "lf1", 43);
77 CompositeNodeWrapper cont = new CompositeNodeWrapper(uri, "cont");