[maven-scm] copy for tag surefire-2.7

git-svn-id: https://svn.apache.org/repos/asf/maven/surefire/tags/surefire-2.7@1049854 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
index bc5c119..c2d5418 100644
--- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
@@ -331,8 +331,9 @@
     private String forkMode;
 
     /**
-     * Option to specify the jvm (or path to the java executable) to use with the forking options. For the default, the
-     * jvm will be the same as the one used to run Maven.
+      * Option to specify the jvm (or path to the java executable) to use with the forking options. For the default, the
+      * jvm will be a new instance of the same VM as the one used to run Maven. JVM settings are not inherited from
+      * MAVEN_OPTS
      *
      * @parameter expression="${jvm}"
      * @since 2.1
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
index 866d72c..7d0108a 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java
@@ -24,6 +24,7 @@
 import org.apache.maven.plugin.surefire.booterclient.output.StandardOutputConsumer;
 import org.apache.maven.plugin.surefire.booterclient.output.SupressFooterOutputConsumerProxy;
 import org.apache.maven.plugin.surefire.booterclient.output.SupressHeaderOutputConsumerProxy;
+import org.apache.maven.plugin.surefire.booterclient.output.SynchronizedOutputConsumer;
 import org.apache.maven.surefire.booter.Classpath;
 import org.apache.maven.surefire.booter.ProviderConfiguration;
 import org.apache.maven.surefire.booter.ProviderFactory;
@@ -170,8 +171,7 @@
         {
             BooterSerializer booterSerializer = new BooterSerializer( forkConfiguration, properties );
 
-            surefireProperties =
-                booterSerializer.serialize( providerConfiguration, startupConfiguration, testSet );
+            surefireProperties = booterSerializer.serialize( providerConfiguration, startupConfiguration, testSet );
 
             if ( forkConfiguration.getSystemProperties() != null )
             {
@@ -205,11 +205,13 @@
         final boolean willBeSharingConsumer = startupConfiguration.isRedirectTestOutputToFile();
 
         ForkingStreamConsumer out =
-            getForkingStreamConsumer( showHeading, showFooter, startupConfiguration.isRedirectTestOutputToFile() );
+            getForkingStreamConsumer( showHeading, showFooter, startupConfiguration.isRedirectTestOutputToFile(),
+                                      willBeSharingConsumer );
 
         StreamConsumer err = willBeSharingConsumer
             ? out
-            : getForkingStreamConsumer( showHeading, showFooter, startupConfiguration.isRedirectTestOutputToFile() );
+            : getForkingStreamConsumer( showHeading, showFooter, startupConfiguration.isRedirectTestOutputToFile(),
+                                        false );
 
         if ( forkConfiguration.isDebug() )
         {
@@ -224,7 +226,7 @@
         }
         catch ( CommandLineException e )
         {
-            throw new SurefireBooterForkException( "Error while executing forked tests.", e );
+            throw new SurefireBooterForkException( "Error while executing forked tests.", e.getCause() );
         }
 
         if ( startupConfiguration.isRedirectTestOutputToFile() )
@@ -267,7 +269,7 @@
     }
 
     private ForkingStreamConsumer getForkingStreamConsumer( boolean showHeading, boolean showFooter,
-                                                            boolean redirectTestOutputToFile )
+                                                            boolean redirectTestOutputToFile, boolean mustBeThreadSafe )
     {
         OutputConsumer outputConsumer = new StandardOutputConsumer();
 
@@ -286,6 +288,11 @@
             outputConsumer = new SupressFooterOutputConsumerProxy( outputConsumer );
         }
 
+        if ( mustBeThreadSafe )
+        {
+            outputConsumer = new SynchronizedOutputConsumer( outputConsumer );
+        }
+
         return new ForkingStreamConsumer( outputConsumer );
     }
 }
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/FileOutputConsumerProxy.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/FileOutputConsumerProxy.java
index 58051dd..8f8ea02 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/FileOutputConsumerProxy.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/FileOutputConsumerProxy.java
@@ -31,6 +31,9 @@
 /**
  * Surefire output consumer proxy that writes test output to a {@link File} for each test suite.
  *
+ * This class is not threadsafe, but can be encapsulated with a SynchronizedOutputConsumer. It may still be
+ * accessed from different threads (serially).
+ *
  * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
  * @version $Id$
  * @since 2.1
@@ -104,9 +107,8 @@
     /**
      * Write the output to the current test file
      * <p/>
-     * This method may be called from multiple threads
      */
-    public synchronized void consumeOutputLine( String line )
+    public void consumeOutputLine( String line )
     {
         if ( printWriter == null )
         {
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/SynchronizedOutputConsumer.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/SynchronizedOutputConsumer.java
new file mode 100644
index 0000000..163e9f6
--- /dev/null
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/SynchronizedOutputConsumer.java
@@ -0,0 +1,69 @@
+package org.apache.maven.plugin.surefire.booterclient.output;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.surefire.report.ReportEntry;
+
+/**
+ * Imposes synchronization on a non-thredsafe OutputConsumer
+ *
+ * @author Kristian Rosenvold
+ */
+public class SynchronizedOutputConsumer
+    implements OutputConsumer
+{
+
+    final OutputConsumer target;
+
+    public SynchronizedOutputConsumer( OutputConsumer target )
+    {
+        this.target = target;
+    }
+
+    public synchronized void consumeHeaderLine( String line )
+    {
+        target.consumeHeaderLine( line );
+    }
+
+    public synchronized void consumeMessageLine( String line )
+    {
+        target.consumeMessageLine( line );
+    }
+
+    public synchronized void consumeFooterLine( String line )
+    {
+        target.consumeFooterLine( line );
+    }
+
+    public synchronized void consumeOutputLine( String line )
+    {
+        target.consumeOutputLine( line );
+    }
+
+    public synchronized void testSetStarting( ReportEntry reportEntry )
+    {
+        target.testSetStarting( reportEntry );
+    }
+
+    public synchronized void testSetCompleted()
+    {
+        target.testSetCompleted();
+    }
+}
diff --git a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
index e3b87aa..ce71f52 100644
--- a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
+++ b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
@@ -306,7 +306,8 @@
 
     /**
      * Option to specify the jvm (or path to the java executable) to use with the forking options. For the default, the
-     * jvm will be the same as the one used to run Maven.
+     * jvm will be a new instance of the same VM as the one used to run Maven. JVM settings are not inherited from
+     * MAVEN_OPTS
      *
      * @parameter expression="${jvm}"
      * @since 2.1
diff --git a/pom.xml b/pom.xml
index 7d4768c..cd37e0f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -211,6 +211,15 @@
             <tagBase>https://svn.apache.org/repos/asf/maven/surefire/tags</tagBase>
           </configuration>
         </plugin>
+          <plugin>
+            <artifactId>maven-compiler-plugin</artifactId>
+            <version>2.3.2</version>
+            <configuration>
+              <source>1.3</source>
+              <target>1.3</target>
+            </configuration>
+          </plugin>
+
       </plugins>
     </pluginManagement>
   </build>
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java b/surefire-api/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java
index 84bf014..5ffea30 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/report/PojoStackTraceWriter.java
@@ -19,7 +19,8 @@
  * under the License.
  */
 
-import org.codehaus.plexus.util.StringUtils;
+
+import org.apache.maven.surefire.util.internal.StringUtils;
 
 import java.io.PrintWriter;
 import java.io.StringWriter;
@@ -62,7 +63,7 @@
 
         String marker = "at " + testClass + "." + testMethod;
 
-        String[] lines = StringUtils.split( text, "\n" );
+        String[] lines = StringUtils.split(text, "\n");
         int lastLine = lines.length - 1;
         int causedByLine = -1;
         // skip first
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StringUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
similarity index 97%
rename from surefire-booter/src/main/java/org/apache/maven/surefire/booter/StringUtils.java
rename to surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
index fd11192..c2c7689 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StringUtils.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
@@ -1,4 +1,4 @@
-package org.apache.maven.surefire.booter;
+package org.apache.maven.surefire.util.internal;
 
 /* ====================================================================
  * The Apache Software License, Version 1.1
@@ -80,6 +80,8 @@
  *
  * A quick borrow from plexus-utils by Kristian Rosenvold, to restore jdk1.3 compat
  * Threw away all the unused stuff.
+ *
+ * NOTE: This class is not part of any api and is public purely for technical reasons !
  */
 public class StringUtils
 {
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java
index bed5ca8..0167a77 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java
@@ -22,6 +22,7 @@
 import org.apache.maven.surefire.testset.DirectoryScannerParameters;
 import org.apache.maven.surefire.testset.TestArtifactInfo;
 import org.apache.maven.surefire.testset.TestRequest;
+import org.apache.maven.surefire.util.internal.StringUtils;
 
 import java.io.ByteArrayInputStream;
 import java.io.File;
@@ -130,7 +131,7 @@
 
         List list = new ArrayList();
 
-        String[] stringArray = StringUtils.split( sl, "," );
+        String[] stringArray = StringUtils.split(sl, ",");
 
         for ( int i = 0; i < stringArray.length; i++ )
         {
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java
index 9ed7d93..16307d5 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java
@@ -20,6 +20,7 @@
  */
 
 import org.apache.maven.surefire.util.ReflectionUtils;
+import org.apache.maven.surefire.util.internal.StringUtils;
 
 import java.io.ByteArrayInputStream;
 import java.io.File;
@@ -193,7 +194,7 @@
 
         List list = new ArrayList();
 
-        String[] stringArray = StringUtils.split( sl, "," );
+        String[] stringArray = StringUtils.split(sl, ",");
 
         for ( int i = 0; i < stringArray.length; i++ )
         {
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AbstractSurefireIntegrationTestClass.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AbstractSurefireIntegrationTestClass.java
index 77fbb1b..91b1dda 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AbstractSurefireIntegrationTestClass.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AbstractSurefireIntegrationTestClass.java
@@ -99,4 +99,8 @@
         verifier.executeGoals( goals );
     }
 
+    protected String getSurefireVersion()
+    {
+        return surefireVersion;
+    }
 }
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AggregateReportIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AggregateReportIT.java
index 195b9e5..5d26232 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AggregateReportIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/AggregateReportIT.java
@@ -40,7 +40,7 @@
 
         Verifier verifier = new Verifier( testDir.getAbsolutePath() );
         List goals = this.getInitialGoals();
-        goals.add( "surefire-report:report" );
+        goals.add( "org.apache.maven.plugins:maven-surefire-report-plugin:" + getSurefireVersion() + ":report" );
         executeGoals( verifier, goals );
         //DGF even though the build will succeed, the log will contain errors (from the failure)
         //verifier.verifyErrorFreeLog();
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java
index 1248f93..5eef4e7 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java
@@ -38,7 +38,8 @@
         File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/testng-simple" );
 
         Verifier verifier = new Verifier( testDir.getAbsolutePath() );
-        this.executeGoal( verifier, "surefire-report:report" );
+        this.executeGoal( verifier,
+                          "org.apache.maven.plugins:maven-surefire-report-plugin:" + getSurefireVersion() + ":report" );
         verifier.verifyErrorFreeLog();
         verifier.resetStreams();