Bug 4656: Yang parser does not determine configuration true or false properly
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / test / IncludeResolutionTest.java
index f44189fb7f4a9af623741a1af3ff0b9a1055b639..49236cffa67e12e051a924143467559b55e1241c 100644 (file)
@@ -13,22 +13,30 @@ import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 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 IncludeTestStatementSource ROOT = new IncludeTestStatementSource(false,"root-module",null, "submodule-1");
-    private static final IncludeTestStatementSource SUBMODULE1 = new IncludeTestStatementSource(true,"submodule-1","root-module", "submodule-2");
-    private static final IncludeTestStatementSource SUBMODULE2 = new IncludeTestStatementSource(true,"submodule-2", "root-module");
-    private static final IncludeTestStatementSource ERROR_MODULE = new IncludeTestStatementSource(false,"error-module", null, "foo");
-    private static final IncludeTestStatementSource ERROR_SUBMODULE = new IncludeTestStatementSource(true,"error-submodule", "root-module", "foo");
+    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 YangStatementSourceImpl MISSING_PARENT_MODULE = new YangStatementSourceImpl(
+            "/semantic-statement-parser/include-arg-parsing/missing-parent.yang", false);
 
-    private static final IncludeTestStatementSource MISSING_PARENT_MODULE = new IncludeTestStatementSource(true,"missing-parent", "foo");
     @Test
     public void includeTest() throws SourceException, ReactorException {
         BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        addSources(reactor,ROOT,SUBMODULE1,SUBMODULE2);
+        addSources(reactor, ROOT, SUBMODULE1, SUBMODULE2);
         EffectiveModelContext result = reactor.build();
         assertNotNull(result);
     }
@@ -36,13 +44,13 @@ public class IncludeResolutionTest {
     @Test
     public void missingIncludedSourceTest() throws SourceException {
         BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        addSources(reactor,ERROR_MODULE);
+        addSources(reactor, ERROR_MODULE);
         try {
             reactor.build();
-            fail("reactor.process should fail doe to misssing included source");
+            fail("reactor.process should fail due to missing included source");
         } catch (ReactorException e) {
             assertTrue(e instanceof SomeModifiersUnresolvedException);
-            assertEquals(ModelProcessingPhase.SOURCE_LINKAGE,e.getPhase());
+            assertEquals(ModelProcessingPhase.SOURCE_LINKAGE, e.getPhase());
             log.info(e.getMessage());
         }
 
@@ -51,37 +59,34 @@ public class IncludeResolutionTest {
     @Test
     public void missingIncludedSourceTest2() throws SourceException {
         BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        addSources(reactor,ERROR_SUBMODULE);
+        addSources(reactor, ERROR_SUBMODULE);
         try {
             reactor.build();
-            fail("reactor.process should fail doe to misssing included source");
+            fail("reactor.process should fail due to missing included source");
         } catch (ReactorException e) {
             assertTrue(e instanceof SomeModifiersUnresolvedException);
-            assertEquals(ModelProcessingPhase.SOURCE_LINKAGE,e.getPhase());
+            assertEquals(ModelProcessingPhase.SOURCE_LINKAGE, e.getPhase());
             log.info(e.getMessage());
         }
 
     }
 
-    //@Test
+    @Test
     public void missingIncludedSourceTest3() throws SourceException, ReactorException {
         BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        addSources(reactor,MISSING_PARENT_MODULE);
+        addSources(reactor, MISSING_PARENT_MODULE);
         try {
-            EffectiveModelContext build = reactor.build();
-            //fail("reactor.process should fail doe to misssing belongsTo source");
+            reactor.build();
+            fail("reactor.process should fail due to missing belongsTo source");
         } catch (ReactorException e) {
-            //assertTrue(e instanceof SomeModifiersUnresolvedException);
-            //assertEquals(ModelProcessingPhase.SourceLinkage,e.getPhase());
-            throw(e);
+            log.info(e.getMessage());
         }
 
     }
 
-    private static void addSources(final BuildAction reactor, final IncludeTestStatementSource... sources) {
-        for(IncludeTestStatementSource source : sources) {
+    private static void addSources(final BuildAction reactor, final YangStatementSourceImpl... sources) {
+        for (YangStatementSourceImpl source : sources) {
             reactor.addSource(source);
         }
     }
-
 }