You are viewing a plain text version of this content. The canonical link for it is here.
Posted to surefire-commits@maven.apache.org by kr...@apache.org on 2011/04/27 23:20:16 UTC

svn commit: r1097246 [1/5] - in /maven/surefire/trunk: maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/ maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/ maven-surefire-common/src/main/java/org/apache/maven/plug...

Author: krosenvold
Date: Wed Apr 27 21:20:12 2011
New Revision: 1097246

URL: http://svn.apache.org/viewvc?rev=1097246&view=rev
Log:
[SUREFIRE-732] Simplified reporting logic

Note the slight change in semantics for the 'redirectTestOutputToFile' parameter,
which now redirects test output to file even if not forking.

Added:
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/MockReporter.java
      - copied, changed from r1097226, maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/junit4/MockReporter.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/TestSetMockReporterFactory.java
      - copied, changed from r1097226, maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ClassesParallelRunListener.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java   (contents, props changed)
      - copied, changed from r1097226, maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/SupressFooterOutputConsumerProxy.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java   (with props)
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java   (with props)
    maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkingRunListenerTest.java   (with props)
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/plugin/
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/plugin/surefire/
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/plugin/surefire/booterclient/
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/FileOutputConsumerProxy.java
      - copied, changed from r1097226, maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/FileOutputConsumerProxy.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/plugin/surefire/report/
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/plugin/surefire/report/ReporterManagerFactory.java   (with props)
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingReporterFactory.java   (with props)
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java   (with props)
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/forking/
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/forking/ForkConfigurationInfo.java   (contents, props changed)
      - copied, changed from r1097226, maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/output/SupressHeaderOutputConsumerProxyTest.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AsynchRunListener.java   (with props)
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputFileReporter.java   (contents, props changed)
      - copied, changed from r1097226, maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/FileOutputConsumerProxy.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/DefaultConsoleReporter.java   (contents, props changed)
      - copied, changed from r1097226, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/RunReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ForwardingRunListener.java   (with props)
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/PrettyPrintXMLWriter.java   (contents, props changed)
      - copied, changed from r1097226, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/PrettyPrintXMLWriter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ThreadLocalRunListener.java   (with props)
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueue.java   (contents, props changed)
      - copied, changed from r1097226, maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/output/StandardOutputConsumerTest.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueueFactory.java   (contents, props changed)
      - copied, changed from r1097226, maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/StandardOutputConsumer.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/FunkyTwoThreadBlockingQueue.java   (with props)
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/Java13BlockingQueue.java   (contents, props changed)
      - copied, changed from r1097226, maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/output/SupressFooterOutputConsumerProxyTest.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/Java15BlockingQueue.java
      - copied, changed from r1097226, maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/NullOutputConsumer.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueue.java   (with props)
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/AsynchRunListenerTest.java   (with props)
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/suite/
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/suite/RunResultTest.java   (with props)
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/StringUtilsTest.java   (contents, props changed)
      - copied, changed from r1097226, maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/ForkingConsoleReporterTest.java
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueueTest.java   (with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire674BuildFailingWhenFailsafeErrorsIT.java
      - copied, changed from r1097226, maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire628ConsoleOutputBeforeAndAfterClassIT.java
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/invoker.properties   (with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/pom.xml   (with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/src/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/src/test/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/src/test/java/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/src/test/java/MyAT.java
      - copied, changed from r1097226, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/src/test/java/MyIT.java
      - copied, changed from r1097226, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/pom.xml
      - copied, changed from r1097226, maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/src/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/src/test/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/src/test/java/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/src/test/java/forkConsoleOutput/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/src/test/java/forkConsoleOutput/Test1.java   (contents, props changed)
      - copied, changed from r1097226, maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/NullOutputConsumer.java
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutputWithErrors/src/test/java/forkConsoleOutput/Test2.java   (contents, props changed)
      - copied, changed from r1097226, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java
    maven/surefire/trunk/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4ProviderTest.java   (contents, props changed)
      - copied, changed from r1097226, maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/SupressHeaderOutputConsumerProxy.java
Removed:
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkingStreamConsumer.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/FileOutputConsumerProxy.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/NullOutputConsumer.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/OutputConsumer.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/OutputConsumerProxy.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/PrintWriterOutputConsumer.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/StandardOutputConsumer.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/SupressFooterOutputConsumerProxy.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/SupressHeaderOutputConsumerProxy.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/SynchronizedOutputConsumer.java
    maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/ForkingStreamConsumerTest.java
    maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/output/AbstractOutputConsumerTestCase.java
    maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/output/FileOutputConsumerProxyTest.java
    maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/output/OutputConsumerProxyTest.java
    maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/output/PrintWriterOutputConsumerTest.java
    maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/output/StandardOutputConsumerTest.java
    maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/output/SupressFooterOutputConsumerProxyTest.java
    maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/output/SupressHeaderOutputConsumerProxyTest.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/Surefire.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ForkingConsoleReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterManagerFactory.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/RunReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/PrettyPrintXMLWriter.java
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/ForkingConsoleReporterTest.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentPrintStream.java
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-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/SurefireHelper.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
    maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.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/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java
    maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java
    maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/SurefireReflector.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/providerapi/ProviderParameters.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractConsoleReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractFileReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AbstractTextReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputCapture.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/MulticastingReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/Reporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterException.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterFactory.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/RunListener.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/RunStatistics.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/TestSetRunListener.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/TestSetStatistics.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/TestConsoleOutputRunListenerTest.java
    maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java
    maven/surefire/trunk/surefire-booter/pom.xml
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StartupConfiguration.java
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java
    maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ForkTimeoutTest.java
    maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
    maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgExecuteErrorIT.java
    maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire628ConsoleOutputBeforeAndAfterClassIT.java
    maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SurefireVerifierTestClass.java
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml
    maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/junit4/MockReporter.java
    maven/surefire/trunk/surefire-providers/surefire-junit3/src/main/java/org/apache/maven/surefire/junit/JUnit3Provider.java
    maven/surefire/trunk/surefire-providers/surefire-junit4/src/main/java/org/apache/maven/surefire/junit4/JUnit4Provider.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ClassesParallelRunListener.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ConcurrentReporterManager.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreProvider.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreWrapper.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/LogicalStream.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/MethodsParallelRunListener.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestMethod.java
    maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/TestSet.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
    maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGDirectoryTestSuite.java
    maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java
    maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGXmlTestSuite.java
    maven/surefire/trunk/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNgTestSuite.java
    maven/surefire/trunk/surefire-setup-integration-tests/pom.xml

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=1097246&r1=1097245&r2=1097246&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 Wed Apr 27 21:20:12 2011
@@ -19,6 +19,17 @@ package org.apache.maven.plugin.failsafe
  * under the License.
  */
 
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
 import org.apache.maven.artifact.factory.ArtifactFactory;
 import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
 import org.apache.maven.artifact.repository.ArtifactRepository;
@@ -38,22 +49,11 @@ import org.apache.maven.surefire.booter.
 import org.apache.maven.surefire.booter.SurefireExecutionException;
 import org.apache.maven.surefire.failsafe.model.FailsafeSummary;
 import org.apache.maven.surefire.failsafe.model.io.xpp3.FailsafeSummaryXpp3Writer;
+import org.apache.maven.surefire.suite.RunResult;
 import org.apache.maven.toolchain.ToolchainManager;
 import org.codehaus.plexus.util.ReaderFactory;
 import org.codehaus.plexus.util.StringUtils;
 
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
 /**
  * Run integration tests using Surefire.
  *
@@ -197,7 +197,7 @@ public class IntegrationTestMojo
      * to run a single test called "foo/MyTest.java".<br/>
      * This parameter overrides the <code>includes/excludes</code> parameters, and the TestNG
      * <code>suiteXmlFiles</code> parameter.
-     * 
+     * <p/>
      * since 2.7.3
      * You can execute a limited number of method in the test with adding #myMethod or #my*ethod.
      * Si type "-Dtest=MyTest#myMethod"
@@ -206,7 +206,7 @@ public class IntegrationTestMojo
      * @parameter expression="${it.test}"
      */
     private String test;
-    
+
     /**
      * A list of &lt;include> elements specifying the tests (by pattern) that should be included in testing. When not
      * specified and when the <code>test</code> parameter is not specified, the default includes will be
@@ -328,7 +328,7 @@ public class IntegrationTestMojo
     private boolean useFile;
 
     /**
-     * When forking, set this to "true" to redirect the unit test standard output to a file (found in
+     * Set this to "true" to redirect the unit test standard output to a file (found in
      * reportsDirectory/testName-output.txt).
      *
      * @parameter expression="${maven.test.redirectTestOutputToFile}" default-value="false"
@@ -653,7 +653,8 @@ public class IntegrationTestMojo
             ForkStarter forkStarter = createForkStarter( provider, forkConfiguration, classLoaderConfiguration );
             try
             {
-                result.setResult( forkStarter.run() );
+                final RunResult runResult = forkStarter.run();
+                result.setResult( runResult.getForkedProcessCode() );
             }
             catch ( SurefireBooterForkException e )
             {
@@ -684,24 +685,24 @@ public class IntegrationTestMojo
             System.setProperties( getOriginalSystemProperties() );
         }
 
-        writeSummary(result);
+        writeSummary( result );
     }
 
-	private void writeSummary(FailsafeSummary summary)
-			throws MojoExecutionException {
-		File summaryFile = getSummaryFile();
+    private void writeSummary( FailsafeSummary summary )
+        throws MojoExecutionException
+    {
+        File summaryFile = getSummaryFile();
         if ( !summaryFile.getParentFile().isDirectory() )
         {
-        	summaryFile.getParentFile().mkdirs();
+            summaryFile.getParentFile().mkdirs();
         }
-		try
+        try
         {
             String encoding;
             if ( StringUtils.isEmpty( this.encoding ) )
             {
-                getLog().warn(
-                    "File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING
-                        + ", i.e. build is platform dependent!" );
+                getLog().warn( "File encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING
+                                   + ", i.e. build is platform dependent!" );
                 encoding = ReaderFactory.FILE_ENCODING;
             }
             else
@@ -722,11 +723,11 @@ public class IntegrationTestMojo
         {
             throw new MojoExecutionException( e.getMessage(), e );
         }
-	}
+    }
 
     protected boolean isSkipExecution()
     {
-    	return isSkip() || isSkipTests() || isSkipITs() || isSkipExec();
+        return isSkip() || isSkipTests() || isSkipITs() || isSkipExec();
     }
 
     protected String getPluginName()
@@ -887,7 +888,7 @@ public class IntegrationTestMojo
     {
         this.test = test;
     }
-    
+
     /**
      * @since 2.7.3
      */
@@ -896,14 +897,14 @@ public class IntegrationTestMojo
         if ( StringUtils.isBlank( test ) )
         {
             return null;
-        }        
+        }
         int index = this.test.indexOf( '#' );
         if ( index >= 0 )
         {
             return this.test.substring( index + 1, this.test.length() );
         }
         return null;
-    }    
+    }
 
     public List getIncludes()
     {
@@ -1384,8 +1385,8 @@ public class IntegrationTestMojo
 
     protected void addPluginSpecificChecksumItems( ChecksumCalculator checksum )
     {
-        checksum.add(skipITs);
-        checksum.add(summaryFile);
+        checksum.add( skipITs );
+        checksum.add( summaryFile );
     }
-    
+
 }

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=1097246&r1=1097245&r2=1097246&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 Wed Apr 27 21:20:12 2011
@@ -181,7 +181,7 @@ public class VerifyMojo
                     summary = new FailsafeSummary();
                 }
                 else
-                {                    
+                {
                     summary = readSummary( encoding, summaryFile );
                 }
                 if ( summaryFiles != null )
@@ -207,7 +207,7 @@ public class VerifyMojo
     }
 
     private FailsafeSummary readSummary( String encoding, File summaryFile )
-            throws IOException, XmlPullParserException
+        throws IOException, XmlPullParserException
     {
         FileInputStream fileInputStream = null;
         BufferedInputStream bufferedInputStream = null;

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=1097246&r1=1097245&r2=1097246&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 Wed Apr 27 21:20:12 2011
@@ -55,17 +55,16 @@ import org.apache.maven.surefire.booter.
 import org.apache.maven.surefire.booter.StartupConfiguration;
 import org.apache.maven.surefire.report.BriefConsoleReporter;
 import org.apache.maven.surefire.report.BriefFileReporter;
+import org.apache.maven.surefire.report.ConsoleOutputFileReporter;
 import org.apache.maven.surefire.report.ConsoleReporter;
 import org.apache.maven.surefire.report.DetailedConsoleReporter;
 import org.apache.maven.surefire.report.FileReporter;
-import org.apache.maven.surefire.report.ForkingConsoleReporter;
 import org.apache.maven.surefire.report.ReporterConfiguration;
 import org.apache.maven.surefire.report.XMLReporter;
 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.NestedRuntimeException;
-import org.apache.maven.surefire.util.Relocator;
 import org.apache.maven.toolchain.Toolchain;
 import org.codehaus.plexus.util.StringUtils;
 
@@ -264,18 +263,18 @@ public abstract class AbstractSurefireMo
         return ForkConfiguration.FORK_NEVER.equals( getForkMode() );
     }
 
-    protected ProviderConfiguration createProviderConfiguration( ForkConfiguration forkConfiguration,
-                                                                 boolean shadefire )
+    protected ProviderConfiguration createProviderConfiguration( ForkConfiguration forkConfiguration )
         throws MojoExecutionException, MojoFailureException
     {
-
-        List reports = getReporters( forkConfiguration.isForking() );
-        reports = shadefire ? new Relocator().relocateReports( reports ) : reports;
+        final String consoleReporter = getConsoleReporter();
+        final String fileReporter = getFileReporter();
+        final String xmlReporterName = getXmlReporterName();
+        final String consoleOutputFileReporterName = getConsoleOutputFileReporterName();
         Integer timeoutSet =
             getForkedProcessTimeoutInSeconds() > 0 ? Integer.valueOf( getForkedProcessTimeoutInSeconds() ) : null;
         ReporterConfiguration reporterConfiguration =
-            new ReporterConfiguration( reports, getReportsDirectory(), Boolean.valueOf( isTrimStackTrace() ),
-                                       timeoutSet );
+            new ReporterConfiguration( getReportsDirectory(), Boolean.valueOf( isTrimStackTrace() ), consoleReporter,
+                                       fileReporter, xmlReporterName, consoleOutputFileReporterName );
 
         Artifact testNgArtifact;
         try
@@ -328,7 +327,7 @@ public abstract class AbstractSurefireMo
 
         ProviderConfiguration providerConfiguration1 =
             new ProviderConfiguration( directoryScannerParameters, failIfNoTests, reporterConfiguration, testNg,
-                                       testSuiteDefinition, providerProperties, null );
+                                       testSuiteDefinition, providerProperties, null, forkConfiguration.getForkMode() );
 
         Toolchain tc = getToolchain();
 
@@ -372,7 +371,7 @@ public abstract class AbstractSurefireMo
                                             isChildDelegation() );
 
             return new StartupConfiguration( providerName, classpathConfiguration, classLoaderConfiguration,
-                                             forkConfiguration.isForking(), false, isRedirectTestOutputToFile() );
+                                             forkConfiguration.getForkMode(), false, isRedirectTestOutputToFile() );
         }
         catch ( DependencyResolutionRequiredException e )
         {
@@ -523,10 +522,9 @@ public abstract class AbstractSurefireMo
     {
         StartupConfiguration startupConfiguration =
             createStartupConfiguration( forkConfiguration, provider, classLoaderConfiguration );
-        ProviderConfiguration providerConfiguration =
-            createProviderConfiguration( forkConfiguration, startupConfiguration.isShadefire() );
-        return new ForkStarter( providerConfiguration, startupConfiguration, getReportsDirectory(), forkConfiguration,
-                                getForkedProcessTimeoutInSeconds(), isPrintSummary() );
+        ProviderConfiguration providerConfiguration = createProviderConfiguration( forkConfiguration );
+        return new ForkStarter( providerConfiguration, startupConfiguration, forkConfiguration,
+                                getForkedProcessTimeoutInSeconds() );
     }
 
     protected ForkConfiguration getForkConfiguration()
@@ -985,62 +983,45 @@ public abstract class AbstractSurefireMo
         return props;
     }
 
-    /**
-     * <p/>
-     * Adds Reporters that will generate reports with different formatting.
-     * <p/>
-     * The Reporter that will be added will be based on the value of the parameter useFile, reportFormat, and
-     * printSummary.
-     *
-     * @param forking forking
-     * @return a list of reporters
-     */
-    private List getReporters( boolean forking )
+    private String getXmlReporterName()
     {
-        List reports = new ArrayList();
-        final String consoleReporter = getConsoleReporter( forking );
-        if ( consoleReporter != null )
+        if ( !isDisableXmlReport() )
         {
-            reports.add( consoleReporter );
+            return XMLReporter.class.getName();
         }
+        return null;
+    }
 
+    private String getFileReporter()
+    {
         if ( isUseFile() )
         {
             if ( BRIEF_REPORT_FORMAT.equals( getReportFormat() ) )
             {
-                reports.add( BriefFileReporter.class.getName() );
+                return BriefFileReporter.class.getName();
             }
             else if ( PLAIN_REPORT_FORMAT.equals( getReportFormat() ) )
             {
-                reports.add( FileReporter.class.getName() );
+                return FileReporter.class.getName();
             }
         }
-
-        if ( !isDisableXmlReport() )
-        {
-            reports.add( XMLReporter.class.getName() );
-        }
-        return reports;
+        return null;
     }
 
     /**
      * Returns the reporter that will write to the console
      *
-     * @param forking forking
      * @return a console reporter of null if no console reporting
      */
-    private String getConsoleReporter( boolean forking )
+    private String getConsoleReporter()
     {
+        if (isRedirectTestOutputToFile())
+        {
+            return null;
+        }
         if ( isUseFile() )
         {
-            if ( forking )
-            {
-                return ForkingConsoleReporter.class.getName();
-            }
-            else
-            {
-                return isPrintSummary() ? ConsoleReporter.class.getName() : null;
-            }
+            return isPrintSummary() ? ConsoleReporter.class.getName() : null;
         }
         else if ( BRIEF_REPORT_FORMAT.equals( getReportFormat() ) )
         {
@@ -1053,6 +1034,16 @@ public abstract class AbstractSurefireMo
         return null;
     }
 
+    private String getConsoleOutputFileReporterName()
+    {
+        if ( isRedirectTestOutputToFile() )
+        {
+            return ConsoleOutputFileReporter.class.getName();
+        }
+        return null;
+    }
+
+
     protected void ensureWorkingDirectoryExists()
         throws MojoFailureException
     {

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java Wed Apr 27 21:20:12 2011
@@ -22,6 +22,7 @@ package org.apache.maven.plugin.surefire
 import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.surefire.booter.ProviderConfiguration;
+import org.apache.maven.surefire.suite.RunResult;
 
 /**
  * Helper class for surefire plugins
@@ -37,6 +38,56 @@ public final class SurefireHelper
         throw new IllegalAccessError( "Utility class" );
     }
 
+    // Todo: Fix the duplication, probably by making failsafe relate to a "RunResult" too.
+
+    public static void reportExecution( SurefireReportParameters reportParameters, RunResult result, Log log )
+        throws MojoFailureException
+    {
+
+        String msg;
+
+//        System.out.println( "");
+//        System.out.println( result.getTestSetSummary() );
+
+        if ( result.getCompletedCount() == 0 )
+        {
+            if ( ( reportParameters.getFailIfNoTests() == null )
+                || !reportParameters.getFailIfNoTests().booleanValue() )
+            {
+                return;
+            }
+            // TODO: i18n
+            throw new MojoFailureException(
+                "No tests were executed!  (Set -DfailIfNoTests=false to ignore this error.)" );
+        }
+
+        if ( result.isErrrorFree() )
+        {
+            return;
+        }
+
+        if ( result.isFailureOrTimeout() )
+        {
+            msg = "There was a timeout or other error in the fork";
+        }
+        else
+        {
+            // TODO: i18n
+            msg = "There are test failures.\n\nPlease refer to " + reportParameters.getReportsDirectory()
+                + " for the individual test results.";
+
+        }
+
+        if ( reportParameters.isTestFailureIgnore() )
+        {
+            log.error( msg );
+        }
+        else
+        {
+            throw new MojoFailureException( msg );
+        }
+    }
+
     public static void reportExecution( SurefireReportParameters reportParameters, int result, Log log )
         throws MojoFailureException
     {
@@ -49,7 +100,8 @@ public final class SurefireHelper
 
         if ( result == ProviderConfiguration.NO_TESTS_EXIT_CODE )
         {
-            if ( ( reportParameters.getFailIfNoTests() == null ) || !reportParameters.getFailIfNoTests().booleanValue() )
+            if ( ( reportParameters.getFailIfNoTests() == null )
+                || !reportParameters.getFailIfNoTests().booleanValue() )
             {
                 return;
             }
@@ -74,4 +126,5 @@ public final class SurefireHelper
             throw new MojoFailureException( msg );
         }
     }
+
 }

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java Wed Apr 27 21:20:12 2011
@@ -67,10 +67,10 @@ public class BooterSerializer
 
 
     public File serialize( ProviderConfiguration booterConfiguration, StartupConfiguration providerConfiguration,
-                           Object testSet )
+                           Object testSet, String forkMode )
         throws IOException
     {
-        providerConfiguration.getClasspathConfiguration().setForkProperties( properties);
+        providerConfiguration.getClasspathConfiguration().setForkProperties( properties );
 
         TestArtifactInfo testNg = booterConfiguration.getTestArtifact();
         if ( testNg != null )
@@ -102,13 +102,11 @@ public class BooterSerializer
         }
 
         ReporterConfiguration reporterConfiguration = booterConfiguration.getReporterConfiguration();
-        addList( reporterConfiguration.getReports(), properties.getProperties(),
-                 BooterConstants.REPORT_PROPERTY_PREFIX );
 
         Boolean rep = reporterConfiguration.isTrimStackTrace();
         properties.setProperty( BooterConstants.ISTRIMSTACKTRACE, rep );
         properties.setProperty( BooterConstants.REPORTSDIRECTORY, reporterConfiguration.getReportsDirectory() );
-        properties.setProperty( BooterConstants.FORKTIMEOUT, reporterConfiguration.getForkTimeout() );
+        properties.setProperty( BooterConstants.FORKMODE, forkMode );
         ClassLoaderConfiguration classLoaderConfiguration = providerConfiguration.getClassLoaderConfiguration();
         properties.setProperty( BooterConstants.USESYSTEMCLASSLOADER,
                                 String.valueOf( classLoaderConfiguration.isUseSystemClassLoader() ) );

Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java Wed Apr 27 21:20:12 2011
@@ -34,6 +34,7 @@ import org.apache.maven.surefire.booter.
 import org.apache.maven.surefire.booter.Classpath;
 import org.apache.maven.surefire.booter.ForkedBooter;
 import org.apache.maven.surefire.booter.SurefireBooterForkException;
+import org.apache.maven.surefire.forking.ForkConfigurationInfo;
 import org.apache.maven.surefire.util.Relocator;
 import org.apache.maven.surefire.util.UrlUtils;
 import org.codehaus.plexus.util.StringUtils;
@@ -146,6 +147,12 @@ public class ForkConfiguration
         this.tempDirectory = tempDirectory;
     }
 
+
+    public ForkConfigurationInfo getForkConfigurationInfo( Boolean isInFork )
+    {
+        return new ForkConfigurationInfo( forkMode, isInFork );
+    }
+
     public String getForkMode()
     {
         return forkMode;

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=1097246&r1=1097245&r2=1097246&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 Wed Apr 27 21:20:12 2011
@@ -19,36 +19,30 @@ package org.apache.maven.plugin.surefire
  * under the License.
  */
 
-import org.apache.maven.plugin.surefire.booterclient.output.FileOutputConsumerProxy;
-import org.apache.maven.plugin.surefire.booterclient.output.NullOutputConsumer;
-import org.apache.maven.plugin.surefire.booterclient.output.OutputConsumer;
-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 java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Properties;
+import org.apache.maven.plugin.surefire.booterclient.output.ForkClient;
+import org.apache.maven.plugin.surefire.booterclient.output.ThreadedStreamConsumer;
+import org.apache.maven.plugin.surefire.report.ReporterManagerFactory;
 import org.apache.maven.surefire.booter.Classpath;
 import org.apache.maven.surefire.booter.ProviderConfiguration;
 import org.apache.maven.surefire.booter.ProviderFactory;
 import org.apache.maven.surefire.booter.StartupConfiguration;
 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;
+import org.apache.maven.surefire.report.RunStatistics;
 import org.apache.maven.surefire.suite.RunResult;
-import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.cli.CommandLineException;
 import org.codehaus.plexus.util.cli.CommandLineTimeOutException;
 import org.codehaus.plexus.util.cli.CommandLineUtils;
 import org.codehaus.plexus.util.cli.Commandline;
-import org.codehaus.plexus.util.cli.StreamConsumer;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Properties;
 
 
 /**
@@ -76,31 +70,24 @@ public class ForkStarter
 
     private final ForkConfiguration forkConfiguration;
 
-    private final File reportsDirectory;
-
-    private final boolean printSummary;
-
     public ForkStarter( ProviderConfiguration providerConfiguration, StartupConfiguration startupConfiguration,
-                        File reportsDirectory, ForkConfiguration forkConfiguration, int forkedProcessTimeoutInSeconds,
-                        boolean printSummary )
+                        ForkConfiguration forkConfiguration, int forkedProcessTimeoutInSeconds )
     {
         this.forkConfiguration = forkConfiguration;
         this.providerConfiguration = providerConfiguration;
-        this.reportsDirectory = reportsDirectory;
         this.forkedProcessTimeoutInSeconds = forkedProcessTimeoutInSeconds;
         this.startupConfiguration = startupConfiguration;
-        this.printSummary = printSummary;
     }
 
-    public int run()
+    public RunResult run()
         throws SurefireBooterForkException, SurefireExecutionException
     {
-        final int result;
+        final RunResult result;
 
         final String requestedForkMode = forkConfiguration.getForkMode();
         if ( ForkConfiguration.FORK_NEVER.equals( requestedForkMode ) )
         {
-            SurefireStarter surefireStarter = new SurefireStarter( startupConfiguration, providerConfiguration );
+            SurefireStarter surefireStarter = new SurefireStarter( startupConfiguration, providerConfiguration, false );
             result = surefireStarter.runSuitesInProcess();
         }
         else if ( ForkConfiguration.FORK_ONCE.equals( requestedForkMode ) )
@@ -118,16 +105,27 @@ public class ForkStarter
         return result;
     }
 
-    private int runSuitesForkOnce()
+    private RunResult runSuitesForkOnce()
         throws SurefireBooterForkException
     {
-        return fork( null, providerConfiguration.getProviderProperties(), true, true );
+        final ReporterManagerFactory testSetReporterFactory =
+            new ReporterManagerFactory( Thread.currentThread().getContextClassLoader(),
+                                        providerConfiguration.getReporterConfiguration(),
+                                        providerConfiguration.getReporterConfiguration().getReports() );
+        try
+        {
+            return fork( null, providerConfiguration.getProviderProperties(), testSetReporterFactory );
+        }
+        finally
+        {
+            testSetReporterFactory.close();
+        }
     }
 
-    private int runSuitesForkPerTestSet()
+    private RunResult runSuitesForkPerTestSet()
         throws SurefireBooterForkException
     {
-        int globalResult = 0;
+        RunResult globalResult = new RunResult( 0, 0, 0, 0 );
 
         ClassLoader testsClassLoader;
         ClassLoader surefireClassLoader;
@@ -143,31 +141,47 @@ public class ForkStarter
             throw new SurefireBooterForkException( "Unable to create classloader to find test suites", e );
         }
 
-        boolean showHeading = true;
-        final ProviderFactory providerFactory =
-            new ProviderFactory( startupConfiguration, providerConfiguration, surefireClassLoader, testsClassLoader );
-        SurefireProvider surefireProvider = providerFactory.createProvider();
+        final Iterator suites = getSuitesIterator( testsClassLoader, surefireClassLoader );
 
         Properties properties = new Properties();
 
-        final Iterator suites = surefireProvider.getSuites();
-        while ( suites.hasNext() )
+        final ReporterManagerFactory testSetReporterFactory =
+            new ReporterManagerFactory( Thread.currentThread().getContextClassLoader(),
+                                        providerConfiguration.getReporterConfiguration(),
+                                        providerConfiguration.getReporterConfiguration().getReports() );
+        try
         {
-            Object testSet = suites.next();
-            boolean showFooter = !suites.hasNext();
-            int result = fork( testSet, properties, showHeading, showFooter );
-
-            if ( result > globalResult )
+            while ( suites.hasNext() )
             {
-                globalResult = result;
+                Object testSet = suites.next();
+                RunResult runResult = fork( testSet, properties, testSetReporterFactory );
+
+                globalResult = globalResult.aggregate( runResult );
             }
-            showHeading = false;
+            // At this place, show aggregated results ?
+            return globalResult;
+        }
+        finally
+        {
+            testSetReporterFactory.close();
         }
-        // At this place, show aggregated results ?
-        return globalResult;
     }
 
-    private int fork( Object testSet, Properties properties, boolean showHeading, boolean showFooter )
+    private Iterator getSuitesIterator( ClassLoader testsClassLoader, ClassLoader surefireClassLoader )
+    {
+        SurefireReflector surefireReflector = new SurefireReflector( surefireClassLoader );
+        Object reporterFactory =
+            surefireReflector.createReportingReporterFactory( this.providerConfiguration.getReporterConfiguration() );
+
+        final ProviderFactory providerFactory =
+            new ProviderFactory( startupConfiguration, providerConfiguration, surefireClassLoader, testsClassLoader,
+                                 forkConfiguration.getForkConfigurationInfo( Boolean.FALSE ), reporterFactory );
+        SurefireProvider surefireProvider = providerFactory.createProvider();
+        return surefireProvider.getSuites();
+    }
+
+
+    private RunResult fork( Object testSet, Properties properties, ReporterFactory testSetReporterFactory )
         throws SurefireBooterForkException
     {
         File surefireProperties;
@@ -176,7 +190,8 @@ public class ForkStarter
         {
             BooterSerializer booterSerializer = new BooterSerializer( forkConfiguration, properties );
 
-            surefireProperties = booterSerializer.serialize( providerConfiguration, startupConfiguration, testSet );
+            surefireProperties = booterSerializer.serialize( providerConfiguration, startupConfiguration, testSet,
+                                                             forkConfiguration.getForkMode() );
 
             if ( forkConfiguration.getSystemProperties() != null )
             {
@@ -208,112 +223,38 @@ public class ForkStarter
             cli.createArg().setFile( systemProperties );
         }
 
-        final boolean willBeSharingConsumer = startupConfiguration.isRedirectTestOutputToFile();
-
-        ForkingStreamConsumer out =
-            getForkingStreamConsumer( showHeading, showFooter, startupConfiguration.isRedirectTestOutputToFile(),
-                                      willBeSharingConsumer, printSummary );
-
-        StreamConsumer err = willBeSharingConsumer
-            ? out
-            : getForkingStreamConsumer( showHeading, showFooter, startupConfiguration.isRedirectTestOutputToFile(),
-                                        false, printSummary );
+        ForkClient out = new ForkClient( testSetReporterFactory,
+                                         providerConfiguration.getReporterConfiguration().getTestVmSystemProperties() );
+        ThreadedStreamConsumer threadedStreamConsumer2 = new ThreadedStreamConsumer( out );
 
         if ( forkConfiguration.isDebug() )
         {
             System.out.println( "Forking command line: " + cli );
         }
 
-        int returnCode;
+        RunResult runResult;
 
         try
         {
-            returnCode = CommandLineUtils.executeCommandLine( cli, out, err, forkedProcessTimeoutInSeconds > 0 ?
-                forkedProcessTimeoutInSeconds: 0 );
-        }
-        catch ( CommandLineTimeOutException e )
-        {
-            returnCode = RunResult.FAILURE;
-        }
-        catch ( CommandLineException e )
-        {
-            throw new SurefireBooterForkException( "Error while executing forked tests.", e.getCause() );
-        }
-
-       /*if ( !providerConfiguration.isSurefireForkReturnCode( returnCode ) )
-        {
-            throw new SurefireBooterForkException( "Uncontrolled error while forking surefire."
-                                                       + "You need to inspect log files (with reportFormat=plain and redirectTestOutputToFile=true )"
-                                                       + " to see stacktrace" );
-        }  */
-
-        if ( startupConfiguration.isRedirectTestOutputToFile() )
-        {
-            // ensure the FileOutputConsumerProxy flushes/closes the output file
-            try
-            {
-                out.getOutputConsumer().testSetCompleted();
-            }
-            catch ( Exception e )
-            {
-                // the FileOutputConsumerProxy might throw an IllegalStateException but that's not of interest now
-            }
-        }
-
-        if ( surefireProperties != null && surefireProperties.exists() )
-        {
-            FileInputStream inStream = null;
-            try
-            {
-                inStream = new FileInputStream( surefireProperties );
-
-                properties.load( inStream );
-            }
-            catch ( FileNotFoundException e )
-            {
-                throw new SurefireBooterForkException( "Unable to reload properties file from forked process", e );
-            }
-            catch ( IOException e )
-            {
-                throw new SurefireBooterForkException( "Unable to reload properties file from forked process", e );
-            }
-            finally
-            {
-                IOUtil.close( inStream );
-            }
-        }
-
-        return returnCode;
-    }
-
+            final int timeout = forkedProcessTimeoutInSeconds > 0 ? forkedProcessTimeoutInSeconds : 0;
+            CommandLineUtils.executeCommandLine( cli, threadedStreamConsumer2, threadedStreamConsumer2, timeout );
 
-    private ForkingStreamConsumer getForkingStreamConsumer( boolean showHeading, boolean showFooter,
-                                                            boolean redirectTestOutputToFile, boolean mustBeThreadSafe,
-                                                            boolean printSummary )
-    {
-        OutputConsumer outputConsumer =
-            printSummary ? new StandardOutputConsumer() : (OutputConsumer) new NullOutputConsumer();
+            threadedStreamConsumer2.close();
+            out.close();
 
-        if ( redirectTestOutputToFile )
-        {
-            outputConsumer = new FileOutputConsumerProxy( outputConsumer, reportsDirectory );
-        }
+            final RunStatistics globalRunStatistics = testSetReporterFactory.getGlobalRunStatistics();
 
-        if ( !showHeading )
-        {
-            outputConsumer = new SupressHeaderOutputConsumerProxy( outputConsumer );
+            runResult = globalRunStatistics.getRunResult();
         }
-
-        if ( !showFooter )
+        catch ( CommandLineTimeOutException e )
         {
-            outputConsumer = new SupressFooterOutputConsumerProxy( outputConsumer );
+            runResult = RunResult.Timeout;
         }
-
-        if ( mustBeThreadSafe )
+        catch ( CommandLineException e )
         {
-            outputConsumer = new SynchronizedOutputConsumer( outputConsumer );
+            throw new SurefireBooterForkException( "Error while executing forked tests.", e.getCause() );
         }
 
-        return new ForkingStreamConsumer( outputConsumer );
+        return runResult;
     }
 }

Copied: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/MockReporter.java (from r1097226, maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/junit4/MockReporter.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/MockReporter.java?p2=maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/MockReporter.java&p1=maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/junit4/MockReporter.java&r1=1097226&r2=1097246&rev=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/common-junit4/src/main/java/org/apache/maven/surefire/junit4/MockReporter.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/MockReporter.java Wed Apr 27 21:20:12 2011
@@ -1,4 +1,4 @@
-package org.apache.maven.surefire.junit4;
+package org.apache.maven.plugin.surefire.booterclient;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -22,28 +22,29 @@ package org.apache.maven.surefire.junit4
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.maven.surefire.report.ConsoleOutputReceiver;
+import org.apache.maven.surefire.report.DirectConsoleReporter;
 import org.apache.maven.surefire.report.ReportEntry;
 import org.apache.maven.surefire.report.ReporterConfiguration;
-import org.apache.maven.surefire.report.ReporterException;
 import org.apache.maven.surefire.report.RunListener;
 
-/** Internal use only */
+/**
+ * Internal use only
+ */
 public class MockReporter
-    implements RunListener
+    implements RunListener, DirectConsoleReporter, ConsoleOutputReceiver
 {
-    private final List<String> events = new ArrayList<String>();
-
-    public static final String RUN_STARTED = "RUN_STARTED";
+    private final List events = new ArrayList();
 
-    public static final String RUN_COMPLETED = "RUN_COMPLETED";
+    private final List data = new ArrayList();
 
-    public static final String SET_STARTED = "SET_STARTED";
+    public static final String SET_STARTING = "SET_STARTED";
 
     public static final String SET_COMPLETED = "SET_COMPLETED";
 
-    public static final String TEST_STARTED = "TEST_STARTED";
+    public static final String TEST_STARTING = "TEST_STARTED";
 
-    public static final String TEST_COMPLETED = "TEST_COMPLETED";
+    public static final String TEST_SUCCEEDED = "TEST_COMPLETED";
 
     public static final String TEST_FAILED = "TEST_FAILED";
 
@@ -51,6 +52,14 @@ public class MockReporter
 
     public static final String TEST_SKIPPED = "TEST_SKIPPED";
 
+    public static final String TEST_ASSUMPTION_FAIL = "TEST_ASSUMPTION_SKIPPED";
+
+    public static final String CONSOLE_OUTPUT = "CONSOLE_OUTPUT";
+
+    public static final String STDOUT = "STDOUT";
+
+    public static final String STDERR = "STDERR";
+
     private final AtomicInteger testSucceeded = new AtomicInteger();
 
     private final AtomicInteger testIgnored = new AtomicInteger();
@@ -68,57 +77,77 @@ public class MockReporter
 
     }
 
-    public void runStarting()
-    {
-        events.add( RUN_STARTED );
-    }
-
-    public void runCompleted()
-    {
-        events.add( RUN_COMPLETED );
-    }
-
     public void testSetStarting( ReportEntry report )
-        throws ReporterException
     {
-        events.add( SET_STARTED );
+        events.add( SET_STARTING );
+        data.add( report );
     }
 
     public void testSetCompleted( ReportEntry report )
-        throws ReporterException
     {
         events.add( SET_COMPLETED );
+        data.add( report );
     }
 
     public void testStarting( ReportEntry report )
     {
-        events.add( TEST_STARTED );
+        events.add( TEST_STARTING );
+        data.add( report );
     }
 
     public void testSucceeded( ReportEntry report )
     {
-        events.add( TEST_COMPLETED );
+        events.add( TEST_SUCCEEDED );
         testSucceeded.incrementAndGet();
+        data.add( report );
+    }
 
+    public void testError( ReportEntry report )
+    {
+        events.add( TEST_ERROR );
+        data.add( report );
+        testFailed.incrementAndGet();
     }
 
+    public void testFailed( ReportEntry report )
+    {
+        events.add( TEST_FAILED );
+        data.add( report );
+        testFailed.incrementAndGet();
+    }
+
+
     public void testSkipped( ReportEntry report )
     {
         events.add( TEST_SKIPPED );
+        data.add( report );
         testIgnored.incrementAndGet();
     }
 
-    public void writeFooter( String footer )
+
+    public List getEvents()
     {
+        return events;
     }
 
-    public void writeDetailMessage( String message )
+    public List getData()
     {
+        return data;
     }
 
-    public List<String> getEvents()
+    public String getFirstEvent()
     {
-        return events;
+        return (String) events.get( 0 );
+    }
+
+    public ReportEntry getFirstData()
+    {
+        return (ReportEntry) data.get( 0 );
+    }
+
+    public String getFirstStringData()
+    {
+        return (String) data.get( 0 );
     }
 
     public int getTestSucceeded()
@@ -136,21 +165,30 @@ public class MockReporter
         return testFailed.get();
     }
 
-    public void writeConsoleMessage( String message )
+
+    public void testAssumptionFailure( ReportEntry report )
     {
+        events.add( TEST_ASSUMPTION_FAIL );
+        data.add( report );
+        testIgnored.incrementAndGet();
+
     }
 
-    public void testError( ReportEntry report )
+    public void writeTestOutput( String output, boolean stdout )
     {
-        testError.incrementAndGet();
+        //To change body of implemented methods use File | Settings | File Templates.
     }
 
-    public void testFailed( ReportEntry report )
+    public void writeMessage( String message )
     {
-        testFailed.incrementAndGet();
+        events.add( CONSOLE_OUTPUT );
+        data.add( message );
+        //To change body of implemented methods use File | Settings | File Templates.
     }
 
-    public void testAssumptionFailure( ReportEntry report )
+    public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
     {
+        events.add( stdout ? STDOUT : STDERR );
+        data.add( new String( buf, off, len ) );
     }
 }

Copied: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/TestSetMockReporterFactory.java (from r1097226, maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ClassesParallelRunListener.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/TestSetMockReporterFactory.java?p2=maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/TestSetMockReporterFactory.java&p1=maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ClassesParallelRunListener.java&r1=1097226&r2=1097246&rev=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/ClassesParallelRunListener.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/TestSetMockReporterFactory.java Wed Apr 27 21:20:12 2011
@@ -1,4 +1,4 @@
-package org.apache.maven.surefire.junitcore;
+package org.apache.maven.plugin.surefire.booterclient;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -19,32 +19,29 @@ package org.apache.maven.surefire.junitc
  * under the License.
  */
 
+import java.io.File;
+import java.util.ArrayList;
+import org.apache.maven.plugin.surefire.report.ReporterManagerFactory;
+import org.apache.maven.surefire.report.DefaultConsoleReporter;
+import org.apache.maven.surefire.report.DirectConsoleReporter;
 import org.apache.maven.surefire.report.ReporterConfiguration;
-import org.apache.maven.surefire.report.ReporterFactory;
-import org.apache.maven.surefire.testset.TestSetFailedException;
-
-import java.util.Map;
+import org.apache.maven.surefire.report.RunListener;
 
 /**
  * @author Kristian Rosenvold
  */
-public class ClassesParallelRunListener
-    extends ConcurrentReporterManager
+public class TestSetMockReporterFactory extends ReporterManagerFactory
 {
-    public ClassesParallelRunListener( Map<String, TestSet> classMethodCounts, ReporterFactory reporterFactory,
-                                       ReporterConfiguration reporterConfiguration )
-        throws TestSetFailedException
+    public TestSetMockReporterFactory(  )
     {
-        super( reporterFactory, false, reporterConfiguration, classMethodCounts );
+        super( Thread.currentThread().getContextClassLoader(), new ReporterConfiguration(new File("."), Boolean.TRUE), new ArrayList( ) );
     }
 
-    @Override
-    public void checkIfTestSetCanBeReported( TestSet testSetForTest )
-    {
-        TestSet currentlyAttached = TestSet.getThreadTestSet();
-        if ( currentlyAttached != null && currentlyAttached != testSetForTest )
-        {
-            currentlyAttached.setAllScheduled( getReporterManager() );
-        }
+    public DirectConsoleReporter createConsoleReporter() {
+        return new DefaultConsoleReporter(System.out);
+    }
+
+    public RunListener createReporter(){
+        return new MockReporter();
     }
 }

Copied: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java (from r1097226, maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/SupressFooterOutputConsumerProxy.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java?p2=maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java&p1=maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/SupressFooterOutputConsumerProxy.java&r1=1097226&r2=1097246&rev=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/SupressFooterOutputConsumerProxy.java (original)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java Wed Apr 27 21:20:12 2011
@@ -19,33 +19,42 @@ package org.apache.maven.plugin.surefire
  * under the License.
  */
 
+import org.apache.maven.surefire.report.StackTraceWriter;
+
 /**
- * Surefire output consumer that will take out the surefire footer
+ * Represents a deserialize stacktracewriter that has been
+ * marshalled across to the plugin from the fork.
+ * <p/>
+ * Might be better to represent this whole thing differently
  *
- * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
- * @version $Id$
- * @since 2.1
+ * @author Kristian Rosenvold
  */
-public class SupressFooterOutputConsumerProxy
-    extends OutputConsumerProxy
+public class DeserializedStacktraceWriter
+    implements StackTraceWriter
 {
+    private final String message;
+
+    private final String stackTrace;
 
-    /**
-     * Create a consumer that will delegate all calls to the next filter but {@link #consumeFooterLine(String)}
-     *
-     * @param nextFilter filter to delegate to
-     */
-    public SupressFooterOutputConsumerProxy( OutputConsumer nextFilter )
+    public DeserializedStacktraceWriter( String message, String stackTrace )
     {
-        super( nextFilter );
+        this.message = message;
+        this.stackTrace = stackTrace;
     }
 
-    /**
-     * Do nothing
-     */
-    public void consumeFooterLine( String line )
+    // Trimming or not is decided on the forking side
+    public String writeTraceToString()
     {
-        /* do nothing */
+        return stackTrace;
     }
 
+    public String writeTrimmedTraceToString()
+    {
+        return stackTrace;
+    }
+
+    public Throwable getThrowable()
+    {
+        return new Throwable( message );
+    }
 }

Propchange: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/DeserializedStacktraceWriter.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java?rev=1097246&view=auto
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java (added)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java Wed Apr 27 21:20:12 2011
@@ -0,0 +1,247 @@
+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 java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import org.apache.maven.surefire.booter.ForkingRunListener;
+import org.apache.maven.surefire.report.CategorizedReportEntry;
+import org.apache.maven.surefire.report.ConsoleOutputReceiver;
+import org.apache.maven.surefire.report.DirectConsoleReporter;
+import org.apache.maven.surefire.report.ReportEntry;
+import org.apache.maven.surefire.report.ReporterException;
+import org.apache.maven.surefire.report.ReporterFactory;
+import org.apache.maven.surefire.report.RunListener;
+import org.apache.maven.surefire.report.SimpleReportEntry;
+import org.apache.maven.surefire.report.StackTraceWriter;
+import org.apache.maven.surefire.util.NestedRuntimeException;
+import org.apache.maven.surefire.util.internal.StringUtils;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+/**
+ * Knows how to reconstruct *all* the state transmitted over stdout by the forked process.
+ *
+ * @author Kristian Rosenvold
+ */
+public class ForkClient
+    implements StreamConsumer
+{
+    private final ReporterFactory providerReporterFactory;
+
+    private final Map testSetReporters = Collections.synchronizedMap( new HashMap() );
+
+    private final Properties testVmSystemProperties;
+
+    public ForkClient( ReporterFactory providerReporterFactory, Properties testVmSystemProperties )
+    {
+        this.providerReporterFactory = providerReporterFactory;
+        this.testVmSystemProperties = testVmSystemProperties;
+    }
+
+    public Properties getTestVmSystemProperties()
+    {
+        return testVmSystemProperties;
+    }
+
+    public void consumeLine( String s )
+    {
+        try
+        {
+            //System.out.println("Recv:" + s.substring( 0, s.length() ));
+            if ( s.length() == 0 )
+            {
+                return;
+            }
+            final byte operationId = (byte) s.charAt( 0 );
+            int commma = s.indexOf( ",", 3 );
+            if ( commma < 0 )
+            {
+                System.out.println( ">" + s );
+                return;
+            }
+            final Integer channelNumber = new Integer( Integer.parseInt( s.substring( 2, commma ), 16 ) );
+            RunListener reporter = (RunListener) testSetReporters.get( channelNumber );
+            if ( reporter == null )
+            {
+                reporter = providerReporterFactory.createReporter();
+                //reporter = new AsynchRunListener( reporter, "ForkClient" );
+                testSetReporters.put( channelNumber, reporter );
+            }
+            int rest = s.indexOf( ",", commma );
+            final String remaining = s.substring( rest + 1 );
+
+            switch ( operationId )
+            {
+                case ForkingRunListener.BOOTERCODE_TESTSET_STARTING:
+                    reporter.testSetStarting( createReportEntry( new StringTokenizer( remaining, "," ) ) );
+                    break;
+                case ForkingRunListener.BOOTERCODE_TESTSET_COMPLETED:
+                    reporter.testSetCompleted( createReportEntry( new StringTokenizer( remaining, "," ) ) );
+                    break;
+                case ForkingRunListener.BOOTERCODE_TEST_STARTING:
+                    reporter.testStarting( createReportEntry( new StringTokenizer( remaining, "," ) ) );
+                    break;
+                case ForkingRunListener.BOOTERCODE_TEST_SUCCEEDED:
+                    reporter.testSucceeded( createReportEntry( new StringTokenizer( remaining, "," ) ) );
+                    break;
+                case ForkingRunListener.BOOTERCODE_TEST_FAILED:
+                    reporter.testFailed( createReportEntry( new StringTokenizer( remaining, "," ) ) );
+                    break;
+                case ForkingRunListener.BOOTERCODE_TEST_SKIPPED:
+                    reporter.testSkipped( createReportEntry( new StringTokenizer( remaining, "," ) ) );
+                    break;
+                case ForkingRunListener.BOOTERCODE_TEST_ERROR:
+                    reporter.testError( createReportEntry( new StringTokenizer( remaining, "," ) ) );
+                    break;
+                case ForkingRunListener.BOOTERCODE_TEST_ASSUMPTIONFAILURE:
+                    reporter.testAssumptionFailure( createReportEntry( new StringTokenizer( remaining, "," ) ) );
+                    break;
+                case ForkingRunListener.BOOTERCODE_SYSPROPS:
+                    int keyEnd = remaining.indexOf( "," );
+                    StringWriter key = new StringWriter();
+                    StringWriter value = new StringWriter();
+                    StringUtils.unescapeJava( key, remaining.substring( 0, keyEnd ) );
+                    StringUtils.unescapeJava( value, remaining.substring( keyEnd + 1 ) );
+
+                    synchronized ( testVmSystemProperties )
+                    {
+                        testVmSystemProperties.put( key, value );
+                    }
+                    break;
+                case ForkingRunListener.BOOTERCODE_STDOUT:
+                    byte[] bytes = new byte[remaining.length() * 2];
+                    int len = StringUtils.unescapeJava( bytes, remaining );
+                    ( (ConsoleOutputReceiver) reporter ).writeTestOutput( bytes, 0, len, true );
+                    break;
+                case ForkingRunListener.BOOTERCODE_STDERR:
+                    bytes = new byte[remaining.length() * 2];
+                    len = StringUtils.unescapeJava( bytes, remaining );
+                    ( (ConsoleOutputReceiver) reporter ).writeTestOutput( bytes, 0, len, false );
+                    break;
+                case ForkingRunListener.BOOTERCODE_CONSOLE:
+                    ( (DirectConsoleReporter) reporter ).writeMessage( createConsoleMessage( remaining ) );
+                    break;
+                default:
+                    System.out.println( ">" + s );
+            }
+        }
+        catch ( NumberFormatException e )
+        {
+            System.out.println( ">" + s );
+        }
+        catch ( ReporterException e )
+        {
+            throw new NestedRuntimeException( e );
+        }
+    }
+
+    public void consumeMultiLineContent( String s )
+        throws IOException
+    {
+        BufferedReader stringReader = new BufferedReader( new StringReader( s ) );
+        String s1;
+        while ( ( s1 = stringReader.readLine() ) != null )
+        {
+            consumeLine( s1 );
+        }
+    }
+
+    private String createConsoleMessage( String remaining )
+    {
+        return unescape( remaining );
+    }
+
+    private ReportEntry createReportEntry( StringTokenizer tokens )
+    {
+        try
+        {
+            String source = tokens.nextToken();
+            String name = tokens.nextToken();
+            String group = nullableCsv( tokens.nextToken() );
+            String elapsedStr = tokens.nextToken();
+            Integer elapsed = "null".equals( elapsedStr ) ? null : Integer.decode( elapsedStr );
+            final StackTraceWriter stackTraceWriter =
+                tokens.hasMoreTokens() ? deserializeStackStraceWriter( tokens ) : null;
+
+            return group != null
+                ? new CategorizedReportEntry( source, name, group, stackTraceWriter, elapsed )
+                : new SimpleReportEntry( source, name, stackTraceWriter, elapsed );
+        }
+        catch ( RuntimeException e )
+        {
+            throw new RuntimeException( tokens.toString(), e );
+        }
+    }
+
+    private StackTraceWriter deserializeStackStraceWriter( StringTokenizer tokens )
+    {
+        StackTraceWriter stackTraceWriter;
+        String stackTraceMessage = nullableCsv( tokens.nextToken() );
+        String stackTrace = nullableCsv( tokens.nextToken() );
+        stackTraceWriter =
+            stackTrace != null ? new DeserializedStacktraceWriter( stackTraceMessage, stackTrace ) : null;
+        return stackTraceWriter;
+    }
+
+    private String nullableCsv( String source )
+    {
+        if ( "null".equals( source ) )
+        {
+            return null;
+        }
+        return unescape( source );
+    }
+
+    private String unescape( String source )
+    {
+        StringWriter stringWriter = new StringWriter( source.length() );
+
+        StringUtils.unescapeJava( stringWriter, source );
+        return stringWriter.getBuffer().toString();
+    }
+
+    /**
+     * Used when getting reporters on the plugin side of a fork.
+     *
+     * @param channelNumber The logical channel number
+     * @return A mock provider reporter
+     */
+    public RunListener getReporter( Integer channelNumber )
+    {
+        return (RunListener) testSetReporters.get( channelNumber );
+    }
+
+
+    public void close()
+    {
+        /*Iterator iter = testSetReporters.values().iterator();
+        while( iter.hasNext() )
+        {
+            ((AsynchRunListener)iter.next()).close();
+        } */
+    }
+}

Propchange: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java?rev=1097246&view=auto
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java (added)
+++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java Wed Apr 27 21:20:12 2011
@@ -0,0 +1,115 @@
+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.util.internal.BlockingQueue;
+import org.apache.maven.surefire.util.internal.BlockingQueueFactory;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+/**
+ * Knows how to reconstruct *all* the state transmitted over stdout by the forked process.
+ *
+ * @author Kristian Rosenvold
+ */
+public class ThreadedStreamConsumer
+    implements StreamConsumer
+{
+
+    private final BlockingQueue items = BlockingQueueFactory.createBlockingQueue();
+
+    private static final String poison = "Pioson";
+
+    private final Thread thread;
+
+    private final Pumper pumper;
+
+    private final long start = System.currentTimeMillis();
+
+    static class Pumper
+        implements Runnable
+    {
+        private final BlockingQueue queue;
+
+        private final StreamConsumer target;
+
+        private volatile InterruptedException interruptedException;
+
+
+        Pumper( BlockingQueue queue, StreamConsumer target )
+        {
+            this.queue = queue;
+            this.target = target;
+        }
+
+        public void run()
+        {
+            try
+            {
+                String item = (String) queue.take();
+                //noinspection StringEquality
+                while ( item != poison )
+                {
+                    target.consumeLine( item );
+                    item = (String) queue.take();
+                }
+            }
+            catch ( InterruptedException e )
+            {
+                this.interruptedException = e;
+            }
+        }
+
+        public InterruptedException getInterruptedException()
+        {
+            return interruptedException;
+        }
+    }
+
+    public ThreadedStreamConsumer( StreamConsumer target )
+    {
+        pumper = new Pumper( items, target );
+        thread = new Thread( pumper, "ThreadedStreamConsumer" );
+        thread.start();
+    }
+
+    public void consumeLine( String s )
+    {
+        items.add( s );
+    }
+
+
+    public void close()
+    {
+        try
+        {
+            items.add( poison );
+            thread.join();
+            //noinspection ThrowableResultOfMethodCallIgnored
+            if ( pumper.getInterruptedException() != null )
+            {
+                throw pumper.getInterruptedException();
+            }
+        }
+        catch ( InterruptedException e )
+        {
+            throw new RuntimeException( e );
+        }
+    }
+}

Propchange: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native