a0f4b83ebd53d52bffe31f4b25adba3ba61d27d7
[yangtools.git] / yang / yang-parser-impl / 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
24                     .getCause()
25                     .getMessage()
26                     .startsWith(
27                             "Error in module 'foo': cannot add '(foo?revision=1970-01-01)name'. "
28                                     + "Node name collision: '(foo?revision=1970-01-01)name' already declared."));
29         }
30     }
31
32     @Test
33     public void testNotification() throws Exception {
34         try {
35             StmtTestUtils.parseYangSource("/bugs/bug7424/foo-notification.yang");
36             fail("Test should fail due to invalid yang model.");
37         } catch (final SomeModifiersUnresolvedException e) {
38             assertTrue(e
39                     .getCause()
40                     .getMessage()
41                     .startsWith(
42                             "Error in module 'foo': cannot add '(foo?revision=1970-01-01)name'. "
43                                     + "Node name collision: '(foo?revision=1970-01-01)name' already declared."));
44         }
45     }
46
47     @Test
48     public void testData() throws Exception {
49         try {
50             StmtTestUtils.parseYangSource("/bugs/bug7424/foo-data.yang");
51             fail("Test should fail due to invalid yang model.");
52         } catch (final SomeModifiersUnresolvedException e) {
53             assertTrue(e
54                     .getCause()
55                     .getMessage()
56                     .startsWith(
57                             "Error in module 'foo': cannot add '(foo?revision=1970-01-01)name'. "
58                                     + "Node name collision: '(foo?revision=1970-01-01)name' already declared."));
59         }
60     }
61
62     @Test
63     public void testRpcUses() throws Exception {
64         try {
65             StmtTestUtils.parseYangSource("/bugs/bug7424/foo-rpc-uses.yang");
66             fail("Test should fail due to invalid yang model.");
67         } catch (final SomeModifiersUnresolvedException e) {
68             assertTrue(e
69                     .getCause()
70                     .getMessage()
71                     .startsWith(
72                             "Error in module 'foo': cannot add '(foo?revision=1970-01-01)name'. "
73                                     + "Node name collision: '(foo?revision=1970-01-01)name' already declared."));
74         }
75     }
76 }