maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krosenv...@apache.org
Subject svn commit: r1099904 - in /maven/surefire/trunk: maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ surefire-api/src/main/java/org/apache/maven/plugin...
Date Thu, 05 May 2011 18:13:35 GMT
Author: krosenvold
Date: Thu May  5 18:13:34 2011
New Revision: 1099904

URL: http://svn.apache.org/viewvc?rev=1099904&view=rev
Log:
o Further split non-forking and forking invocation

Removed an unused parameter

Modified:
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/TestSetMockReporterFactory.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/plugin/surefire/report/ReporterManagerFactory.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/TestConsoleOutputRunListenerTest.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManagerTest.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTest.java

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java?rev=1099904&r1=1099903&r2=1099904&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
(original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
Thu May  5 18:13:34 2011
@@ -55,6 +55,7 @@ import org.apache.maven.surefire.booter.
 import org.apache.maven.surefire.booter.StartupReportConfiguration;
 import org.apache.maven.surefire.booter.SurefireBooterForkException;
 import org.apache.maven.surefire.booter.SurefireExecutionException;
+import org.apache.maven.surefire.booter.SurefireStarter;
 import org.apache.maven.surefire.report.ReporterConfiguration;
 import org.apache.maven.surefire.suite.RunResult;
 import org.apache.maven.surefire.testset.DirectoryScannerParameters;
@@ -180,10 +181,20 @@ public abstract class AbstractSurefireMo
         ForkConfiguration forkConfiguration = getForkConfiguration();
         summary.reportForkConfiguration( forkConfiguration );
         ClassLoaderConfiguration classLoaderConfiguration = getClassLoaderConfiguration(
forkConfiguration );
-        ForkStarter forkStarter = createForkStarter( provider, forkConfiguration, classLoaderConfiguration
);
         try
         {
-            RunResult result = forkStarter.run();
+            final RunResult result;
+            if ( ForkConfiguration.FORK_NEVER.equals( forkConfiguration.getForkMode() ) )
+            {
+                SurefireStarter surefireStarter =
+                    createInprocessStarter( provider, forkConfiguration, classLoaderConfiguration
);
+                result = surefireStarter.runSuitesInProcess();
+            }
+            else
+            {
+                ForkStarter forkStarter = createForkStarter( provider, forkConfiguration,
classLoaderConfiguration );
+                result = forkStarter.run();
+            }
             summary.registerRunResult( result );
         }
         catch ( SurefireBooterForkException e )
@@ -569,6 +580,19 @@ public abstract class AbstractSurefireMo
                                 getForkedProcessTimeoutInSeconds(), startupReportConfiguration
);
     }
 
+    protected SurefireStarter createInprocessStarter( ProviderInfo provider, ForkConfiguration
forkConfiguration,
+                                                       ClassLoaderConfiguration classLoaderConfiguration
)
+        throws MojoExecutionException, MojoFailureException
+    {
+        StartupConfiguration startupConfiguration =
+            createStartupConfiguration( forkConfiguration, provider, classLoaderConfiguration
);
+        StartupReportConfiguration startupReportConfiguration = getStartupReportConfiguration();
+        ProviderConfiguration providerConfiguration = createProviderConfiguration();
+         return
+            new SurefireStarter( startupConfiguration, providerConfiguration, startupReportConfiguration
);
+
+    }
+
     protected ForkConfiguration getForkConfiguration()
     {
         File tmpDir = getSurefireTempDir();

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java?rev=1099904&r1=1099903&r2=1099904&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
(original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
Thu May  5 18:13:34 2011
@@ -34,7 +34,6 @@ import org.apache.maven.surefire.booter.
 import org.apache.maven.surefire.booter.SurefireBooterForkException;
 import org.apache.maven.surefire.booter.SurefireExecutionException;
 import org.apache.maven.surefire.booter.SurefireReflector;
-import org.apache.maven.surefire.booter.SurefireStarter;
 import org.apache.maven.surefire.booter.SystemPropertyManager;
 import org.apache.maven.surefire.providerapi.SurefireProvider;
 import org.apache.maven.surefire.report.ReporterFactory;
@@ -90,12 +89,7 @@ public class ForkStarter
         final RunResult result;
 
         final String requestedForkMode = forkConfiguration.getForkMode();
-        if ( ForkConfiguration.FORK_NEVER.equals( requestedForkMode ) )
-        {
-            SurefireStarter surefireStarter = new SurefireStarter( startupConfiguration,
providerConfiguration, this.startupReportConfiguration );
-            result = surefireStarter.runSuitesInProcess();
-        }
-        else if ( ForkConfiguration.FORK_ONCE.equals( requestedForkMode ) )
+        if ( ForkConfiguration.FORK_ONCE.equals( requestedForkMode ) )
         {
             result = runSuitesForkOnce();
         }
@@ -114,7 +108,7 @@ public class ForkStarter
         throws SurefireBooterForkException
     {
         final ReporterManagerFactory testSetReporterFactory =
-            new ReporterManagerFactory( Thread.currentThread().getContextClassLoader(), startupReportConfiguration
);
+            new ReporterManagerFactory( startupReportConfiguration );
         try
         {
             return fork( null, providerConfiguration.getProviderProperties(), testSetReporterFactory
);
@@ -149,7 +143,7 @@ public class ForkStarter
         Properties properties = new Properties();
 
         final ReporterManagerFactory testSetReporterFactory =
-            new ReporterManagerFactory( Thread.currentThread().getContextClassLoader(), startupReportConfiguration
);
+            new ReporterManagerFactory( startupReportConfiguration );
         try
         {
             while ( suites.hasNext() )

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/TestSetMockReporterFactory.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/TestSetMockReporterFactory.java?rev=1099904&r1=1099903&r2=1099904&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/TestSetMockReporterFactory.java
(original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/TestSetMockReporterFactory.java
Thu May  5 18:13:34 2011
@@ -33,7 +33,7 @@ public class TestSetMockReporterFactory
 {
     public TestSetMockReporterFactory()
     {
-        super( Thread.currentThread().getContextClassLoader(), StartupReportConfiguration.defaultValue()
);
+        super( StartupReportConfiguration.defaultValue() );
     }
 
     public DirectConsoleReporter createConsoleReporter()

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/plugin/surefire/report/ReporterManagerFactory.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/plugin/surefire/report/ReporterManagerFactory.java?rev=1099904&r1=1099903&r2=1099904&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/plugin/surefire/report/ReporterManagerFactory.java
(original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/plugin/surefire/report/ReporterManagerFactory.java
Thu May  5 18:13:34 2011
@@ -42,16 +42,12 @@ import org.apache.maven.surefire.suite.R
  * <p/>
  * Keeps a centralized count of test run results.
  *
- * TODO: Move out of API module
- *
  * @author Kristian Rosenvold
  */
 public class ReporterManagerFactory
     implements ReporterFactory
 {
 
-    private final ClassLoader surefireClassLoader;
-
     private final ReporterConfiguration reporterConfiguration;
 
     private final RunStatistics globalStats = new RunStatistics();
@@ -60,17 +56,17 @@ public class ReporterManagerFactory
 
     private final StartupReportConfiguration reportConfiguration;
 
-    public ReporterManagerFactory( ClassLoader surefireClassLoader, StartupReportConfiguration
reportConfiguration )
+    public ReporterManagerFactory( StartupReportConfiguration reportConfiguration )
     {
         this.reportConfiguration = reportConfiguration;
         this.reporterConfiguration = getReporterConfiguration(  );
-        this.surefireClassLoader = surefireClassLoader;
         multicastingReporter = new MulticastingReporter( instantiateReports() );
         runStarting();
     }
 
     private ReporterConfiguration getReporterConfiguration( )
     {
+        //noinspection BooleanConstructorCall
         return new ReporterConfiguration( reportConfiguration.getReportsDirectory(), new
Boolean( reportConfiguration.isTrimStackTrace() ));
     }
 

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java?rev=1099904&r1=1099903&r2=1099904&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
(original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
Thu May  5 18:13:34 2011
@@ -224,9 +224,9 @@ public class SurefireReflector
     public Object createReportingReporterFactory( StartupReportConfiguration startupReportConfiguration
)
     {
         Class[] args =
-            new Class[]{ ClassLoader.class, this.startupReportConfiguration };
+            new Class[]{ this.startupReportConfiguration };
         Object src = createStartupReportConfiguration( startupReportConfiguration );
-        Object[] params = new Object[]{ this.surefireClassLoader, src };
+        Object[] params = new Object[]{ src };
         return ReflectionUtils.instantiateObject( ReporterManagerFactory.class.getName(),
args, params,
                                                   surefireClassLoader );
 

Modified: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/TestConsoleOutputRunListenerTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/TestConsoleOutputRunListenerTest.java?rev=1099904&r1=1099903&r2=1099904&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/TestConsoleOutputRunListenerTest.java
(original)
+++ maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/TestConsoleOutputRunListenerTest.java
Thu May  5 18:13:34 2011
@@ -50,8 +50,7 @@ public class TestConsoleOutputRunListene
 
     private ReporterFactory createReporterFactory()
     {
-        ReporterConfiguration reporterConfiguration = getTestReporterConfiguration();
-        return new ReporterManagerFactory( this.getClass().getClassLoader(), StartupReportConfiguration.defaultValue()
);
+        return new ReporterManagerFactory( StartupReportConfiguration.defaultValue() );
     }
 
     public static ReporterConfiguration getTestReporterConfiguration()

Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManagerTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManagerTest.java?rev=1099904&r1=1099903&r2=1099904&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManagerTest.java
(original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManagerTest.java
Thu May  5 18:13:34 2011
@@ -396,8 +396,7 @@ public class ConcurrentReporterManagerTe
 
     private ReporterFactory createReporterFactory()
     {
-        ReporterConfiguration reporterConfiguration = getTestReporterConfiguration();
-        return new ReporterManagerFactory( this.getClass().getClassLoader(), StartupReportConfiguration.defaultNoXml()
);
+        return new ReporterManagerFactory( StartupReportConfiguration.defaultNoXml() );
     }
 
     public static ReporterConfiguration getTestReporterConfiguration()

Modified: maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTest.java?rev=1099904&r1=1099903&r2=1099904&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTest.java
(original)
+++ maven/surefire/trunk/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/MavenSurefireJUnit47RunnerTest.java
Thu May  5 18:13:34 2011
@@ -117,10 +117,8 @@ public class MavenSurefireJUnit47RunnerT
     public void testSurefireShouldBeAbleToReportRunStatusEvenWithFailingTests()
         throws Exception
     {
-        ReporterConfiguration reporterConfiguration = ConcurrentReporterManagerTest.getTestReporterConfiguration();
-
         ReporterFactory reporterManagerFactory =
-            new ReporterManagerFactory( this.getClass().getClassLoader(), StartupReportConfiguration.defaultNoXml()
);
+            new ReporterManagerFactory( StartupReportConfiguration.defaultNoXml() );
 
         final HashMap<String, TestSet> classMethodCounts = new HashMap<String, TestSet>();
         RunListener reporter = ConcurrentReporterManager.createInstance( classMethodCounts,
reporterManagerFactory,



Mime
View raw message