2 * Copyright (c) 2015 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.test;
10 import org.junit.Test;
11 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
12 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
13 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
14 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
15 import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveModelContext;
16 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
17 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
19 import static org.junit.Assert.assertNotNull;
21 public class YangFileStmtTest {
22 private static final YangStatementSourceImpl YANGFILE = new YangStatementSourceImpl("/semantic-statement-parser/test.yang");
23 private static final YangStatementSourceImpl IMPORTEDYANGFILE = new YangStatementSourceImpl("/semantic-statement-parser/importedtest.yang");
24 private static final YangStatementSourceImpl SIMPLENODES = new YangStatementSourceImpl("/semantic-statement-parser/simple-nodes-semantic.yang");
25 private static final YangStatementSourceImpl FOO = new YangStatementSourceImpl("/semantic-statement-parser/foo.yang");
26 private static final YangStatementSourceImpl FILE1 = new YangStatementSourceImpl("/model/bar.yang");
27 private static final YangStatementSourceImpl FILE2 = new YangStatementSourceImpl("/model/baz.yang");
28 private static final YangStatementSourceImpl FILE3 = new YangStatementSourceImpl("/model/foo.yang");
29 private static final YangStatementSourceImpl FILE4 = new YangStatementSourceImpl("/model/subfoo.yang");
30 private static final YangStatementSourceImpl EXTFILE = new YangStatementSourceImpl("/semantic-statement-parser/ext-typedef.yang");
31 private static final YangStatementSourceImpl EXTUSE = new YangStatementSourceImpl("/semantic-statement-parser/ext-use.yang");
34 public void readAndParseYangFileTest1() throws SourceException, ReactorException {
35 CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
36 addSources(reactor, YANGFILE, SIMPLENODES, IMPORTEDYANGFILE, FOO);
37 EffectiveModelContext result = reactor.build();
38 assertNotNull(result);
41 // TODO uncomment when Augment in Uses implemented
43 // public void readAndParseYangFileTest2() throws SourceException, ReactorException {
44 // CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
45 // addSources(reactor, FILE1, FILE2, FILE3, FILE4);
46 // EffectiveModelContext result = reactor.build();
47 // assertNotNull(result);
51 public void readAndParseYangFileTest3() throws SourceException, ReactorException {
52 CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
53 addSources(reactor, EXTFILE, EXTUSE);
54 EffectiveModelContext result = reactor.build();
55 assertNotNull(result);
58 private void addSources(CrossSourceStatementReactor.BuildAction reactor, StatementStreamSource... sources) {
59 for (StatementStreamSource source : sources) {
60 reactor.addSource(source);