Update StmtTestUtils
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / YangTypesStmtTest.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.parser.spi.meta.ReactorException;
15 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
16 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
17 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
18 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
19 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext;
20
21 public class YangTypesStmtTest {
22
23     private static final StatementStreamSource TYPEFILE1 = sourceForResource("/semantic-statement-parser/types.yang");
24     private static final StatementStreamSource TYPEFILE2 = sourceForResource(
25         "/semantic-statement-parser/simple-types.yang");
26     private static final StatementStreamSource TYPEFILE3 = sourceForResource(
27         "/semantic-statement-parser/identityreftest.yang");
28
29     private static final StatementStreamSource FILE1 = sourceForResource("/semantic-statement-parser/model/bar.yang");
30     private static final StatementStreamSource FILE2 = sourceForResource("/semantic-statement-parser/model/baz.yang");
31     private static final StatementStreamSource FILE3 = sourceForResource(
32         "/semantic-statement-parser/model/subfoo.yang");
33     private static final StatementStreamSource FILE4 = sourceForResource("/semantic-statement-parser/model/foo.yang");
34
35     @Test
36     public void readAndParseYangFileTest() throws SourceException, ReactorException {
37         CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
38         addSources(reactor, TYPEFILE1, TYPEFILE2, TYPEFILE3);
39         addSources(reactor, FILE1, FILE2, FILE3, FILE4);
40         EffectiveSchemaContext result = reactor.buildEffective();
41         assertNotNull(result);
42     }
43
44     private static void addSources(final CrossSourceStatementReactor.BuildAction reactor, final StatementStreamSource... sources) {
45         for (StatementStreamSource source : sources) {
46             reactor.addSource(source);
47         }
48     }
49 }