YANGTOOLS-706: Split out yang-parser-rfc7950
[yangtools.git] / yang / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / parser / stmt / rfc7950 / Bug6886Test.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.parser.stmt.rfc7950;
9
10 import static org.junit.Assert.assertNotNull;
11 import static org.junit.Assert.assertTrue;
12 import static org.junit.Assert.fail;
13
14 import org.junit.Test;
15 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
17 import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
18
19 public class Bug6886Test {
20
21     @Test
22     public void yang11UnquotedStrTest() throws Exception {
23         try {
24             StmtTestUtils.parseYangSource("/rfc7950/bug6886/yang11/foo.yang");
25             fail("Test should fail due to invalid yang");
26         } catch (final SomeModifiersUnresolvedException e) {
27             assertTrue(e.getCause().getMessage()
28                     .startsWith("YANG 1.1: unquoted string (illegalchars\"test1) contains illegal characters"));
29         }
30     }
31
32     @Test
33     public void yang11UnquotedStrTest2() throws Exception {
34         try {
35             StmtTestUtils.parseYangSource("/rfc7950/bug6886/yang11/foo2.yang");
36             fail("Test should fail due to invalid yang");
37         } catch (final SomeModifiersUnresolvedException e) {
38             assertTrue(e.getCause().getMessage()
39                     .startsWith("YANG 1.1: unquoted string (illegalchars'test2) contains illegal characters"));
40         }
41     }
42
43     @Test
44     public void yang11DoubleQuotedStrTest() throws Exception {
45         try {
46             StmtTestUtils.parseYangSource("/rfc7950/bug6886/yang11/foo3.yang");
47             fail("Test should fail due to invalid yang");
48         } catch (final SomeModifiersUnresolvedException e) {
49             assertTrue(e.getCause().getMessage().startsWith("YANG 1.1: illegal double quoted string "
50                     + "(i\\\\\\\\l\\nl\\te\\\"\\galcharstest1). In double quoted string the backslash must be followed "
51                     + "by one of the following character [n,t,\",\\], but was 'g'."));
52         }
53     }
54
55     @Test
56     public void yang10UnquotedStrTest() throws Exception {
57         final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug6886/yang10/foo.yang");
58         assertNotNull(schemaContext);
59     }
60
61     @Test
62     public void yang10UnquotedStrTest2() throws Exception {
63         final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug6886/yang10/foo2.yang");
64         assertNotNull(schemaContext);
65     }
66
67     @Test
68     public void yang10DoubleQuotedStrTest() throws Exception {
69         final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug6886/yang10/foo3.yang");
70         assertNotNull(schemaContext);
71     }
72 }