2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.sal.restconf.impl.test;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertTrue;
12 import static org.junit.Assert.fail;
14 import java.io.FileNotFoundException;
16 import org.junit.BeforeClass;
17 import org.junit.Rule;
18 import org.junit.Test;
19 import org.junit.rules.ExpectedException;
20 import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
21 import org.opendaylight.controller.sal.restconf.impl.InstanceIdWithSchemaNode;
22 import org.opendaylight.controller.sal.restconf.impl.RestconfDocumentedException;
23 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
25 public class RestGetAugmentedElementWhenEqualNamesTest {
27 private static ControllerContext controllerContext = ControllerContext.getInstance();
30 public ExpectedException exception = ExpectedException.none();
33 public static void init() throws FileNotFoundException {
34 SchemaContext schemaContextTestModule = TestUtils.loadSchemaContext("/common/augment/yang");
35 controllerContext.setSchemas(schemaContextTestModule);
39 public void augmentedNodesInUri() {
40 InstanceIdWithSchemaNode iiWithData = controllerContext.toInstanceIdentifier("main:cont/augment-main-a:cont1");
41 assertEquals("ns:augment:main:a", iiWithData.getSchemaNode().getQName().getNamespace().toString());
42 iiWithData = controllerContext.toInstanceIdentifier("main:cont/augment-main-b:cont1");
43 assertEquals("ns:augment:main:b", iiWithData.getSchemaNode().getQName().getNamespace().toString());
47 public void nodeWithoutNamespaceHasMoreAugments() {
49 controllerContext.toInstanceIdentifier("main:cont/cont1");
50 fail( "Expected exception" );
51 } catch (RestconfDocumentedException e) {
52 assertTrue(e.getErrors().get( 0 ).getErrorMessage().contains(
53 "is added as augment from more than one module"));