You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2006/11/16 01:10:20 UTC

svn commit: r475501 - in /incubator/tuscany/java/sca/plugins/plugin.itest: ./ src/main/java/org/apache/tuscany/sca/plugin/itest/ src/main/resources/META-INF/tuscany/

Author: rfeng
Date: Wed Nov 15 16:10:19 2006
New Revision: 475501

URL: http://svn.apache.org/viewvc?view=rev&rev=475501
Log:
Fix the ResoureHost registration
Improve the plugin to produce more information about the test results

Modified:
    incubator/tuscany/java/sca/plugins/plugin.itest/pom.xml
    incubator/tuscany/java/sca/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyITestMojo.java
    incubator/tuscany/java/sca/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyStartMojo.java
    incubator/tuscany/java/sca/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyStopMojo.java
    incubator/tuscany/java/sca/plugins/plugin.itest/src/main/resources/META-INF/tuscany/embeddedMaven.scdl

Modified: incubator/tuscany/java/sca/plugins/plugin.itest/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/plugins/plugin.itest/pom.xml?view=diff&rev=475501&r1=475500&r2=475501
==============================================================================
--- incubator/tuscany/java/sca/plugins/plugin.itest/pom.xml (original)
+++ incubator/tuscany/java/sca/plugins/plugin.itest/pom.xml Wed Nov 15 16:10:19 2006
@@ -43,7 +43,7 @@
             <groupId>org.apache.maven.surefire</groupId>
             <artifactId>surefire-junit</artifactId>
             <version>2.0</version>
-            <scope>runtime</scope>
+            <scope>compile</scope>
         </dependency>
 
         <dependency>

Modified: incubator/tuscany/java/sca/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyITestMojo.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyITestMojo.java?view=diff&rev=475501&r1=475500&r2=475501
==============================================================================
--- incubator/tuscany/java/sca/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyITestMojo.java (original)
+++ incubator/tuscany/java/sca/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyITestMojo.java Wed Nov 15 16:10:19 2006
@@ -21,14 +21,17 @@
 import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Properties;
 
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.surefire.Surefire;
-import org.apache.maven.surefire.testset.TestSetFailedException;
+import org.apache.maven.surefire.junit.JUnitDirectoryTestSuite;
 import org.apache.maven.surefire.report.BriefFileReporter;
 import org.apache.maven.surefire.report.ReporterException;
+import org.apache.maven.surefire.report.ReporterManager;
+import org.apache.maven.surefire.suite.SurefireTestSuite;
+import org.apache.maven.surefire.testset.TestSetFailedException;
 
 /**
  * @version $Rev$ $Date$
@@ -42,15 +45,17 @@
     private File reportsDirectory;
 
     /**
-     * Whether to trim the stack trace in the reports to just the lines within the test, or show the full trace.
-     *
+     * Whether to trim the stack trace in the reports to just the lines within
+     * the test, or show the full trace.
+     * 
      * @parameter expression="${trimStackTrace}" default-value="true"
      */
     private boolean trimStackTrace;
 
     /**
-     * The directory containing generated test classes of the project being tested.
-     *
+     * The directory containing generated test classes of the project being
+     * tested.
+     * 
      * @parameter expression="${project.build.testOutputDirectory}"
      * @required
      */
@@ -67,7 +72,7 @@
     private List excludes = new ArrayList();
 
     public void execute() throws MojoExecutionException, MojoFailureException {
-        System.out.println("Executing tests");
+        getLog().info("Executing tests...");
 
         boolean success = runSurefire();
         if (!success) {
@@ -77,24 +82,49 @@
     }
 
     public boolean runSurefire() throws MojoExecutionException {
-        Surefire surefire = new Surefire();
-        ClassLoader surefireClassLoader = surefire.getClass().getClassLoader();
-
-        List reports = new ArrayList();
-        reports.add(new Object[]{BriefFileReporter.class.getName(),
-            new Object[]{reportsDirectory, trimStackTrace}});
-
-        List testSuites = new ArrayList();
-        testSuites.add(new Object[]{"org.apache.maven.surefire.junit.JUnitDirectoryTestSuite",
-            new Object[]{testClassesDirectory, includes, excludes}});
-
         ClassLoader testsClassLoader = TuscanyStartMojo.foo.get();
         try {
-            return surefire.run(reports, testSuites, surefireClassLoader, testsClassLoader);
+            Properties status = new Properties();
+            boolean success = run(testsClassLoader, status);
+            getLog().info("Test results: "+status);
+            return success;
         } catch (ReporterException e) {
             throw new MojoExecutionException(e.getMessage(), e);
         } catch (TestSetFailedException e) {
             throw new MojoExecutionException(e.getMessage(), e);
         }
     }
+
+    public boolean run(ClassLoader testsClassLoader, Properties status) throws ReporterException,
+        TestSetFailedException {
+        List reports = new ArrayList();
+        reports.add(new BriefFileReporter(reportsDirectory, trimStackTrace));
+        ReporterManager reporterManager = new ReporterManager(reports);
+        reporterManager.initResultsFromProperties(status);
+
+        List suites = new ArrayList();
+
+        int totalTests = 0;
+        SurefireTestSuite suite =
+            new JUnitDirectoryTestSuite(testClassesDirectory, (ArrayList)includes, (ArrayList)excludes);
+        suite.locateTestSets(testsClassLoader);
+
+        int testCount = suite.getNumTests();
+        if (testCount > 0) {
+            suites.add(suite);
+            totalTests += testCount;
+        }
+        reporterManager.runStarting(totalTests);
+
+        if (totalTests == 0) {
+            reporterManager.writeMessage("There are no tests to run.");
+        } else {
+            suite.execute(reporterManager, testsClassLoader);
+        }
+
+        reporterManager.runCompleted();
+        reporterManager.updateResultsProperties(status);
+        return reporterManager.getNumErrors() == 0 && reporterManager.getNumFailures() == 0;
+    }
+
 }

Modified: incubator/tuscany/java/sca/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyStartMojo.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyStartMojo.java?view=diff&rev=475501&r1=475500&r2=475501
==============================================================================
--- incubator/tuscany/java/sca/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyStartMojo.java (original)
+++ incubator/tuscany/java/sca/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyStartMojo.java Wed Nov 15 16:10:19 2006
@@ -60,7 +60,7 @@
     static ThreadLocal<ClassLoader> foo = new ThreadLocal<ClassLoader>();
 
     public void execute() throws MojoExecutionException, MojoFailureException {
-        System.out.println("Starting Tuscany!");
+        getLog().info("Starting Tuscany...");
 
         ClassLoader hostClassLoader = getClass().getClassLoader();
         if (systemScdl == null) {

Modified: incubator/tuscany/java/sca/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyStopMojo.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyStopMojo.java?view=diff&rev=475501&r1=475500&r2=475501
==============================================================================
--- incubator/tuscany/java/sca/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyStopMojo.java (original)
+++ incubator/tuscany/java/sca/plugins/plugin.itest/src/main/java/org/apache/tuscany/sca/plugin/itest/TuscanyStopMojo.java Wed Nov 15 16:10:19 2006
@@ -29,6 +29,6 @@
  */
 public class TuscanyStopMojo extends AbstractMojo {
     public void execute() throws MojoExecutionException, MojoFailureException {
-        System.out.println("Stopping Tuscany!");
+        getLog().info("Stopping Tuscany...");
     }
 }

Modified: incubator/tuscany/java/sca/plugins/plugin.itest/src/main/resources/META-INF/tuscany/embeddedMaven.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/plugins/plugin.itest/src/main/resources/META-INF/tuscany/embeddedMaven.scdl?view=diff&rev=475501&r1=475500&r2=475501
==============================================================================
--- incubator/tuscany/java/sca/plugins/plugin.itest/src/main/resources/META-INF/tuscany/embeddedMaven.scdl (original)
+++ incubator/tuscany/java/sca/plugins/plugin.itest/src/main/resources/META-INF/tuscany/embeddedMaven.scdl Wed Nov 15 16:10:19 2006
@@ -70,6 +70,11 @@
         <system:implementation.system class="org.apache.tuscany.core.builder.WirePostProcessorRegistryImpl"/>
     </component>
     
+    <!-- Resource host registry -->
+    <component name="resourceHostRegistry">
+        <system:implementation.system class="org.apache.tuscany.core.services.host.DelegatingResourceHostRegistry"/>
+    </component>
+    
     <!-- Default scopes -->
     <component name="scope.module">
         <system:implementation.system class="org.apache.tuscany.core.component.scope.ModuleScopeObjectFactory"/>



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org