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 static org.junit.Assert.assertNotNull;
11 import org.junit.Test;
12 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
13 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
14 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
15 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
16 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
17 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
18 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext;
20 public class YangTypesStmtTest {
22 private static final YangStatementSourceImpl TYPEFILE1 = new YangStatementSourceImpl
23 ("/semantic-statement-parser/types.yang",false);
24 private static final YangStatementSourceImpl TYPEFILE2 = new YangStatementSourceImpl
25 ("/semantic-statement-parser/simple-types.yang",false);
26 private static final YangStatementSourceImpl TYPEFILE3 = new YangStatementSourceImpl
27 ("/semantic-statement-parser/identityreftest.yang",false);
29 private static final YangStatementSourceImpl FILE1 = new YangStatementSourceImpl
30 ("/semantic-statement-parser/model/bar.yang",false);
31 private static final YangStatementSourceImpl FILE2 = new YangStatementSourceImpl
32 ("/semantic-statement-parser/model/baz.yang",false);
33 private static final YangStatementSourceImpl FILE3 = new YangStatementSourceImpl
34 ("/semantic-statement-parser/model/subfoo.yang",false);
35 private static final YangStatementSourceImpl FILE4 = new YangStatementSourceImpl
36 ("/semantic-statement-parser/model/foo.yang",false);
39 public void readAndParseYangFileTest() throws SourceException, ReactorException {
40 CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
41 addSources(reactor, TYPEFILE1, TYPEFILE2, TYPEFILE3);
42 addSources(reactor, FILE1, FILE2, FILE3, FILE4);
43 EffectiveSchemaContext result = reactor.buildEffective();
44 assertNotNull(result);
47 private static void addSources(final CrossSourceStatementReactor.BuildAction reactor, final StatementStreamSource... sources) {
48 for (StatementStreamSource source : sources) {
49 reactor.addSource(source);