Author: stephenc
Date: Tue Jan 12 08:16:55 2010
New Revision: 898237

URL: http://svn.apache.org/viewvc?rev=898237&view=rev
Log:
[SUREFIRE-596] Merge changes from m-surefire-p to m-failsafe-p

o The sooner I do the refactoring of the common code, the better

Modified:
    
maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
    
maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
    
maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java

Modified: 
maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java?rev=898237&r1=898236&r2=898237&view=diff
==============================================================================
--- 
maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
 (original)
+++ 
maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
 Tue Jan 12 08:16:55 2010
@@ -20,9 +20,15 @@
  */
 
 import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.FileOutputStream;
+import java.io.Writer;
+import java.io.OutputStreamWriter;
+import java.io.BufferedOutputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collections;               
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -39,6 +45,7 @@
 import org.apache.maven.artifact.resolver.ArtifactResolver;
 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
 import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
+import org.apache.maven.artifact.versioning.ArtifactVersion;
 import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
 import 
org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
 import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
@@ -59,29 +66,13 @@
 import org.apache.maven.surefire.report.FileReporter;
 import org.apache.maven.surefire.report.ForkingConsoleReporter;
 import org.apache.maven.surefire.report.XMLReporter;
+import org.apache.maven.toolchain.Toolchain;
+import org.apache.maven.toolchain.ToolchainManager;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.FileUtils;
 
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.FileOutputStream;
-import java.io.Writer;
-import java.io.OutputStreamWriter;
-import java.io.BufferedOutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
 
-import org.apache.maven.execution.MavenSession;
-import org.apache.maven.toolchain.Toolchain;
-import org.apache.maven.toolchain.ToolchainManager;
 import 
org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 import 
org.apache.maven.surefire.failsafe.model.io.xpp3.FailsafeSummaryXpp3Writer;
 import org.apache.maven.surefire.failsafe.model.FailsafeSummary;
@@ -119,12 +110,11 @@
     private boolean skipITs;
 
     /**
-     * DEPRECATED This old parameter is just like skipTests, but bound to the 
old property maven.test.skip.exec.
-     * Use -DskipTests instead; it's shorter.
+     * This old parameter is just like skipTests, but bound to the old 
property maven.test.skip.exec.
      *
+     * @deprecated Use -DskipTests instead.
      * @parameter expression="${maven.test.skip.exec}"
      * @since 2.3
-     * @deprecated
      */
     private boolean skipExec;
 
@@ -249,7 +239,7 @@
 
     /**
      * List of System properties to pass to the JUnit tests.
-     * @deprecated use systemPropertyVariables instead
+     * @deprecated Use systemPropertyVariables instead.
      * @parameter
      */
     private Properties systemProperties;
@@ -468,8 +458,8 @@
     private String perCoreThreadCount;
 
     /**
-     * (junitcore only) Indicates that the thread pool will be unlimited. 
paralell setting and the actual number of classes/methods
-     * will decide. Setting this to true effectively disables 
perCoreThreadCount and  threadCount
+     * (junitcore only) Indicates that the thread pool will be unlimited. The 
parallel parameter and the actual number of classes/methods
+     * will decide. Setting this to true effectively disables 
perCoreThreadCount and threadCount.
      *
      * @parameter expression="${useUnlimitedThreads}"
      * @since 2.5
@@ -480,7 +470,7 @@
      * methods that depend on each other, which will be run in the same thread 
in order to respect their order of
      * execution.
      *
-     * JUNIT4.6 Values are classes/methods/both to run in separate threads, as 
controlled by threadCount.
+     * In JUnit 4.7 the values are classes/methods/both to run in separate 
threads, as controlled by threadCount.
      *
      * @parameter expression="${parallel}"
      * @todo test how this works with forking, and console/file output 
parallelism
@@ -511,7 +501,7 @@
     private ArtifactFactory artifactFactory;
 
     /**
-     * The plugin remote repositories declared in the pom.
+     * The plugin remote repositories declared in the POM.
      *
      * @parameter expression="${project.pluginArtifactRepositories}"
      * @since 2.2
@@ -525,8 +515,6 @@
      */
     private ArtifactMetadataSource metadataSource;
 
-    
-    
     private static final String BRIEF_REPORT_FORMAT = "brief";
 
     private static final String PLAIN_REPORT_FORMAT = "plain";
@@ -605,8 +593,8 @@
 
     /** @component */
     private ToolchainManager toolchainManager;
-    
-    
+
+
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
@@ -727,6 +715,10 @@
         }
     }
 
+    private boolean isAnyConcurrencySelected(){
+       return this.parallel != null && this.parallel.trim().length() > 0; 
+    }
+    
     /**
      * Converts old TestNG configuration parameters over to new properties 
based configuration
      * method. (if any are defined the old way)
@@ -762,9 +754,9 @@
     private boolean isJunit47Compatible(Artifact artifact) throws 
MojoExecutionException {
         return isWithinVersionSpec(artifact, "[4.7,)");
     }
-    
-    private boolean isJunit40to46(Artifact artifact)  throws 
MojoExecutionException {
-        return isWithinVersionSpec(artifact, "[4.0,4.7)");
+
+    private boolean isAnyJunit4(Artifact artifact)  throws 
MojoExecutionException {
+        return isWithinVersionSpec(artifact, "[4.0,)");
     }
 
     private boolean isWithinVersionSpec(Artifact artifact, String versionSpec) 
throws MojoExecutionException {
@@ -846,15 +838,18 @@
                 // The plugin uses a JDK based profile to select the right 
testng. We might be explicity using a
                 // different one since its based on the source level, not the 
JVM. Prune using the filter.
                 addProvider( surefireBooter, "surefire-testng", 
surefireArtifact.getBaseVersion(), testNgArtifact );
-            }
-            else if ( junitArtifact != null && isJunit47Compatible( 
junitArtifact ) )
-            {
-                convertJunitCoreParameters();
-                addProvider( surefireBooter, "surefire-junit47", 
surefireArtifact.getBaseVersion(), null );
-            }
-            else if ( junitArtifact != null && isJunit40to46( junitArtifact ) )
+            } 
+            else if ( junitArtifact != null && isAnyJunit4( junitArtifact ) )
             {
-                addProvider( surefireBooter, "surefire-junit4", 
surefireArtifact.getBaseVersion(), null );
+                    if ( isAnyConcurrencySelected() && isJunit47Compatible( 
junitArtifact ) )
+                    {
+                        convertJunitCoreParameters();
+                        addProvider( surefireBooter, "surefire-junit47", 
surefireArtifact.getBaseVersion(), null );
+                    } 
+                    else 
+                    {
+                        addProvider( surefireBooter, "surefire-junit4", 
surefireArtifact.getBaseVersion(), null );
+                    }
             }
             else
             {
@@ -951,16 +946,16 @@
             else
             {
                 String junitDirectoryTestSuite;
-                if ( isJunit47Compatible( junitArtifact ) )
+                if (  isAnyConcurrencySelected() && isJunit47Compatible( 
junitArtifact ) )
                 {
                     junitDirectoryTestSuite = 
"org.apache.maven.surefire.junitcore.JUnitCoreDirectoryTestSuite";
-                    getLog().warn( "Props are" + properties.toString() );
+                    getLog().info( "Concurrency config is " + 
properties.toString() );
                     surefireBooter.addTestSuite( junitDirectoryTestSuite,
                                                  new 
Object[]{testClassesDirectory, includes, excludes, properties} );
                 }
                 else
                 {
-                    if ( isJunit40to46( junitArtifact ) )
+                    if ( isAnyJunit4( junitArtifact ) )
                     {
                         junitDirectoryTestSuite = 
"org.apache.maven.surefire.junit4.JUnit4DirectoryTestSuite";
                     }
@@ -969,7 +964,6 @@
                         // fall back to JUnit, which also contains POJO 
support. Also it can run
                         // classes compiled against JUnit since it has a 
dependency on JUnit itself.
                         junitDirectoryTestSuite = 
"org.apache.maven.surefire.junit.JUnitDirectoryTestSuite";
-                        junitDirectoryTestSuite = 
"org.apache.maven.surefire.junit.JUnitDirectoryTestSuite";
                     }
                     surefireBooter.addTestSuite( junitDirectoryTestSuite,
                                                  new 
Object[]{testClassesDirectory, includes, excludes} );
@@ -1142,7 +1136,7 @@
 
         return surefireBooter;
     }
-    
+
     private void showMap( Map map, String setting )
     {
         for ( Iterator i = map.keySet().iterator(); i.hasNext(); )
@@ -1339,12 +1333,12 @@
     private Toolchain getToolchain()
     {
         Toolchain tc = null;
-        
+
         if ( toolchainManager != null )
         {
             tc = toolchainManager.getToolchainFromBuildContext( "jdk", session 
);
         }
-        
+
         return tc;
     }
 }

Modified: 
maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java?rev=898237&r1=898236&r2=898237&view=diff
==============================================================================
--- 
maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
 (original)
+++ 
maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/VerifyMojo.java
 Tue Jan 12 08:16:55 2010
@@ -20,6 +20,11 @@
  */
 
 import java.io.File;
+import java.io.IOException;
+import java.io.FileInputStream;
+import java.io.BufferedInputStream;
+import java.io.Reader;
+import java.io.InputStreamReader;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -65,21 +70,6 @@
 import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.BufferedOutputStream;
-import java.io.Writer;
-import java.io.OutputStreamWriter;
-import java.io.IOException;
-import java.io.FileInputStream;
-import java.io.BufferedInputStream;
-import java.io.Reader;
-import java.io.InputStreamReader;
-import java.util.List;
-import java.util.Properties;
-import java.util.Map;
-import java.util.HashMap;
-
 /**
  * Verify integration tests ran using Surefire.
  *
@@ -112,12 +102,11 @@
     private boolean skipITs;
 
     /**
-     * DEPRECATED This old parameter is just like skipTests, but bound to the 
old property maven.test.skip.exec.
-     * Use -DskipTests instead; it's shorter.
+     * This old parameter is just like skipTests, but bound to the old 
property maven.test.skip.exec.
      *
+     * @deprecated Use -DskipTests instead.
      * @parameter expression="${maven.test.skip.exec}"
      * @since 2.3
-     * @deprecated
      */
     private boolean skipExec;
 
@@ -171,7 +160,7 @@
     private File summaryFile;
 
     /**
-     * Set this to "true" to cause a failure if there are no tests to run. 
Defaults to false.
+     * Set this to "true" to cause a failure if there are no tests to run.
      *
      * @parameter expression="${failIfNoTests}"
      * @since 2.4

Modified: 
maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java?rev=898237&r1=898236&r2=898237&view=diff
==============================================================================
--- 
maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
 (original)
+++ 
maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
 Tue Jan 12 08:16:55 2010
@@ -490,8 +490,6 @@
      */
     private ArtifactMetadataSource metadataSource;
 
-
-
     private static final String BRIEF_REPORT_FORMAT = "brief";
 
     private static final String PLAIN_REPORT_FORMAT = "plain";
@@ -804,11 +802,16 @@
                 // The plugin uses a JDK based profile to select the right 
testng. We might be explicity using a
                 // different one since its based on the source level, not the 
JVM. Prune using the filter.
                 addProvider( surefireBooter, "surefire-testng", 
surefireArtifact.getBaseVersion(), testNgArtifact );
-            } else if (junitArtifact != null && isAnyJunit4( junitArtifact)){
-                    if ( isAnyConcurrencySelected() && isJunit47Compatible( 
junitArtifact ) ){
+            } 
+            else if ( junitArtifact != null && isAnyJunit4( junitArtifact ) )
+            {
+                    if ( isAnyConcurrencySelected() && isJunit47Compatible( 
junitArtifact ) )
+                    {
                         convertJunitCoreParameters();
                         addProvider( surefireBooter, "surefire-junit47", 
surefireArtifact.getBaseVersion(), null );
-                    } else {
+                    } 
+                    else 
+                    {
                         addProvider( surefireBooter, "surefire-junit4", 
surefireArtifact.getBaseVersion(), null );
                     }
             }


Reply via email to