2 * Copyright (c) 2017 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.yangtools.yang.parser.stmt.rfc7950;
10 import static org.junit.Assert.assertNotNull;
11 import static org.junit.Assert.assertTrue;
12 import static org.junit.Assert.fail;
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;
19 public class Bug6886Test {
22 public void yang11UnquotedStrTest() throws Exception {
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"));
33 public void yang11UnquotedStrTest2() throws Exception {
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"));
44 public void yang11DoubleQuotedStrTest() throws Exception {
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'."));
56 public void yang10UnquotedStrTest() throws Exception {
57 final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug6886/yang10/foo.yang");
58 assertNotNull(schemaContext);
62 public void yang10UnquotedStrTest2() throws Exception {
63 final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug6886/yang10/foo2.yang");
64 assertNotNull(schemaContext);
68 public void yang10DoubleQuotedStrTest() throws Exception {
69 final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/rfc7950/bug6886/yang10/foo3.yang");
70 assertNotNull(schemaContext);