2 * Copyright (c) 2016 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.stmt;
10 import static org.junit.Assert.assertNotNull;
11 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
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.ReactorDeclaredModel;
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");
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");
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");
45 public void readAndParseYangFileTestModel() throws ReactorException {
46 ReactorDeclaredModel result = RFC7950Reactors.defaultReactor().newBuild()
47 .addSources(BAZ, FOO, BAR, SUBFOO)
49 assertNotNull(result);
53 public void readAndParseYangFileTestModel2() throws ReactorException {
54 ReactorDeclaredModel result = RFC7950Reactors.defaultReactor().newBuild()
55 .addSources(BAZ2, FOO2, BAR2, SUBFOO2)
57 assertNotNull(result);
61 public void readAndParseYangFileTest() throws ReactorException {
62 SchemaContext result = RFC7950Reactors.defaultReactor().newBuild()
63 .addSources(YANGFILE, SIMPLENODES, IMPORTEDYANGFILE, FOOBAR, EXTFILE, EXTUSE)
65 assertNotNull(result);