BUG-7052: extract SimpleSchemaContext
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / IncludeResolutionTest.java
index 745f71f22d9403fdad6bb1a6fb740e68a6ce6e95..40f7f9238887064af71ce3124af2b9d5db9aaf11 100644 (file)
@@ -12,39 +12,41 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
+import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
+
 import java.util.logging.Logger;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
 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.BuildAction;
 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;
 
 public class IncludeResolutionTest {
 
     private static final Logger log = Logger.getLogger(IncludeResolutionTest.class.getName());
 
-    private static final YangStatementSourceImpl ROOT = new YangStatementSourceImpl(
-            "/semantic-statement-parser/include-arg-parsing/root-module.yang", false);
-    private static final YangStatementSourceImpl SUBMODULE1 = new YangStatementSourceImpl(
-            "/semantic-statement-parser/include-arg-parsing/submodule-1.yang", false);
-    private static final YangStatementSourceImpl SUBMODULE2 = new YangStatementSourceImpl(
-            "/semantic-statement-parser/include-arg-parsing/submodule-2.yang", false);
-    private static final YangStatementSourceImpl ERROR_MODULE = new YangStatementSourceImpl(
-            "/semantic-statement-parser/include-arg-parsing/error-module.yang", false);
-    private static final YangStatementSourceImpl ERROR_SUBMODULE = new YangStatementSourceImpl(
-            "/semantic-statement-parser/include-arg-parsing/error-submodule.yang", false);
+    private static final StatementStreamSource ROOT = sourceForResource(
+            "/semantic-statement-parser/include-arg-parsing/root-module.yang");
+    private static final StatementStreamSource SUBMODULE1 = sourceForResource(
+            "/semantic-statement-parser/include-arg-parsing/submodule-1.yang");
+    private static final StatementStreamSource SUBMODULE2 = sourceForResource(
+            "/semantic-statement-parser/include-arg-parsing/submodule-2.yang");
+    private static final StatementStreamSource ERROR_MODULE = sourceForResource(
+            "/semantic-statement-parser/include-arg-parsing/error-module.yang");
+    private static final StatementStreamSource ERROR_SUBMODULE = sourceForResource(
+            "/semantic-statement-parser/include-arg-parsing/error-submodule.yang");
 
-    private static final YangStatementSourceImpl MISSING_PARENT_MODULE = new YangStatementSourceImpl(
-            "/semantic-statement-parser/include-arg-parsing/missing-parent.yang", false);
+    private static final StatementStreamSource MISSING_PARENT_MODULE = sourceForResource(
+            "/semantic-statement-parser/include-arg-parsing/missing-parent.yang");
 
     @Test
     public void includeTest() throws SourceException, ReactorException {
         BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        addSources(reactor, ROOT, SUBMODULE1, SUBMODULE2);
+        reactor.addSources(ROOT, SUBMODULE1, SUBMODULE2);
         EffectiveModelContext result = reactor.build();
         assertNotNull(result);
     }
@@ -52,7 +54,7 @@ public class IncludeResolutionTest {
     @Test
     public void missingIncludedSourceTest() throws SourceException {
         BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        addSources(reactor, ERROR_MODULE);
+        reactor.addSources(ERROR_MODULE);
         try {
             reactor.build();
             fail("reactor.process should fail due to missing included source");
@@ -67,7 +69,7 @@ public class IncludeResolutionTest {
     @Test
     public void missingIncludedSourceTest2() throws SourceException {
         BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        addSources(reactor, ERROR_SUBMODULE);
+        reactor.addSources(ERROR_SUBMODULE);
         try {
             reactor.build();
             fail("reactor.process should fail due to missing included source");
@@ -82,7 +84,7 @@ public class IncludeResolutionTest {
     @Test
     public void missingIncludedSourceTest3() throws SourceException, ReactorException {
         BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        addSources(reactor, MISSING_PARENT_MODULE);
+        reactor.addSources(MISSING_PARENT_MODULE);
         try {
             reactor.build();
             fail("reactor.process should fail due to missing belongsTo source");
@@ -91,10 +93,4 @@ public class IncludeResolutionTest {
         }
 
     }
-
-    private static void addSources(final BuildAction reactor, final YangStatementSourceImpl... sources) {
-        for (YangStatementSourceImpl source : sources) {
-            reactor.addSource(source);
-        }
-    }
 }