Refactored yang-maven-plugin.
[controller.git] / opendaylight / sal / yang-prototype / code-generator / maven-yang-plugin-it / src / test / java / org / opendaylight / controller / yang2sources / plugin / it / YangToSourcesPluginTest.java
index 4b41cfd9441705ef07ae23685c7c272afeace5f9..75d6ee5d7d5ffb1898cb950d37af25203d2e0e04 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.controller.yang2sources.plugin.it;
 
 import static org.junit.Assert.*;
-import static org.junit.matchers.JUnitMatchers.*;
+import static org.junit.matchers.JUnitMatchers.containsString;
 
 import java.io.File;
 
@@ -38,6 +38,7 @@ public class YangToSourcesPluginTest {
     public void testCorrect() throws VerificationException {
         Verifier v = setUp("Correct/", false);
         verifyCorrectLog(v);
+
     }
 
     static void verifyCorrectLog(Verifier v) throws VerificationException {
@@ -45,6 +46,8 @@ public class YangToSourcesPluginTest {
         v.verifyTextInLog("[INFO] yang-to-sources: yang files parsed from");
         v.verifyTextInLog("[INFO] yang-to-sources: Code generator instantiated from org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl");
         v.verifyTextInLog("[INFO] yang-to-sources: Sources generated by org.opendaylight.controller.yang2sources.spi.CodeGeneratorTestImpl: null");
+        v.verifyTextInLog("[INFO] yang-to-sources: Resource provider instantiated from org.opendaylight.controller.yang2sources.spi.ResourceProviderTestImpl");
+        v.verifyTextInLog("[INFO] yang-to-sources: Resource provider org.opendaylight.controller.yang2sources.spi.ResourceProviderTestImpl call successful");
     }
 
     @Test
@@ -83,8 +86,34 @@ public class YangToSourcesPluginTest {
                 + project).getAbsolutePath());
         if (ignoreF)
             verifier.addCliOption("-fn");
-        verifier.executeGoal("generate-resources");
+        verifier.executeGoal("generate-sources");
         return verifier;
     }
 
+    @Test
+    public void testNoGeneratorsResources() throws VerificationException {
+        Verifier v = YangToSourcesPluginTest.setUp("NoGenerators_resources/",
+                false);
+        v.verifyErrorFreeLog();
+        v.verifyTextInLog("[WARNING] yang-to-sources: No resource provider classes provided");
+    }
+
+    @Test
+    public void testUnknownGeneratorResources() throws VerificationException {
+        Verifier v = YangToSourcesPluginTest.setUp(
+                "UnknownGenerator_resources/", true);
+        v.verifyTextInLog("[ERROR] yang-to-sources: Unable to provide resources with unknown resource provider");
+        v.verifyTextInLog("java.lang.ClassNotFoundException: unknown");
+        v.verifyTextInLog("[INFO] yang-to-sources: Resource provider instantiated from org.opendaylight.controller.yang2sources.spi.ResourceProviderTestImpl");
+        v.verifyTextInLog("[INFO] yang-to-sources: Resource provider org.opendaylight.controller.yang2sources.spi.ResourceProviderTestImpl call successful");
+        v.verifyTextInLog("[ERROR] yang-to-sources: One or more code resource provider failed, including failed list(resourceProviderClass=exception) {unknown=java.lang.ClassNotFoundException}");
+    }
+
+    @Test
+    public void testNoOutputDir() throws VerificationException {
+        Verifier v = YangToSourcesPluginTest.setUp("NoOutputDir/",
+                false);
+        verifyCorrectLog(v);
+    }
+
 }