X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fstmt%2FMoreRevisionsTest.java;h=f18c46d7694822918b0e24424a85c4ff9c235d1f;hb=b79c54e7f34511c604518c70290f02b2be8ee0f6;hp=1603262daab7acadd7bbd29f9f9cec42e0249c4c;hpb=2243372d01cadb95dd56d11bdbe3576299c198b9;p=yangtools.git diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/MoreRevisionsTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/MoreRevisionsTest.java index 1603262daa..f18c46d769 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/MoreRevisionsTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/MoreRevisionsTest.java @@ -12,8 +12,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource; -import java.io.FileNotFoundException; import java.net.URI; import java.net.URISyntaxException; import java.text.ParseException; @@ -35,49 +35,41 @@ import org.opendaylight.yangtools.yang.model.api.TypeDefinition; import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil; import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; +import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource; import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor; 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 MoreRevisionsTest { - private static final YangStatementSourceImpl REVFILE = new YangStatementSourceImpl( - "/semantic-statement-parser/revisions/more-revisions-test.yang", - false); + private static final StatementStreamSource REVFILE = sourceForResource( + "/semantic-statement-parser/revisions/more-revisions-test.yang"); - private static final YangStatementSourceImpl TED_20130712 = new YangStatementSourceImpl( - "/semantic-statement-parser/two-revisions/ted@2013-07-12.yang", - false); + private static final StatementStreamSource TED_20130712 = sourceForResource( + "/semantic-statement-parser/two-revisions/ted@2013-07-12.yang"); - private static final YangStatementSourceImpl TED_20131021 = new YangStatementSourceImpl( - "/semantic-statement-parser/two-revisions/ted@2013-10-21.yang", - false); + private static final StatementStreamSource TED_20131021 = sourceForResource( + "/semantic-statement-parser/two-revisions/ted@2013-10-21.yang"); - private static final YangStatementSourceImpl IETF_TYPES = new YangStatementSourceImpl( - "/ietf/ietf-inet-types@2010-09-24.yang", false); + private static final StatementStreamSource IETF_TYPES = sourceForResource( + "/ietf/ietf-inet-types@2010-09-24.yang"); - private static final YangStatementSourceImpl NETWORK_TOPOLOGY_20130712 = new YangStatementSourceImpl( - "/ietf/network-topology@2013-07-12.yang", false); + private static final StatementStreamSource NETWORK_TOPOLOGY_20130712 = sourceForResource( + "/ietf/network-topology@2013-07-12.yang"); - private static final YangStatementSourceImpl NETWORK_TOPOLOGY_20131021 = new YangStatementSourceImpl( - "/ietf/network-topology@2013-10-21.yang", false); + private static final StatementStreamSource NETWORK_TOPOLOGY_20131021 = sourceForResource( + "/ietf/network-topology@2013-10-21.yang"); - private static final YangStatementSourceImpl ISIS_20130712 = new YangStatementSourceImpl( - "/semantic-statement-parser/two-revisions/isis-topology@2013-07-12.yang", - false); + private static final StatementStreamSource ISIS_20130712 = sourceForResource( + "/semantic-statement-parser/two-revisions/isis-topology@2013-07-12.yang"); - private static final YangStatementSourceImpl ISIS_20131021 = new YangStatementSourceImpl( - "/semantic-statement-parser/two-revisions/isis-topology@2013-10-21.yang", - false); + private static final StatementStreamSource ISIS_20131021 = sourceForResource( + "/semantic-statement-parser/two-revisions/isis-topology@2013-10-21.yang"); - private static final YangStatementSourceImpl L3_20130712 = new YangStatementSourceImpl( - "/semantic-statement-parser/two-revisions/l3-unicast-igp-topology@2013-07-12.yang", - false); + private static final StatementStreamSource L3_20130712 = sourceForResource( + "/semantic-statement-parser/two-revisions/l3-unicast-igp-topology@2013-07-12.yang"); - private static final YangStatementSourceImpl L3_20131021 = new YangStatementSourceImpl( - "/semantic-statement-parser/two-revisions/l3-unicast-igp-topology@2013-10-21.yang", - false); + private static final StatementStreamSource L3_20131021 = sourceForResource( + "/semantic-statement-parser/two-revisions/l3-unicast-igp-topology@2013-10-21.yang"); @Test public void readAndParseYangFileTest() throws SourceException, @@ -85,7 +77,7 @@ public class MoreRevisionsTest { CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR .newBuild(); reactor.addSource(REVFILE); - EffectiveSchemaContext result = reactor.buildEffective(); + SchemaContext result = reactor.buildEffective(); assertNotNull(result); final Module moduleByName = result.getModules().iterator().next(); final QNameModule qNameModule = moduleByName.getQNameModule(); @@ -100,7 +92,7 @@ public class MoreRevisionsTest { reactor.addSources(TED_20130712, TED_20131021, IETF_TYPES); - EffectiveSchemaContext result = reactor.buildEffective(); + SchemaContext result = reactor.buildEffective(); assertNotNull(result); } @@ -113,7 +105,7 @@ public class MoreRevisionsTest { reactor.addSources(NETWORK_TOPOLOGY_20130712, NETWORK_TOPOLOGY_20131021, IETF_TYPES); - EffectiveSchemaContext result = reactor.buildEffective(); + SchemaContext result = reactor.buildEffective(); assertNotNull(result); Set modules = result.getModules(); @@ -132,13 +124,12 @@ public class MoreRevisionsTest { ISIS_20131021, L3_20130712, L3_20131021, IETF_TYPES, NETWORK_TOPOLOGY_20130712, NETWORK_TOPOLOGY_20131021); - EffectiveSchemaContext result = reactor.buildEffective(); + SchemaContext result = reactor.buildEffective(); assertNotNull(result); } @Test - public void multipleRevisionsTest() throws SourceException, - ReactorException, FileNotFoundException, URISyntaxException { + public void multipleRevisionsTest() throws Exception { for (int i = 0; i < 100; i++) { SchemaContext context = StmtTestUtils .parseYangSources("/semantic-statement-parser/multiple-revisions"); @@ -147,8 +138,7 @@ public class MoreRevisionsTest { } @Test - public void multipleRevisionsFullTest() throws SourceException, - ReactorException, FileNotFoundException, URISyntaxException, + public void multipleRevisionsFullTest() throws Exception, ParseException { for (int i = 0; i < 100; i++) { SchemaContext context = StmtTestUtils @@ -159,8 +149,7 @@ public class MoreRevisionsTest { } } - private static void checkContentFullTest(final SchemaContext context) throws ParseException, - URISyntaxException { + private static void checkContentFullTest(final SchemaContext context) throws ParseException, URISyntaxException { String yangTypesNSStr = "urn:ietf:params:xml:ns:yang:ietf-yang-types"; URI yangTypesNS = new URI(yangTypesNSStr); @@ -248,12 +237,10 @@ public class MoreRevisionsTest { } @Test - public void multipleRevisionsSimpleTest() throws SourceException, - ReactorException, FileNotFoundException, URISyntaxException, - ParseException { + public void multipleRevisionsSimpleTest() throws Exception { for (int i = 0; i < 1000; i++) { - SchemaContext context = StmtTestUtils - .parseYangSources("/semantic-statement-parser/multiple-revisions/simple"); + SchemaContext context = StmtTestUtils.parseYangSources( + "/semantic-statement-parser/multiple-revisions/simple"); assertNotNull(context); assertEquals(5, context.getModules().size()); checkContentSimpleTest(context);