2 * Copyright (c) 2017 Pantheon Technologies, s.r.o. 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.yangtools.yang.stmt;
10 import static org.junit.Assert.assertTrue;
11 import static org.junit.Assert.fail;
13 import org.junit.Test;
14 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
15 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
17 public class YT838Test {
19 public void testGroupingShadowing() throws Exception {
20 testGrouping("grouping.yang");
24 public void testGroupingPostShadowing() throws Exception {
25 testGrouping("grouping-post.yang");
29 public void testTypedefShadowing() throws Exception {
30 testTypedef("typedef.yang");
34 public void testTypedefPostShadowing() throws Exception {
35 testTypedef("typedef-post.yang");
38 private static void testGrouping(final String model) throws Exception {
40 StmtTestUtils.parseYangSource("/bugs/YT838/" + model);
41 fail("Expected failure due to grouping identifier shadowing");
42 } catch (ReactorException e) {
43 final Throwable cause = e.getCause();
44 assertTrue(cause instanceof SourceException);
45 assertTrue(cause.getMessage().startsWith(
46 "Duplicate name for grouping (grouping?revision=2017-12-20)foo [at "));
50 private static void testTypedef(final String model) throws Exception {
52 StmtTestUtils.parseYangSource("/bugs/YT838/" + model);
53 fail("Expected failure due to type identifier shadowing");
54 } catch (ReactorException e) {
55 final Throwable cause = e.getCause();
56 assertTrue(cause instanceof SourceException);
57 assertTrue(cause.getMessage().startsWith(
58 "Duplicate name for typedef (typedef?revision=2017-12-20)foo [at "));