7dbc82c697b9ceb6d3db52dce776f3f7b2149273
[yangtools.git] / parser / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / Bug7424Test.java
1 /*
2  * Copyright (c) 2017 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.stmt;
9
10 import static org.junit.Assert.assertTrue;
11 import static org.junit.Assert.fail;
12
13 import org.junit.Test;
14 import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
15
16 public class Bug7424Test {
17     @Test
18     public void testRpc() throws Exception {
19         try {
20             StmtTestUtils.parseYangSource("/bugs/bug7424/foo-rpc.yang");
21             fail("Test should fail due to invalid yang model.");
22         } catch (final SomeModifiersUnresolvedException e) {
23             assertTrue(e.getCause().getMessage().startsWith(
24                 "Error in module 'foo': cannot add '(foo)name'. Node name collision: '(foo)name' already declared"));
25         }
26     }
27
28     @Test
29     public void testNotification() throws Exception {
30         try {
31             StmtTestUtils.parseYangSource("/bugs/bug7424/foo-notification.yang");
32             fail("Test should fail due to invalid yang model.");
33         } catch (final SomeModifiersUnresolvedException e) {
34             assertTrue(e.getCause().getMessage().startsWith(
35                 "Error in module 'foo': cannot add '(foo)name'. Node name collision: '(foo)name' already declared"));
36         }
37     }
38
39     @Test
40     public void testData() throws Exception {
41         try {
42             StmtTestUtils.parseYangSource("/bugs/bug7424/foo-data.yang");
43             fail("Test should fail due to invalid yang model.");
44         } catch (final SomeModifiersUnresolvedException e) {
45             assertTrue(e.getCause().getMessage().startsWith(
46                 "Error in module 'foo': cannot add '(foo)name'. Node name collision: '(foo)name' already declared"));
47         }
48     }
49
50     @Test
51     public void testRpcUses() throws Exception {
52         try {
53             StmtTestUtils.parseYangSource("/bugs/bug7424/foo-rpc-uses.yang");
54             fail("Test should fail due to invalid yang model.");
55         } catch (final SomeModifiersUnresolvedException e) {
56             assertTrue(e.getCause().getMessage().startsWith(
57                 "Error in module 'foo': cannot add '(foo)name'. Node name collision: '(foo)name' already declared"));
58         }
59     }
60 }