Bug 4540: Yang parser exceptions should follow consistent path
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / test / Bug4410Test.java
1 /*
2  * Copyright (c) 2015 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.test;
9
10 import static org.junit.Assert.assertTrue;
11 import static org.junit.Assert.fail;
12
13 import com.google.common.base.Throwables;
14 import java.io.FileNotFoundException;
15 import java.net.URISyntaxException;
16 import org.junit.Test;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
20 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
21
22 public class Bug4410Test {
23
24     @Test
25     public void test() throws SourceException, FileNotFoundException, ReactorException, URISyntaxException {
26         try {
27             StmtTestUtils.parseYangSources("/bugs/bug4410");
28             fail("SomeModifiersUnresolvedException should be thrown.");
29         } catch (SomeModifiersUnresolvedException e) {
30             Throwable rootCause = Throwables.getRootCause(e);
31             assertTrue(rootCause instanceof InferenceException);
32             final String message = rootCause.getMessage();
33             assertTrue(message.startsWith("Type [(foo?revision=1970-01-01)"));
34             assertTrue(message.contains("was not found"));
35         }
36     }
37 }