f2c47245ad24bda2b7ca0177df71d990ba4270f1
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / YangFileStmtTest.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 package org.opendaylight.yangtools.yang.stmt;
9
10 import static org.junit.Assert.assertNotNull;
11 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
12
13 import org.junit.Test;
14 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
15 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.RFC7950Reactors;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
17 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
18 import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveModelContext;
19
20 public class YangFileStmtTest {
21     //basic statements to parse and write
22     private static final StatementStreamSource YANGFILE = sourceForResource("/semantic-statement-parser/test.yang");
23     private static final StatementStreamSource IMPORTEDYANGFILE = sourceForResource(
24         "/semantic-statement-parser/importedtest.yang");
25     private static final StatementStreamSource SIMPLENODES = sourceForResource(
26         "/semantic-statement-parser/simple-nodes-semantic.yang");
27     private static final StatementStreamSource FOOBAR = sourceForResource("/semantic-statement-parser/foobar.yang");
28     //extension statement to parse and write
29     private static final StatementStreamSource EXTFILE = sourceForResource(
30         "/semantic-statement-parser/ext-typedef.yang");
31     private static final StatementStreamSource EXTUSE = sourceForResource("/semantic-statement-parser/ext-use.yang");
32
33
34     private static final StatementStreamSource BAR = sourceForResource("/model-new/bar.yang");
35     private static final StatementStreamSource BAZ = sourceForResource("/model-new/baz.yang");
36     private static final StatementStreamSource FOO = sourceForResource("/model-new/foo.yang");
37     private static final StatementStreamSource SUBFOO = sourceForResource("/model-new/subfoo.yang");
38
39     private static final StatementStreamSource BAR2 = sourceForResource("/model/bar.yang");
40     private static final StatementStreamSource BAZ2 = sourceForResource("/model/baz.yang");
41     private static final StatementStreamSource FOO2 = sourceForResource("/model/foo.yang");
42     private static final StatementStreamSource SUBFOO2 = sourceForResource("/model/subfoo.yang");
43
44     @Test
45     public void readAndParseYangFileTestModel() throws ReactorException {
46         EffectiveModelContext result = RFC7950Reactors.defaultReactor().newBuild()
47                 .addSources(BAZ, FOO, BAR, SUBFOO)
48                 .build();
49         assertNotNull(result);
50     }
51
52     @Test
53     public void readAndParseYangFileTestModel2() throws ReactorException {
54         EffectiveModelContext result = RFC7950Reactors.defaultReactor().newBuild()
55                 .addSources(BAZ2, FOO2, BAR2, SUBFOO2)
56                 .build();
57         assertNotNull(result);
58     }
59
60     @Test
61     public void readAndParseYangFileTest() throws ReactorException {
62         SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
63                 .addSources(YANGFILE, SIMPLENODES, IMPORTEDYANGFILE, FOOBAR, EXTFILE, EXTUSE)
64                 .buildEffective();
65         assertNotNull(result);
66     }
67 }