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%2FRestGetAugmentedElementWhenEqualNamesTest.java;h=a6391894c2f044dd13d98518db473c952e44d1e8;hb=3948bedd0129e44c0943bd77c91806425645cd72;hp=5650be57ce49dbb45719652fb31cd8ba8658d7ab;hpb=335aee8c6154a25c76503223e636398d32135bc9;p=controller.git diff --git a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetAugmentedElementWhenEqualNamesTest.java b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetAugmentedElementWhenEqualNamesTest.java index 5650be57ce..a6391894c2 100644 --- a/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetAugmentedElementWhenEqualNamesTest.java +++ b/opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetAugmentedElementWhenEqualNamesTest.java @@ -1,45 +1,57 @@ +/* + * 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.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import java.io.FileNotFoundException; -import java.io.UnsupportedEncodingException; -import java.net.URISyntaxException; -import org.junit.Ignore; +import org.junit.BeforeClass; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; import org.opendaylight.controller.sal.restconf.impl.ControllerContext; import org.opendaylight.controller.sal.restconf.impl.InstanceIdWithSchemaNode; import org.opendaylight.controller.sal.restconf.impl.ResponseException; import org.opendaylight.yangtools.yang.model.api.SchemaContext; public class RestGetAugmentedElementWhenEqualNamesTest { - - @Ignore - @Test - public void getDataWithUrlMountPoint() throws UnsupportedEncodingException, URISyntaxException, - FileNotFoundException { - boolean exceptionCaught = false; - + + private static ControllerContext controllerContext = ControllerContext.getInstance(); + + @Rule + public ExpectedException exception = ExpectedException.none(); + + @BeforeClass + public static void init() throws FileNotFoundException { SchemaContext schemaContextTestModule = TestUtils.loadSchemaContext("/common/augment/yang"); - ControllerContext controllerContext = ControllerContext.getInstance(); controllerContext.setSchemas(schemaContextTestModule); + } + @Test + public void augmentedNodesInUri() { + InstanceIdWithSchemaNode iiWithData = controllerContext.toInstanceIdentifier("main:cont/augment-main-a:cont1"); + assertEquals("ns:augment:main:a", iiWithData.getSchemaNode().getQName().getNamespace().toString()); + iiWithData = controllerContext.toInstanceIdentifier("main:cont/augment-main-b:cont1"); + assertEquals("ns:augment:main:b", iiWithData.getSchemaNode().getQName().getNamespace().toString()); + } + + @Test + public void nodeWithoutNamespaceHasMoreAugments() { + boolean exceptionCaught = false; try { - InstanceIdWithSchemaNode instanceIdentifierA = controllerContext - .toInstanceIdentifier("main:cont/augment-main-a:cont1"); - InstanceIdWithSchemaNode instanceIdentifierB = controllerContext - .toInstanceIdentifier("main:cont/augment-main-b:cont1"); - - assertEquals("ns:augment:main:a", instanceIdentifierA.getSchemaNode().getQName().getNamespace().toString()); - assertEquals("ns:augment:main:b", instanceIdentifierB.getSchemaNode().getQName().getNamespace()); + controllerContext.toInstanceIdentifier("main:cont/cont1"); } catch (ResponseException e) { + assertTrue(((String) e.getResponse().getEntity()).contains("is added as augment from more than one module")); exceptionCaught = true; } - - assertFalse(exceptionCaught); - + assertTrue(exceptionCaught); } }