package org.opendaylight.yangtools.yang.stmt;
import static org.junit.Assert.assertNotNull;
+import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
import org.junit.Test;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveModelContext;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext;
public class YangFileStmtTest {
//basic statements to parse and write
- private static final YangStatementSourceImpl YANGFILE = new YangStatementSourceImpl("/semantic-statement-parser/test.yang", false);
- private static final YangStatementSourceImpl IMPORTEDYANGFILE = new YangStatementSourceImpl("/semantic-statement-parser/importedtest.yang", false);
- private static final YangStatementSourceImpl SIMPLENODES = new YangStatementSourceImpl("/semantic-statement-parser/simple-nodes-semantic.yang", false);
- private static final YangStatementSourceImpl FOOBAR = new YangStatementSourceImpl("/semantic-statement-parser/foobar.yang", false);
+ private static final StatementStreamSource YANGFILE = sourceForResource("/semantic-statement-parser/test.yang");
+ private static final StatementStreamSource IMPORTEDYANGFILE = sourceForResource(
+ "/semantic-statement-parser/importedtest.yang");
+ private static final StatementStreamSource SIMPLENODES = sourceForResource(
+ "/semantic-statement-parser/simple-nodes-semantic.yang");
+ private static final StatementStreamSource FOOBAR = sourceForResource("/semantic-statement-parser/foobar.yang");
//extension statement to parse and write
- private static final YangStatementSourceImpl EXTFILE = new YangStatementSourceImpl("/semantic-statement-parser/ext-typedef.yang", false);
- private static final YangStatementSourceImpl EXTUSE = new YangStatementSourceImpl("/semantic-statement-parser/ext-use.yang", false);
+ private static final StatementStreamSource EXTFILE = sourceForResource(
+ "/semantic-statement-parser/ext-typedef.yang");
+ private static final StatementStreamSource EXTUSE = sourceForResource("/semantic-statement-parser/ext-use.yang");
- private static final YangStatementSourceImpl BAR = new YangStatementSourceImpl("/model-new/bar.yang", false);
- private static final YangStatementSourceImpl BAZ = new YangStatementSourceImpl("/model-new/baz.yang", false);
- private static final YangStatementSourceImpl FOO = new YangStatementSourceImpl("/model-new/foo.yang", false);
- private static final YangStatementSourceImpl SUBFOO = new YangStatementSourceImpl("/model-new/subfoo.yang", false);
+ private static final StatementStreamSource BAR = sourceForResource("/model-new/bar.yang");
+ private static final StatementStreamSource BAZ = sourceForResource("/model-new/baz.yang");
+ private static final StatementStreamSource FOO = sourceForResource("/model-new/foo.yang");
+ private static final StatementStreamSource SUBFOO = sourceForResource("/model-new/subfoo.yang");
- private static final YangStatementSourceImpl BAR2 = new YangStatementSourceImpl("/model/bar.yang",false);
- private static final YangStatementSourceImpl BAZ2 = new YangStatementSourceImpl("/model/baz.yang",false);
- private static final YangStatementSourceImpl FOO2 = new YangStatementSourceImpl("/model/foo.yang",false);
- private static final YangStatementSourceImpl SUBFOO2 = new YangStatementSourceImpl("/model/subfoo.yang",false);
+ private static final StatementStreamSource BAR2 = sourceForResource("/model/bar.yang");
+ private static final StatementStreamSource BAZ2 = sourceForResource("/model/baz.yang");
+ private static final StatementStreamSource FOO2 = sourceForResource("/model/foo.yang");
+ private static final StatementStreamSource SUBFOO2 = sourceForResource("/model/subfoo.yang");
@Test
public void readAndParseYangFileTestModel() throws SourceException, ReactorException {
CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
- addSources(reactor, BAZ,FOO,BAR,SUBFOO);
+ reactor.addSources(BAZ,FOO,BAR,SUBFOO);
EffectiveModelContext result = reactor.build();
assertNotNull(result);
}
public void readAndParseYangFileTestModel2() throws SourceException, ReactorException {
CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
- addSources(reactor, BAZ2,FOO2,BAR2,SUBFOO2);
+ reactor.addSources(BAZ2,FOO2,BAR2,SUBFOO2);
EffectiveModelContext result = reactor.build();
assertNotNull(result);
}
@Test
public void readAndParseYangFileTest() throws SourceException, ReactorException {
CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
- addSources(reactor, YANGFILE, SIMPLENODES, IMPORTEDYANGFILE, FOOBAR);
- addSources(reactor, EXTFILE, EXTUSE);
+ reactor.addSources(YANGFILE, SIMPLENODES, IMPORTEDYANGFILE, FOOBAR);
+ reactor.addSources(EXTFILE, EXTUSE);
EffectiveSchemaContext result = reactor.buildEffective();
assertNotNull(result);
}
-
- private static void addSources(final CrossSourceStatementReactor.BuildAction reactor, final StatementStreamSource... sources) {
- for (StatementStreamSource source : sources) {
- reactor.addSource(source);
- }
- }
}
\ No newline at end of file