90935fd324ceccd375f698c3b4685051cdf4528b
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / Bug7146Test.java
1 /*
2  * Copyright (c) 2016 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
9 package org.opendaylight.yangtools.yang.stmt;
10
11 import static org.junit.Assert.assertTrue;
12 import static org.junit.Assert.fail;
13 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
14
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
18
19 public class Bug7146Test {
20
21     @Test
22     public void shouldFailOnSyntaxError() throws ReactorException {
23         try {
24             StmtTestUtils.parseYangSources(sourceForResource("/bugs/bug7146/foo.yang"));
25             fail("RuntimeException should have been thrown because of an unknown character in yang module.");
26         } catch (IllegalArgumentException ex) {
27             final Throwable cause = ex.getCause();
28             assertTrue(cause instanceof YangSyntaxErrorException);
29             assertTrue(cause.getMessage().contains("extraneous input '#'"));
30         }
31     }
32 }