Adjust test suite parser update to conform with API changes
[yangtools.git] / yang / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / Bug8831Test.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.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
18 public class Bug8831Test {
19     @Test
20     public void test() throws Exception {
21         final SchemaContext context = TestUtils.parseYangSources("/bugs/bug8831/valid");
22         assertNotNull(context);
23     }
24
25     @Test
26     public void invalidModelsTest() throws Exception {
27         try {
28             TestUtils.parseYangSource("/bugs/bug8831/invalid/inv-model.yang");
29             fail("Test should fails due to invalid yang 1.1 model");
30         } catch (final SomeModifiersUnresolvedException e) {
31             assertTrue(
32                     e.getCause().getMessage().contains("has default value 'any' marked with an if-feature statement"));
33         }
34     }
35
36     @Test
37     public void invalidModelsTest2() throws Exception {
38         try {
39             TestUtils.parseYangSource("/bugs/bug8831/invalid/inv-model2.yang");
40             fail("Test should fails due to invalid yang 1.1 model");
41         } catch (final SomeModifiersUnresolvedException e) {
42             assertTrue(
43                     e.getCause().getMessage().contains("has default value 'any' marked with an if-feature statement"));
44         }
45     }
46 }