X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-rest-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Frestconf%2Fimpl%2Ftest%2FNormalizeNodeTest.java;h=158569af7386eb35081ba046af00d96b0de08d96;hb=48814d6a264b8f13e5db1422336d9ef25cb05fa9;hp=83e6ae51d07b1e32844a712edef2d86c2a2cc39c;hpb=54bed4dd6dfbada9a8e2ddf70ca84952aec3f55a;p=controller.git diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/NormalizeNodeTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/NormalizeNodeTest.java index 83e6ae51d0..158569af73 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/NormalizeNodeTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/NormalizeNodeTest.java @@ -1,6 +1,13 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ package org.opendaylight.controller.sal.restconf.impl.test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertNotNull; import java.net.URI; import java.net.URISyntaxException; @@ -8,7 +15,7 @@ import java.net.URISyntaxException; import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.controller.sal.restconf.impl.CompositeNodeWrapper; -import org.opendaylight.controller.sal.restconf.impl.ResponseException; +import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException; import org.opendaylight.controller.sal.restconf.impl.SimpleNodeWrapper; import org.opendaylight.yangtools.yang.data.api.CompositeNode; @@ -19,51 +26,31 @@ public class NormalizeNodeTest extends YangAndXmlAndDataSchemaLoader { dataLoad("/normalize-node/yang/"); } - @Test + @Test(expected=RestconfDocumentedException.class) public void namespaceNotNullAndInvalidNamespaceAndNoModuleNameTest() { - boolean exceptionReised = false; - try { - TestUtils.normalizeCompositeNode(prepareCnSn("wrongnamespace"), modules, schemaNodePath); - } catch (ResponseException e) { - exceptionReised = true; - } - assertTrue(exceptionReised); + + TestUtils.normalizeCompositeNode(prepareCnSn("wrongnamespace"), modules, schemaNodePath); } @Test public void namespaceNullTest() { - String exceptionMessage = null; - try { - TestUtils.normalizeCompositeNode(prepareCnSn(null), modules, schemaNodePath); - } catch (ResponseException e) { - exceptionMessage = String.valueOf(e.getResponse().getEntity()); - } - assertNull(exceptionMessage); + + TestUtils.normalizeCompositeNode(prepareCnSn(null), modules, schemaNodePath); } @Test public void namespaceValidNamespaceTest() { - String exceptionMessage = null; - try { - TestUtils.normalizeCompositeNode(prepareCnSn("normalize:node:module"), modules, schemaNodePath); - } catch (ResponseException e) { - exceptionMessage = String.valueOf(e.getResponse().getEntity()); - } - assertNull(exceptionMessage); + + TestUtils.normalizeCompositeNode(prepareCnSn("normalize:node:module"), modules, schemaNodePath); } @Test public void namespaceValidModuleNameTest() { - String exceptionMessage = null; - try { - TestUtils.normalizeCompositeNode(prepareCnSn("normalize-node-module"), modules, schemaNodePath); - } catch (ResponseException e) { - exceptionMessage = String.valueOf(e.getResponse().getEntity()); - } - assertNull(exceptionMessage); + + TestUtils.normalizeCompositeNode(prepareCnSn("normalize-node-module"), modules, schemaNodePath); } - private CompositeNode prepareCnSn(String namespace) { + private CompositeNode prepareCnSn(final String namespace) { URI uri = null; if (namespace != null) { try {