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 [3/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...

Added: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AsynchRunListener.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AsynchRunListener.java?rev=1097246&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AsynchRunListener.java (added)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AsynchRunListener.java Wed Apr 27 21:20:12 2011
@@ -0,0 +1,261 @@
+package org.apache.maven.surefire.report;
+
+/*
+ * 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.util.concurrent.LinkedBlockingQueue;
+import org.apache.maven.surefire.util.internal.ByteBuffer;
+
+/**
+ * Transfers further processing of the request to a different thread,
+ * returning immediately to calling code.
+ * Deals with system.out/err from single-threaded processes.
+ * <p/>
+ */
+public class AsynchRunListener
+    implements RunListener, ConsoleOutputReceiver, DirectConsoleReporter
+{
+    private final LinkedBlockingQueue blockingQueue = new LinkedBlockingQueue();
+
+    private final Processor processor;
+
+    private final RunListener target;
+
+    private final ConsoleOutputReceiver consoleOutputReceiver;
+
+    private final Thread asynchRunListener;
+
+    static class Processor
+        implements Runnable
+    {
+        private final LinkedBlockingQueue blockingQueue;
+
+        private volatile InterruptedException exception;
+
+        Processor( LinkedBlockingQueue blockingQueue )
+        {
+            this.blockingQueue = blockingQueue;
+        }
+
+        public void run()
+        {
+            try
+            {
+                Runnable take;
+                take = (Runnable) blockingQueue.take();
+                while ( take != poison )
+                {
+                    take.run();
+                    take = (Runnable) blockingQueue.take();
+                }
+            }
+            catch ( InterruptedException e )
+            {
+                this.exception = e;
+            }
+        }
+
+        public InterruptedException getException()
+        {
+            return exception;
+        }
+    }
+
+    public AsynchRunListener( RunListener target, String role )
+    {
+        this.processor = new Processor( blockingQueue );
+        this.target = target;
+        consoleOutputReceiver = (ConsoleOutputReceiver) target;
+        asynchRunListener = new Thread( processor, "AsynchRunListener" + role );
+        asynchRunListener.start();
+    }
+
+    public void testSetStarting( final ReportEntry report )
+    {
+        blockingQueue.add( new Runnable()
+        {
+            public void run()
+            {
+                target.testSetStarting( report );
+            }
+        } );
+    }
+
+    public void testSetCompleted( final ReportEntry report )
+    {
+        blockingQueue.add( new Runnable()
+        {
+            public void run()
+            {
+                target.testSetCompleted( report );
+            }
+        } );
+    }
+
+    public void testStarting( final ReportEntry report )
+    {
+        blockingQueue.add( new Runnable()
+        {
+            public void run()
+            {
+                target.testStarting( report );
+            }
+        } );
+    }
+
+    public void testSucceeded( final ReportEntry report )
+    {
+        blockingQueue.add( new Runnable()
+        {
+            public void run()
+            {
+                target.testSucceeded( report );
+            }
+        } );
+    }
+
+    public void testAssumptionFailure( final ReportEntry report )
+    {
+        blockingQueue.add( new Runnable()
+        {
+            public void run()
+            {
+                target.testAssumptionFailure( report );
+            }
+        } );
+
+    }
+
+    public void testError( final ReportEntry report )
+    {
+        blockingQueue.add( new Runnable()
+        {
+            public void run()
+            {
+                target.testError( report );
+            }
+        } );
+    }
+
+    public void testFailed( final ReportEntry report )
+    {
+        blockingQueue.add( new Runnable()
+        {
+            public void run()
+            {
+                target.testFailed( report );
+            }
+        } );
+    }
+
+    public void testSkipped( final ReportEntry report )
+    {
+        blockingQueue.add( new Runnable()
+        {
+            public void run()
+            {
+                target.testSkipped( report );
+            }
+        } );
+    }
+
+    static class JoinableTestOutput
+        implements Runnable
+    {
+        final byte[] buf;
+
+        final int off;
+
+        final int len;
+
+        final boolean stdout;
+
+        private final ConsoleOutputReceiver consoleOutputReceiver;
+
+        JoinableTestOutput( final byte[] buf, final int off, final int len, final boolean stdout,
+                            ConsoleOutputReceiver consoleOutputReceiver )
+        {
+            this.buf = ByteBuffer.copy( buf, off, len );
+            this.off = 0;
+            this.len = len;
+            this.stdout = stdout;
+            this.consoleOutputReceiver = consoleOutputReceiver;
+        }
+
+        public void run()
+        {
+            consoleOutputReceiver.writeTestOutput( buf, off, len, stdout );
+        }
+
+        public boolean canJoin( Runnable other )
+        {
+            return other instanceof JoinableTestOutput && ( (JoinableTestOutput) other ).stdout == this.stdout;
+        }
+
+        public JoinableTestOutput append( JoinableTestOutput other )
+        {
+            byte[] combined = ByteBuffer.join( buf, this.off, this.len, other.buf, other.off, other.len );
+            return new JoinableTestOutput( combined, 0, combined.length, stdout, consoleOutputReceiver );
+        }
+
+    }
+
+    public void writeTestOutput( final byte[] buf, final int off, final int len, final boolean stdout )
+    {
+        blockingQueue.add( new JoinableTestOutput( buf, off, len, stdout, consoleOutputReceiver ) );
+    }
+
+    public void writeMessage( final String message )
+    {
+        blockingQueue.add( new Runnable()
+        {
+            public void run()
+            {
+                ( (DirectConsoleReporter) consoleOutputReceiver ).writeMessage( message );
+            }
+        } );
+    }
+
+    private static final Runnable poison = new Runnable()
+    {
+        public void run()
+        {
+        }
+    };
+
+    public void close()
+        throws ReporterException
+    {
+        try
+        {
+            blockingQueue.add( poison );
+            asynchRunListener.join();
+            final InterruptedException exception = processor.getException();
+            if ( exception != null )
+            {
+                throw exception;
+            }
+        }
+        catch ( InterruptedException e )
+        {
+            throw new ReporterException( "When waiting", e );
+        }
+
+    }
+}

Propchange: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/AsynchRunListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/CategorizedReportEntry.java Wed Apr 27 21:20:12 2011
@@ -36,11 +36,11 @@ public class CategorizedReportEntry
 
     public CategorizedReportEntry( String source, String name, String group, String message )
     {
-        this( source, name, group, message, null, null );
+        this( source, name, group, null, null );
     }
 
-    private CategorizedReportEntry( String source, String name, String group, String message,
-                                   StackTraceWriter stackTraceWriter, Integer elapsed )
+    public CategorizedReportEntry( String source, String name, String group, StackTraceWriter stackTraceWriter,
+                                   Integer elapsed )
     {
         super( source, name, stackTraceWriter, elapsed );
         this.group = group;

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputCapture.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputCapture.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputCapture.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputCapture.java Wed Apr 27 21:20:12 2011
@@ -22,6 +22,7 @@ package org.apache.maven.surefire.report
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.PrintStream;
+import org.apache.maven.surefire.util.internal.ByteBuffer;
 
 /**
  * Deals with system.out/err.
@@ -29,25 +30,14 @@ import java.io.PrintStream;
  */
 public class ConsoleOutputCapture
 {
-
-    private static final PrintStream oldOut = System.out;
-
-    private static final PrintStream oldErr = System.err;
-
-    public ConsoleOutputCapture( ConsoleOutputReceiver target )
+    public static void startCapture( ConsoleOutputReceiver target )
     {
         System.setOut( new ForwardingPrintStream( true, target ) );
 
         System.setErr( new ForwardingPrintStream( false, target ) );
     }
 
-    public void restoreStreams()
-    {
-        System.setOut( oldOut );
-        System.setErr( oldErr );
-    }
-
-    static class ForwardingPrintStream
+    private static class ForwardingPrintStream
         extends PrintStream
     {
         private final boolean isStdout;
@@ -72,6 +62,15 @@ public class ConsoleOutputCapture
             target.writeTestOutput( b, 0, b.length, isStdout );
         }
 
+        static final byte[] newline = new byte[]{ (byte) '\n' };
+
+        public void println( String s )
+        {
+            final byte[] bytes = s.getBytes();
+            final byte[] join = ByteBuffer.join( bytes, 0, bytes.length, newline, 0, 1 );
+            target.writeTestOutput( join, 0, join.length, isStdout );
+        }
+
         public void close()
         {
         }

Copied: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputFileReporter.java (from r1097226, maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/FileOutputConsumerProxy.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputFileReporter.java?p2=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputFileReporter.java&p1=maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/FileOutputConsumerProxy.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/FileOutputConsumerProxy.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputFileReporter.java Wed Apr 27 21:20:12 2011
@@ -1,4 +1,4 @@
-package org.apache.maven.plugin.surefire.booterclient.output;
+package org.apache.maven.surefire.report;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -19,18 +19,16 @@ package org.apache.maven.plugin.surefire
  * under the License.
  */
 
-import org.apache.maven.surefire.report.ReportEntry;
-import org.apache.maven.surefire.util.NestedRuntimeException;
-
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
+import org.apache.maven.surefire.util.NestedRuntimeException;
 
 /**
- * Surefire output consumer proxy that writes test output to a {@link File} for each test suite.
- *
+ * Surefire output consumer proxy that writes test output to a {@link java.io.File} for each test suite.
+ * <p/>
  * This class is not threadsafe, but can be encapsulated with a SynchronizedOutputConsumer. It may still be
  * accessed from different threads (serially).
  *
@@ -38,8 +36,8 @@ import java.io.PrintWriter;
  * @version $Id$
  * @since 2.1
  */
-public class FileOutputConsumerProxy
-    extends OutputConsumerProxy
+public class ConsoleOutputFileReporter
+    implements Reporter
 {
 
     private static final String LINE_SEPARATOR = System.getProperty( "line.separator" );
@@ -51,15 +49,12 @@ public class FileOutputConsumerProxy
     private volatile PrintWriter printWriter;
 
     /**
-     * Create a consumer that will write to a {@link File} for each test
-     *
-     * @param outputConsumer   the output consumer
-     * @param reportsDirectory directory where files will be saved
+     * Create a consumer that will write to a {@link java.io.File} for each test
      */
-    public FileOutputConsumerProxy( OutputConsumer outputConsumer, File reportsDirectory )
+
+    public ConsoleOutputFileReporter( ReporterConfiguration reporterConfiguration )
     {
-        super( outputConsumer );
-        this.reportsDirectory = reportsDirectory;
+        this.reportsDirectory = reporterConfiguration.getReportsDirectory();
     }
 
     public void testSetStarting( ReportEntry reportEntry )
@@ -84,10 +79,10 @@ public class FileOutputConsumerProxy
         {
             throw new NestedRuntimeException( e );
         }
-        super.testSetStarting( reportEntry );
     }
 
-    public void testSetCompleted()
+    public void testSetCompleted( ReportEntry report )
+        throws ReporterException
     {
         if ( printWriter == null )
         {
@@ -101,30 +96,72 @@ public class FileOutputConsumerProxy
         }
         printWriter.close();
         this.printWriter = null;
-        super.testSetCompleted();
     }
 
+    public void testStarting( ReportEntry report )
+    {
+    }
+
+    public void testSucceeded( ReportEntry report )
+    {
+    }
+
+    public void testError( ReportEntry report )
+    {
+    }
+
+    public void testFailed( ReportEntry report )
+    {
+    }
+
+    public void testSkipped( ReportEntry report )
+    {
+    }
+
+    public void testError( ReportEntry report, String stdOut, String stdErr )
+    {
+    }
+
+    public void testFailed( ReportEntry report, String stdOut, String stdErr )
+    {
+    }
+
+    public void writeMessage( String message )
+    {
+    }
+
+    public void writeMessage( byte[] b, int off, int len )
+    {
+        consumeOutputLine( new String( b, off, len ) );
+    }
+
+    public void writeDetailMessage( String message )
+    {
+    }
+
+    public void reset()
+    {
+    }
+
+
     /**
      * Write the output to the current test file
      * <p/>
      */
-    public void consumeOutputLine( String line )
+    private void consumeOutputLine( String line )
     {
         if ( printWriter == null )
         {
             outputBuffer.append( line );
-            outputBuffer.append( LINE_SEPARATOR );
             return;
         }
 
         if ( outputBuffer.length() > 0 )
         {
             printWriter.write( outputBuffer.toString() );
-            printWriter.write( LINE_SEPARATOR );
             outputBuffer.setLength( 0 );
         }
         printWriter.write( line );
-        printWriter.write( LINE_SEPARATOR );
     }
 
 }

Propchange: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputFileReporter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputFileReporter.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Copied: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/DefaultConsoleReporter.java (from r1097226, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/RunReporter.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/DefaultConsoleReporter.java?p2=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/DefaultConsoleReporter.java&p1=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/RunReporter.java&r1=1097226&r2=1097246&rev=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/RunReporter.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/DefaultConsoleReporter.java Wed Apr 27 21:20:12 2011
@@ -1,38 +1,41 @@
-package org.apache.maven.surefire.report;
-
-/*
- * 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.
- */
-
-/**
- * A reporter that is aware of run start/run finished events
- */
-public interface RunReporter
-{
-    /**
-     * Indicates the start of the entire test run.
-     * Only called on the first provider, and just by the ReporterFactory
-     */
-    void runStarting();
-
-    /**
-     * Indicates the end of the entire test run
-     * Only called on the first provider, and just by the ReporterFactory
-     */
-    void runCompleted();
-}
+package org.apache.maven.surefire.report;
+
+/*
+ * 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.PrintStream;
+
+/**
+ * @author <a href="mailto:kristian@zenior.no">Kristian Rosenvold</a>
+ */
+public class DefaultConsoleReporter
+    implements DirectConsoleReporter
+{
+    private final PrintStream systemOut;
+
+    public DefaultConsoleReporter( PrintStream systemOut )
+    {
+        this.systemOut = systemOut;
+    }
+
+    public void writeMessage( String message )
+    {
+        systemOut.println( message );
+    }
+}

Propchange: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/DefaultConsoleReporter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ForwardingRunListener.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ForwardingRunListener.java?rev=1097246&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ForwardingRunListener.java (added)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ForwardingRunListener.java Wed Apr 27 21:20:12 2011
@@ -0,0 +1,76 @@
+package org.apache.maven.surefire.report;
+
+/*
+ * 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.
+ */
+
+/**
+ * Deals with system.out/err from single-threaded processes.
+ * <p/>
+ */
+public abstract class ForwardingRunListener
+    implements RunListener
+{
+    private final RunListener target;
+
+    protected ForwardingRunListener( RunListener target )
+    {
+        this.target = target;
+    }
+
+    public void testSetStarting( ReportEntry report )
+    {
+        target.testSetStarting( report );
+    }
+
+    public void testSetCompleted( ReportEntry report )
+    {
+        target.testSetCompleted( report );
+    }
+
+    public void testStarting( ReportEntry report )
+    {
+        target.testStarting( report );
+    }
+
+    public void testSucceeded( ReportEntry report )
+    {
+        target.testSucceeded( report );
+    }
+
+    public void testAssumptionFailure( ReportEntry report )
+    {
+        target.testAssumptionFailure( report );
+    }
+
+    public void testError( ReportEntry report )
+    {
+        target.testError( report );
+    }
+
+    public void testFailed( ReportEntry report )
+    {
+        target.testFailed( report );
+    }
+
+    public void testSkipped( ReportEntry report )
+    {
+        target.testSkipped( report );
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ForwardingRunListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/MulticastingReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/MulticastingReporter.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/MulticastingReporter.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/MulticastingReporter.java Wed Apr 27 21:20:12 2011
@@ -19,7 +19,6 @@ package org.apache.maven.surefire.report
  * under the License.
  */
 
-import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -28,153 +27,110 @@ import java.util.List;
  * @author Kristian Rosenvold
  */
 public class MulticastingReporter
-    implements RunReporter, Reporter
+    implements Reporter
 {
-    private final List target;
+    private final Reporter[] target;
+    private final int size;
 
     public MulticastingReporter( List target )
     {
-        this.target = target;
+        size = target.size();
+        this.target = (Reporter[]) target.toArray( new Reporter[target.size()] );
     }
 
     public void testSetStarting( ReportEntry report )
-        throws ReporterException
     {
-        for ( Iterator it = target.iterator(); it.hasNext(); )
-        {
-            ( (Reporter) it.next() ).testSetStarting( report );
+        for (int i = 0; i < size; i++){
+            target[i].testSetStarting( report );
         }
     }
 
     public void testSetCompleted( ReportEntry report )
     {
-        for ( Iterator it = target.iterator(); it.hasNext(); )
-        {
-            try
-            {
-                ( (Reporter) it.next() ).testSetCompleted( report );
-            }
-            catch ( ReporterException e )
-            {
-                // Added in commit r331325 in ReporterManager. This smells fishy. What's this about ?
-            }
-
-        }
-    }
-
-
-    public void runStarting()
-    {
-        for ( Iterator it = target.iterator(); it.hasNext(); )
-        {
-            Object next = it.next();
-            if ( next instanceof RunReporter )
-            {
-                ( (RunReporter) next ).runStarting();
-            }
-        }
-    }
-
-    public void runCompleted()
-    {
-        for ( Iterator it = target.iterator(); it.hasNext(); )
-        {
-            Object next = it.next();
-            if ( next instanceof RunReporter )
-            {
-                ( (RunReporter) next ).runCompleted();
-            }
+        for (int i = 0; i < size; i++){
+            target[i].testSetCompleted( report );
         }
     }
 
 
     public void testStarting( ReportEntry report )
     {
-        for ( Iterator it = target.iterator(); it.hasNext(); )
-        {
-            ( (Reporter) it.next() ).testStarting( report );
+        for (int i = 0; i < size; i++){
+            target[i].testStarting( report );
         }
     }
 
     public void testSucceeded( ReportEntry report )
     {
-        for ( Iterator it = target.iterator(); it.hasNext(); )
-        {
-            ( (Reporter) it.next() ).testSucceeded( report );
+        for (int i = 0; i < size; i++){
+            target[i].testSucceeded( report );
         }
     }
 
     public void testError( ReportEntry report, String stdOut, String stdErr )
     {
-        for ( Iterator it = target.iterator(); it.hasNext(); )
-        {
-            ( (Reporter) it.next() ).testError( report, stdOut, stdErr );
+        for (int i = 0; i < size; i++){
+            target[i].testError( report, stdOut, stdErr );
         }
     }
 
     public void testFailed( ReportEntry report, String stdOut, String stdErr )
     {
-        for ( Iterator it = target.iterator(); it.hasNext(); )
-        {
-            ( (Reporter) it.next() ).testFailed( report, stdOut, stdErr );
+        for (int i = 0; i < size; i++){
+            target[i].testFailed( report, stdOut, stdErr );
         }
     }
 
     public void testSkipped( ReportEntry report )
     {
-        for ( Iterator it = target.iterator(); it.hasNext(); )
-        {
-            ( (Reporter) it.next() ).testSkipped( report );
+        for (int i = 0; i < size; i++){
+            target[i].testSkipped( report );
         }
     }
 
     public void writeDetailMessage( String message )
     {
-        for ( Iterator it = target.iterator(); it.hasNext(); )
-        {
-            Reporter reporter = ( (Reporter) it.next() );
-            reporter.writeDetailMessage( message );
+        for (int i = 0; i < size; i++){
+            target[i].writeDetailMessage( message );
         }
     }
 
     public void writeMessage( String message )
     {
-        for ( Iterator it = target.iterator(); it.hasNext(); )
-        {
-            ( (Reporter) it.next() ).writeMessage( message );
+        for (int i = 0; i < size; i++){
+            target[i].writeMessage( message );
         }
     }
 
-    public void writeFooter( String footer )
+    public void writeMessage( byte[] b, int off, int len )
     {
-        for ( Iterator it = target.iterator(); it.hasNext(); )
-        {
-            ( (Reporter) it.next() ).writeFooter( footer );
+        for (int i = 0; i < size; i++){
+            target[i].writeMessage( b, off, len );
         }
     }
 
     public void reset()
     {
-        for ( Iterator it = target.iterator(); it.hasNext(); )
-        {
-            ( (Reporter) it.next() ).reset();
+        for (int i = 0; i < size; i++){
+            target[i].reset();
         }
     }
 
     public void testError( ReportEntry report )
     {
-        for ( Iterator it = target.iterator(); it.hasNext(); )
-        {
-            ( (Reporter) it.next() ).testError( report );
+        for (int i = 0; i < size; i++){
+            target[i].testError( report );
         }
     }
 
     public void testFailed( ReportEntry report )
     {
-        for ( Iterator it = target.iterator(); it.hasNext(); )
-        {
-            ( (Reporter) it.next() ).testFailed( report );
+        for (int i = 0; i < size; i++){
+            target[i].testFailed( report );
         }
     }
 
+
+    public void close(){
+    }
 }

Copied: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/PrettyPrintXMLWriter.java (from r1097226, maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/PrettyPrintXMLWriter.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/PrettyPrintXMLWriter.java?p2=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/PrettyPrintXMLWriter.java&p1=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/PrettyPrintXMLWriter.java&r1=1097226&r2=1097246&rev=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/PrettyPrintXMLWriter.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/PrettyPrintXMLWriter.java Wed Apr 27 21:20:12 2011
@@ -1,4 +1,4 @@
-package org.apache.maven.surefire.util;
+package org.apache.maven.surefire.report;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -19,10 +19,9 @@ package org.apache.maven.surefire.util;
  * under the License.
  */
 
-import org.codehaus.plexus.util.xml.XMLWriter;
-
 import java.io.PrintWriter;
 import java.util.LinkedList;
+import org.codehaus.plexus.util.xml.XMLWriter;
 
 public class PrettyPrintXMLWriter
     implements XMLWriter
@@ -120,7 +119,7 @@ public class PrettyPrintXMLWriter
 
     private static String escapeXml( String text )
     {
-        StringBuffer sb = new StringBuffer ( text.length() * 2 );
+        StringBuffer sb = new StringBuffer( text.length() * 2 );
         for ( int i = 0; i < text.length(); i++ )
         {
             char c = text.charAt( i );

Propchange: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/PrettyPrintXMLWriter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/PrettyPrintXMLWriter.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/Reporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/Reporter.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/Reporter.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/Reporter.java Wed Apr 27 21:20:12 2011
@@ -107,6 +107,8 @@ public interface Reporter
      */
     void writeMessage( String message );
 
+    void writeMessage( byte[] b, int off, int len );
+
     /**
      * Writes a detailed message that will not necessarily be displayed in all channels.
      * This is controlled by reportFormat attribute on the plugin.
@@ -120,6 +122,4 @@ public interface Reporter
      * same thread.
      */
     void reset();
-
-    void writeFooter( String footer );
 }

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterConfiguration.java Wed Apr 27 21:20:12 2011
@@ -21,23 +21,36 @@ package org.apache.maven.surefire.report
 
 import java.io.File;
 import java.io.PrintStream;
+import java.util.ArrayList;
 import java.util.List;
-import java.util.Timer;
+import java.util.Properties;
 
 /**
+ * The configuration of the reporter. Most of this stuff is not relevant for the providers
+ * and should be moved out of the api.
+ * <p/>
+ * TODO: Split this class in 2, or more. Extract classnames of reporters to somewhere else.
+ * This class seems to be the focal point of all the bad code smells left in reporting ;)
+ *
  * @author Kristian Rosenvold
  */
 public class ReporterConfiguration
 {
-    private final List reports;
-
     private final File reportsDirectory;
 
     private final PrintStream originalSystemOut;
 
     private final PrintStream originalSystemErr;
 
-    private final Integer forkTimeout;
+    private final Properties testVmSystemProperties;
+
+    private final String consoleReporter;
+
+    private final String fileReporter;
+
+    private final String xmlReporter;
+
+    private final String consoleOutputFileReporterName;
 
     /**
      * A non-null Boolean value
@@ -46,13 +59,17 @@ public class ReporterConfiguration
 
     private volatile boolean timedOut = false;
 
-
-    public ReporterConfiguration( List reports, File reportsDirectory, Boolean trimStackTrace, Integer forkWithTimeout )
+    public ReporterConfiguration( File reportsDirectory, Boolean trimStackTrace, String consoleReporter,
+                                  String fileReporter, String xmlReporter, String consoleOutputFileReporterName )
     {
-        this.reports = reports;
         this.reportsDirectory = reportsDirectory;
+        this.consoleReporter = consoleReporter;
+        this.fileReporter = fileReporter;
+        this.xmlReporter = xmlReporter;
         this.trimStackTrace = trimStackTrace;
-        this.forkTimeout = forkWithTimeout;
+        this.consoleOutputFileReporterName = consoleOutputFileReporterName;
+
+        testVmSystemProperties = new Properties();
         /*
         * While this may seem slightly odd, when this object is constructted no user code has been run
         * (including classloading), and we can be guaranteed that no-one has modified System.out/System.err.
@@ -60,13 +77,11 @@ public class ReporterConfiguration
          */
         this.originalSystemOut = System.out;
         this.originalSystemErr = System.err;
-
     }
 
-    // todo: remove once we build with 2.7.2
-    public ReporterConfiguration( List reports, File reportsDirectory, Boolean trimStackTrace )
+    public ReporterConfiguration( File reportsDirectory, Boolean trimStackTrace )
     {
-        this( reports, reportsDirectory, trimStackTrace, null );
+        this( reportsDirectory, trimStackTrace, null, null, null, null );
     }
 
     /**
@@ -97,6 +112,23 @@ public class ReporterConfiguration
      */
     public List getReports()
     {
+        ArrayList reports = new ArrayList();
+        if ( consoleReporter != null )
+        {
+            reports.add( consoleReporter );
+        }
+        if ( fileReporter != null )
+        {
+            reports.add( fileReporter );
+        }
+        if ( xmlReporter != null )
+        {
+            reports.add( xmlReporter );
+        }
+        if ( consoleOutputFileReporterName != null )
+        {
+            reports.add( consoleOutputFileReporterName );
+        }
         return reports;
     }
 
@@ -111,40 +143,38 @@ public class ReporterConfiguration
         return originalSystemOut;
     }
 
-    /**
-     * The original system err belonging to the (possibly forked) surefire process.
-     * Note that users of Reporter/ReporterFactory should normally not be using this.
-     *
-     * @return A printstream.
-     */
-    public PrintStream getOriginalSystemErr()
+    public Properties getTestVmSystemProperties()
     {
-        return originalSystemErr;
+        return testVmSystemProperties;
     }
 
-    /**
-     * Indicates that the test is running timed out, meaning this process could be abruptly killed.
-     * This will normally tell the reporter to delete result files upon startup.
-     *
-     * @return true if test run can be killed by timeout
-     */
-    public boolean isForkWithTimeout()
+    public void setTimedOut( boolean timedOut )
     {
-        return getForkTimeout() != null;
+        this.timedOut = timedOut;
     }
 
-    public Integer getForkTimeout()
+    public boolean isTimedOut()
     {
-        return forkTimeout;
+        return this.timedOut;
     }
 
-    public void setTimedOut( boolean timedOut )
+    public String getConsoleReporter()
     {
-        this.timedOut = timedOut;
+        return consoleReporter;
     }
 
-    public boolean isTimedOut()
+    public String getFileReporter()
     {
-        return this.timedOut;
+        return fileReporter;
+    }
+
+    public String getXmlReporter()
+    {
+        return xmlReporter;
+    }
+
+    public String getConsoleOutputFileReporterName()
+    {
+        return consoleOutputFileReporterName;
     }
 }

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterException.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterException.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterException.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterException.java Wed Apr 27 21:20:12 2011
@@ -19,7 +19,7 @@ package org.apache.maven.surefire.report
  * under the License.
  */
 
-import org.apache.maven.surefire.util.NestedCheckedException;
+import org.apache.maven.surefire.util.NestedRuntimeException;
 
 /**
  * Exception occurring during report generation.
@@ -27,7 +27,7 @@ import org.apache.maven.surefire.util.Ne
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  */
 public class ReporterException
-    extends NestedCheckedException
+    extends NestedRuntimeException
 {
     public ReporterException( String message, Exception nested )
     {

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterFactory.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterFactory.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterFactory.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ReporterFactory.java Wed Apr 27 21:20:12 2011
@@ -26,8 +26,6 @@ import org.apache.maven.surefire.suite.R
  */
 public interface ReporterFactory
 {
-    RunStatistics getGlobalRunStatistics();
-
     /**
      * Creates a reporter. The reporter is a singleton that is expected to be
      * used in the provider.
@@ -39,10 +37,17 @@ public interface ReporterFactory
     /**
      * Creates a ConsoleReporter, that allows providers to write messages to the running maven console.
      * This output is not associated with any thread/test and appears immediately.
+     *
      * @return a ConsoleReporter
      */
     DirectConsoleReporter createConsoleReporter();
 
-
+    /**
+     * Closes the factory, freeing resources allocated in the factory.
+     *
+     * @return The run result
+     */
     RunResult close();
+
+    RunStatistics getGlobalRunStatistics();
 }

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/RunListener.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/RunListener.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/RunListener.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/RunListener.java Wed Apr 27 21:20:12 2011
@@ -34,8 +34,7 @@ public interface RunListener
      * @param report the report entry describing the testset
      * @throws ReporterException When reporting fails
      */
-    void testSetStarting( ReportEntry report )
-        throws ReporterException;
+    void testSetStarting( ReportEntry report );
 
     /**
      * Indicates end of a given test-set
@@ -43,10 +42,7 @@ public interface RunListener
      * @param report the report entry describing the testset
      * @throws ReporterException When reporting fails
      */
-    void testSetCompleted( ReportEntry report )
-        throws ReporterException;
-
-    // Tests
+    void testSetCompleted( ReportEntry report );
 
     /**
      * Event fired when a test is about to start
@@ -85,6 +81,10 @@ public interface RunListener
      */
     void testFailed( ReportEntry report );
 
-
+    /**
+     * Event fired when a test is skipped
+     *
+     * @param report The report entry to log for
+     */
     void testSkipped( ReportEntry report );
 }

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/RunStatistics.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/RunStatistics.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/RunStatistics.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/RunStatistics.java Wed Apr 27 21:20:12 2011
@@ -19,11 +19,10 @@ package org.apache.maven.surefire.report
  * under the License.
  */
 
-import org.apache.maven.surefire.util.internal.StringUtils;
-
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import org.apache.maven.surefire.util.internal.StringUtils;
 
 /**
  * @author Kristian Rosenvold
@@ -56,12 +55,12 @@ public class RunStatistics
     // Todo remove when building with 2.7.2
     public void addFailureSource( String failureSource )
     {
-    	failureSources.addSource( failureSource );
+        failureSources.addSource( failureSource );
     }
 
-    public void addFailureSource( String failureSource, StackTraceWriter stackTraceWriter  )
+    public void addFailureSource( String failureSource, StackTraceWriter stackTraceWriter )
     {
-    	failureSources.addSource( failureSource, stackTraceWriter );
+        failureSources.addSource( failureSource, stackTraceWriter );
     }
 
     public Collection getErrorSources()
@@ -74,6 +73,7 @@ public class RunStatistics
         return failureSources.getListOfSources();
     }
 
+
     private static class Sources
     {
         private final Collection listOfSources = new ArrayList();
@@ -82,18 +82,20 @@ public class RunStatistics
         {
             synchronized ( listOfSources )
             {
-                listOfSources.add( source );  		
+                listOfSources.add( source );
             }
         }
 
         void addSource( String source, StackTraceWriter stackTraceWriter )
         {
             String message = getMessageOfThrowable( stackTraceWriter );
-            String extendedSource = StringUtils.isBlank( message ) ? source : source + ": " + trimToSingleLine(message);
+            String extendedSource =
+                StringUtils.isBlank( message ) ? source : source + ": " + trimToSingleLine( message );
             addSource( extendedSource );
         }
 
-        private String trimToSingleLine(String str){
+        private String trimToSingleLine( String str )
+        {
             int i = str.indexOf( "\n" );
             return i >= 0 ? str.substring( 0, i ) : str;
         }

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/TestSetRunListener.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/TestSetRunListener.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/TestSetRunListener.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/TestSetRunListener.java Wed Apr 27 21:20:12 2011
@@ -19,31 +19,23 @@ package org.apache.maven.surefire.report
  * under the License.
  */
 
-import org.apache.maven.surefire.util.internal.ByteBuffer;
-
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
+import org.apache.maven.surefire.util.internal.ByteBuffer;
 
 /**
  * Reports data for a single test set.
  * <p/>
- * Synchronization/Threading note:
- * <p/>
- * This design is really only good for single-threaded test execution. With the use of the additional
- * SynchronizedReporterManager you can get a buggy version that sort-of supports multithreading.
- * <p/>
- * The underlying providers are singletons and keep state per ReporterManager instance
- * <p/>
- * The solution to this problem involves making a clearer separation between test-result collection and reporting,
- * preferably removing singleton state approach out of the reporting interface.
- * <p/>
  */
 public class TestSetRunListener
-    implements RunListener, RunReporter, Reporter, ConsoleOutputReceiver
+    implements RunListener, Reporter, ConsoleOutputReceiver,
+    DirectConsoleReporter     // todo: Does this have to be a reporter ?
 {
-    private final RunStatistics globalStats;
+    private final TestSetStatistics testSetStatistics;
+
+    private final RunStatistics globalStatistics;
 
     private final MulticastingReporter multicastingReporter;
 
@@ -52,10 +44,30 @@ public class TestSetRunListener
     private final List testStdErr = Collections.synchronizedList( new ArrayList() );
 
 
-    public TestSetRunListener( List reports, RunStatistics globalStats )
+    public TestSetRunListener( AbstractConsoleReporter consoleReporter, AbstractFileReporter fileReporter,
+                               XMLReporter xmlReporter, Reporter reporter, RunStatistics globalStats )
     {
-        multicastingReporter = new MulticastingReporter( reports );
-        this.globalStats = globalStats;
+
+        ArrayList reportes = new ArrayList();
+        if ( consoleReporter != null )
+        {
+            reportes.add( consoleReporter );
+        }
+        if ( fileReporter != null )
+        {
+            reportes.add( fileReporter );
+        }
+        if ( xmlReporter != null )
+        {
+            reportes.add( xmlReporter );
+        }
+        if ( reporter != null )
+        {
+            reportes.add( reporter );
+        }
+        multicastingReporter = new MulticastingReporter( reportes );
+        this.testSetStatistics = new TestSetStatistics();
+        this.globalStatistics = globalStats;
     }
 
     public void writeMessage( String message )
@@ -63,18 +75,10 @@ public class TestSetRunListener
         multicastingReporter.writeMessage( message );
     }
 
-    public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
+
+    public void writeMessage( byte[] b, int off, int len )
     {
-        ByteBuffer byteBuffer = new ByteBuffer( buf, off, len );
-        if ( stdout )
-        {
-            testStdOut.add( byteBuffer );
-        }
-        else
-        {
-            testStdErr.add( byteBuffer );
-        }
-        multicastingReporter.writeMessage( new String( buf, off, len ) );
+        multicastingReporter.writeMessage( b, off, len );
     }
 
     public void writeDetailMessage( String message )
@@ -82,59 +86,37 @@ public class TestSetRunListener
         multicastingReporter.writeDetailMessage( message );
     }
 
-    // ----------------------------------------------------------------------
-    // Run
-    // ----------------------------------------------------------------------
-
-    public void runStarting()
-    {
-        multicastingReporter.runStarting();
-    }
-
-    public void runCompleted()
+    public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
     {
-        multicastingReporter.runCompleted();
-        multicastingReporter.writeFooter( "" );
-        multicastingReporter.writeFooter( "Results :" );
-        multicastingReporter.writeFooter( "" );
-        if ( globalStats.hadFailures() )
+        ByteBuffer byteBuffer = new ByteBuffer( buf, off, len );
+        if ( stdout )
         {
-            multicastingReporter.writeFooter( "Failed tests: " );
-            for ( Iterator iterator = this.globalStats.getFailureSources().iterator(); iterator.hasNext(); )
-            {
-                multicastingReporter.writeFooter( "  " + iterator.next() );
-            }
-            multicastingReporter.writeFooter( "" );
+            testStdOut.add( byteBuffer );
         }
-        if ( globalStats.hadErrors() )
+        else
         {
-            writeFooter( "Tests in error: " );
-            for ( Iterator iterator = this.globalStats.getErrorSources().iterator(); iterator.hasNext(); )
-            {
-                multicastingReporter.writeFooter( "  " + iterator.next() );
-            }
-            multicastingReporter.writeFooter( "" );
+            testStdErr.add( byteBuffer );
         }
-        multicastingReporter.writeFooter( globalStats.getSummary() );
-        multicastingReporter.writeFooter( "" );
+        multicastingReporter.writeMessage( buf, off, len );
     }
 
-    public void writeFooter( String footer )
+    public void testSetStarting( ReportEntry report )
     {
-        multicastingReporter.writeFooter( footer );
+        multicastingReporter.testSetStarting( report );
     }
 
-
-    public void testSetStarting( ReportEntry report )
-        throws ReporterException
+    public void clearCapture()
     {
-        multicastingReporter.testSetStarting( report );
+        testStdErr.clear();
+        testStdOut.clear();
     }
 
     public void testSetCompleted( ReportEntry report )
     {
         multicastingReporter.testSetCompleted( report );
         multicastingReporter.reset();
+        globalStatistics.add( testSetStatistics );
+        testSetStatistics.reset();
     }
 
     // ----------------------------------------------------------------------
@@ -148,37 +130,45 @@ public class TestSetRunListener
 
     public void testSucceeded( ReportEntry report )
     {
-        clearCapturedContent();
-        globalStats.incrementCompletedCount();
+        testSetStatistics.incrementCompletedCount();
         multicastingReporter.testSucceeded( report );
+        clearCapture();
     }
 
     public void testError( ReportEntry reportEntry )
     {
-        testError( reportEntry, getAsString( testStdOut ), getAsString( testStdErr ) );
+        multicastingReporter.testError( reportEntry, getAsString( testStdOut ), getAsString( testStdErr ) );
+        testSetStatistics.incrementErrorsCount();
+        testSetStatistics.incrementCompletedCount();
+        globalStatistics.addErrorSource( reportEntry.getName(), reportEntry.getStackTraceWriter() );
+        clearCapture();
     }
 
     public void testError( ReportEntry reportEntry, String stdOutLog, String stdErrLog )
     {
         multicastingReporter.testError( reportEntry, stdOutLog, stdErrLog );
-        globalStats.incrementErrorsCount();
-        globalStats.incrementCompletedCount();
-        globalStats.addErrorSource( reportEntry.getName(), reportEntry.getStackTraceWriter() );
-        clearCapturedContent();
+        testSetStatistics.incrementErrorsCount();
+        testSetStatistics.incrementCompletedCount();
+        globalStatistics.addErrorSource( reportEntry.getName(), reportEntry.getStackTraceWriter() );
+        clearCapture();
     }
 
     public void testFailed( ReportEntry reportEntry )
     {
-        testFailed( reportEntry, getAsString( testStdOut ), getAsString( testStdErr ) );
+        multicastingReporter.testFailed( reportEntry, getAsString( testStdOut ), getAsString( testStdErr ) );
+        testSetStatistics.incrementFailureCount();
+        testSetStatistics.incrementCompletedCount();
+        globalStatistics.addFailureSource( reportEntry.getName(), reportEntry.getStackTraceWriter() );
+        clearCapture();
     }
 
     public void testFailed( ReportEntry reportEntry, String stdOutLog, String stdErrLog )
     {
         multicastingReporter.testFailed( reportEntry, stdOutLog, stdErrLog );
-        globalStats.incrementFailureCount();
-        globalStats.incrementCompletedCount();
-        globalStats.addFailureSource( reportEntry.getName(), reportEntry.getStackTraceWriter() );
-        clearCapturedContent();
+        testSetStatistics.incrementFailureCount();
+        testSetStatistics.incrementCompletedCount();
+        globalStatistics.addFailureSource( reportEntry.getName(), reportEntry.getStackTraceWriter() );
+        clearCapture();
     }
 
     // ----------------------------------------------------------------------
@@ -187,9 +177,9 @@ public class TestSetRunListener
 
     public void testSkipped( ReportEntry report )
     {
-        clearCapturedContent();
-        globalStats.incrementSkippedCount();
-        globalStats.incrementCompletedCount();
+        clearCapture();
+        testSetStatistics.incrementSkippedCount();
+        testSetStatistics.incrementCompletedCount();
         multicastingReporter.testSkipped( report );
     }
 
@@ -213,12 +203,4 @@ public class TestSetRunListener
         }
         return stringBuffer.toString();
     }
-
-    public void clearCapturedContent()
-    {
-        testStdErr.clear();
-        testStdOut.clear();
-    }
-
-
 }

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/TestSetStatistics.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/TestSetStatistics.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/TestSetStatistics.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/TestSetStatistics.java Wed Apr 27 21:20:12 2011
@@ -19,9 +19,8 @@ package org.apache.maven.surefire.report
  * under the License.
  */
 
-import org.apache.maven.surefire.suite.RunResult;
-
 import java.util.Properties;
+import org.apache.maven.surefire.suite.RunResult;
 
 /**
  * Run-statistics for a testset
@@ -74,6 +73,14 @@ public class TestSetStatistics
         return failures > 0;
     }
 
+    public synchronized void reset()
+    {
+        completedCount = 0;
+        errors = 0;
+        failures = 0;
+        skipped = 0;
+    }
+
     public synchronized boolean hadErrors()
     {
         return errors > 0;
@@ -89,6 +96,14 @@ public class TestSetStatistics
         return skipped;
     }
 
+    public synchronized void add( TestSetStatistics testSetStatistics )
+    {
+        this.completedCount += testSetStatistics.completedCount;
+        this.errors += testSetStatistics.errors;
+        this.failures += testSetStatistics.failures;
+        this.skipped += testSetStatistics.skipped;
+    }
+
     public synchronized void initResultsFromProperties( Properties results )
     {
         errors = Integer.valueOf( results.getProperty( RESULTS_ERRORS, "0" ) ).intValue();

Added: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ThreadLocalRunListener.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ThreadLocalRunListener.java?rev=1097246&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ThreadLocalRunListener.java (added)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ThreadLocalRunListener.java Wed Apr 27 21:20:12 2011
@@ -0,0 +1,88 @@
+package org.apache.maven.surefire.report;
+
+/*
+ * 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.
+ */
+
+/**
+ * Ensures that the current thread has a RunListener instance attached, and forwards calls to it.
+ * @author Kristian Rosenvold
+ */
+public class ThreadLocalRunListener implements RunListener
+{
+    private final InheritableThreadLocal target = new InheritableThreadLocal();
+
+    private final ReporterFactory reporterFactory;
+
+
+    public RunListener getTarget()
+    {
+        Object o = target.get();
+        if (o == null){
+            o = reporterFactory.createReporter();
+            target.set(o);
+        }
+        return (RunListener) o;
+    }
+
+    public ThreadLocalRunListener(ReporterFactory reporterFactory)
+    {
+        this.reporterFactory = reporterFactory;
+    }
+
+    public void testSetStarting( ReportEntry report )
+    {
+        getTarget().testSetStarting( report );
+    }
+
+    public void testSetCompleted( ReportEntry report )
+    {
+        getTarget().testSetCompleted( report );
+    }
+
+    public void testStarting( ReportEntry report )
+    {
+        getTarget().testStarting( report );
+    }
+
+    public void testSucceeded( ReportEntry report )
+    {
+        getTarget().testSucceeded( report );
+    }
+
+    public void testAssumptionFailure( ReportEntry report )
+    {
+        getTarget().testAssumptionFailure( report );
+    }
+
+    public void testError( ReportEntry report )
+    {
+        getTarget().testError( report );
+    }
+
+    public void testFailed( ReportEntry report )
+    {
+        getTarget().testFailed( report );
+    }
+
+    public void testSkipped( ReportEntry report )
+    {
+        getTarget().testSkipped( report );
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ThreadLocalRunListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/XMLReporter.java Wed Apr 27 21:20:12 2011
@@ -19,11 +19,6 @@ package org.apache.maven.surefire.report
  * under the License.
  */
 
-import org.apache.maven.surefire.util.PrettyPrintXMLWriter;
-import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.xml.Xpp3Dom;
-import org.codehaus.plexus.util.xml.Xpp3DomWriter;
-
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileNotFoundException;
@@ -38,6 +33,9 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
 import java.util.StringTokenizer;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.codehaus.plexus.util.xml.Xpp3DomWriter;
 
 /**
  * XML format reporter.
@@ -62,7 +60,7 @@ public class XMLReporter
 
         this.reportsDirectory = reporterConfiguration.getReportsDirectory();
 
-        this.deleteOnStarting = reporterConfiguration.isForkWithTimeout();
+        this.deleteOnStarting = false;
     }
 
 
@@ -70,6 +68,10 @@ public class XMLReporter
     {
     }
 
+    public void writeMessage( byte[] b, int off, int len )
+    {
+    }
+
     public void writeDetailMessage( String message )
     {
     }

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/suite/RunResult.java Wed Apr 27 21:20:12 2011
@@ -19,6 +19,8 @@ package org.apache.maven.surefire.suite;
  * under the License.
  */
 
+import java.util.StringTokenizer;
+
 /**
  * Represents a test-run-result; this may be from a single test run or an aggregated result.
  *
@@ -34,16 +36,36 @@ public class RunResult
 
     private final int skipped;
 
+    private final boolean failure;
+
+    private final boolean timeout;
+
     private static final int SUCCESS = 0;
 
     public static final int FAILURE = 255;
 
+    public static final int NO_TESTS = 254;
+
+
+    public static final RunResult Failure = new RunResult( 0, 0, 0, 0, true, false );
+
+    public static final RunResult Success = new RunResult( 0, 0, 0, 0 );
+
+    public static final RunResult Timeout = new RunResult( 0, 0, 0, 0, false, true );
+
     public RunResult( int completedCount, int errors, int failures, int skipped )
     {
+        this( completedCount, errors, failures, skipped, false, false );
+    }
+
+    public RunResult( int completedCount, int errors, int failures, int skipped, boolean failure, boolean timeout )
+    {
         this.completedCount = completedCount;
         this.errors = errors;
         this.failures = failures;
         this.skipped = skipped;
+        this.failure = failure;
+        this.timeout = timeout;
     }
 
     public int getCompletedCount()
@@ -68,7 +90,60 @@ public class RunResult
 
     public int getBooterCode()
     {
-        return getFailures() == 0 && getErrors() == 0 ? SUCCESS : FAILURE;
+        return isErrrorFree() ? SUCCESS : FAILURE;
+    }
+
+    public int getForkedProcessCode()
+    {
+        return completedCount == 0 ? NO_TESTS : isErrrorFree() ? SUCCESS : FAILURE;
+    }
+
+    public boolean isErrrorFree()
+    {
+        return getFailures() == 0 && getErrors() == 0;
     }
 
+    public String getAsString()
+    {
+        return getCompletedCount() + "," + getErrors() + "," + getFailures() + "," + getSkipped() + "," + isFailure()
+            + "," + isTimeout();
+    }
+
+    public static RunResult fromString( String string )
+    {
+        StringTokenizer strTok = new StringTokenizer( string, "," );
+        int completed = Integer.parseInt( strTok.nextToken() );
+        int errors = Integer.parseInt( strTok.nextToken() );
+        int failures = Integer.parseInt( strTok.nextToken() );
+        int skipped = Integer.parseInt( strTok.nextToken() );
+        boolean isFailure = Boolean.parseBoolean( strTok.nextToken() );
+        boolean isTimeout = Boolean.parseBoolean( strTok.nextToken() );
+        return new RunResult( completed, errors, failures, skipped, isFailure, isTimeout );
+    }
+
+    public boolean isFailureOrTimeout()
+    {
+        return this.timeout || this.failure;
+    }
+
+    public boolean isFailure()
+    {
+        return failure;
+    }
+
+    public boolean isTimeout()
+    {
+        return timeout;
+    }
+
+    public RunResult aggregate( RunResult other )
+    {
+        boolean failure = isFailure() || other.isFailure();
+        boolean timeout = isTimeout() || other.isTimeout();
+        int completed = getCompletedCount() + other.getCompletedCount();
+        int fail = getFailures() + other.getFailures();
+        int ign = getSkipped() + other.getSkipped();
+        int err = getErrors() + other.getErrors();
+        return new RunResult( completed, err, fail, ign, failure, timeout );
+    }
 }

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java Wed Apr 27 21:20:12 2011
@@ -218,6 +218,13 @@ public class ReflectionUtils
         }
     }
 
+    public static Object instantiateObject( String className, Class[] types, Object[] params, ClassLoader classLoader )
+    {
+        Class clazz = loadClass( classLoader, className );
+        final Constructor constructor = getConstructor( clazz, types );
+        return newInstance( constructor, params );
+    }
+
     public static Class tryLoadClass( ClassLoader classLoader, String className )
     {
         try

Copied: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueue.java (from r1097226, maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/output/StandardOutputConsumerTest.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueue.java?p2=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueue.java&p1=maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/output/StandardOutputConsumerTest.java&r1=1097226&r2=1097246&rev=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/output/StandardOutputConsumerTest.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueue.java Wed Apr 27 21:20:12 2011
@@ -1,4 +1,4 @@
-package org.apache.maven.plugin.surefire.booterclient.output;
+package org.apache.maven.surefire.util.internal;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -20,20 +20,13 @@ package org.apache.maven.plugin.surefire
  */
 
 /**
- * Test for {@link StandardOutputConsumer}
- *
- * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
- * @version $Id$
+ * A very simple blocking queue that might have stricter constraints than the standard jdk1.5 blockingqueues.
+ * @author Kristian Rosenvold
  */
-public class StandardOutputConsumerTest
-    extends AbstractOutputConsumerTestCase
+public interface BlockingQueue
 {
+    void add( Object object );
 
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-        setOutputConsumer( new StandardOutputConsumer() );
-    }
-
+    Object take()
+        throws InterruptedException;
 }

Propchange: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueue.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Copied: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueueFactory.java (from r1097226, maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/StandardOutputConsumer.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueueFactory.java?p2=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueueFactory.java&p1=maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/StandardOutputConsumer.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/StandardOutputConsumer.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueueFactory.java Wed Apr 27 21:20:12 2011
@@ -1,4 +1,4 @@
-package org.apache.maven.plugin.surefire.booterclient.output;
+package org.apache.maven.surefire.util.internal;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -19,25 +19,20 @@ package org.apache.maven.plugin.surefire
  * under the License.
  */
 
-import java.io.PrintWriter;
+import org.apache.maven.surefire.util.ReflectionUtils;
 
 /**
- * Surefire output consumer that writes everything to {@link System#out}
- *
- * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
- * @version $Id$
- * @since 2.1
+ * Creates blocking queues that work at different language levels.
+ * @author Kristian Rosenvold
  */
-public class StandardOutputConsumer
-    extends PrintWriterOutputConsumer
+public class BlockingQueueFactory
 {
 
-    /**
-     * Create a consumer that will write to {@link System#out}
-     */
-    public StandardOutputConsumer()
-    {
-        super( new PrintWriter( System.out ) );
+    public static BlockingQueue createBlockingQueue(){
+        return isJdk15() ? new Java15BlockingQueue() : (BlockingQueue) new Java13BlockingQueue();
     }
 
+    private static boolean isJdk15(){
+        return ReflectionUtils.tryGetMethod( String.class, "contains", new Class[]{CharSequence.class}) != null;
+    }
 }

Propchange: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueueFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/BlockingQueueFactory.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/FunkyTwoThreadBlockingQueue.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/FunkyTwoThreadBlockingQueue.java?rev=1097246&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/FunkyTwoThreadBlockingQueue.java (added)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/FunkyTwoThreadBlockingQueue.java Wed Apr 27 21:20:12 2011
@@ -0,0 +1,99 @@
+package org.apache.maven.surefire.util.internal;
+
+/*
+ * 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.
+ */
+
+/**
+ * A producer/consumer queue that is optimized for *one* producer thread
+ * and *one* consumer thread, and solely optimized for efficient inserts
+ * by the producer, minimizing producer locking for hand-off to
+ * a second consumer.
+ *
+ * TwoThreadBlockingQueue insert 5000000 elements in  = 52
+ * FunkyTwoThreadBlockingQueue insert 5000000 elements in  = 42
+ * TwoThreadBlockingQueue produced and taken 5000000 elements in  = 104
+ * LinkedBlockingQueue insert 5000000 elements in  = 1815
+ * LinkedBlockingDeque insert 5000000 elements in  = 113
+ * ArrayList insert 5000000 elements in  = 18
+ * LinkedList insert 5000000 elements in  = 334
+ *
+ * @author Kristian Rosenvold
+ */
+public class FunkyTwoThreadBlockingQueue implements BlockingQueue
+{
+    final int chunkSize = 100;
+
+    private Chunk takeChunk = new Chunk();
+
+    private int takePos = 0;
+
+    private Chunk insertChunk = takeChunk;
+
+    private int insertPos = 0;
+
+    private volatile boolean memoryModelGuard;
+
+
+    public void put( Object object )
+    {
+        insertChunk.elements[insertPos] = object;
+        if ( ++insertPos == chunkSize)
+        {
+            Chunk newChunk = new Chunk();
+            insertChunk.next = newChunk;
+            insertChunk = newChunk;
+            insertPos = 0;
+        }
+        memoryModelGuard = true;
+    }
+
+    public void add( Object object )
+    {
+        put(  object );
+    }
+
+
+    public Object take()
+        throws InterruptedException
+    {
+        if ( takePos >= chunkSize )
+        {
+            takeChunk = takeChunk.next;
+            takePos = 0;
+        }
+
+        boolean fud = memoryModelGuard;
+        Object next = takeChunk.elements[takePos];
+        while ( next == null )
+        {
+            Thread.sleep( 1 );
+            fud = memoryModelGuard;
+            next = takeChunk.elements[takePos];
+        }
+        takePos++;
+        return next;
+    }
+
+    final class Chunk
+    {
+        final Object[] elements = new Object[chunkSize];
+
+        volatile Chunk next;
+    }
+}

Propchange: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/FunkyTwoThreadBlockingQueue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/Java13BlockingQueue.java (from r1097226, maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/output/SupressFooterOutputConsumerProxyTest.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/Java13BlockingQueue.java?p2=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/Java13BlockingQueue.java&p1=maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/output/SupressFooterOutputConsumerProxyTest.java&r1=1097226&r2=1097246&rev=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/output/SupressFooterOutputConsumerProxyTest.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/Java13BlockingQueue.java Wed Apr 27 21:20:12 2011
@@ -1,4 +1,4 @@
-package org.apache.maven.plugin.surefire.booterclient.output;
+package org.apache.maven.surefire.util.internal;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -19,27 +19,38 @@ package org.apache.maven.plugin.surefire
  * under the License.
  */
 
+
+import java.util.LinkedList;
+
 /**
- * Test for {@link SupressFooterOutputConsumerProxy}
- *
- * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
- * @version $Id$
+ * @author Kristian Rosenvold
  */
-public class SupressFooterOutputConsumerProxyTest
-    extends OutputConsumerProxyTest
+public class Java13BlockingQueue
+    implements BlockingQueue
 {
+    private final java.util.List items = new LinkedList();
 
-    protected void setUp()
-        throws Exception
+    public void add( Object object )
     {
-        super.setUp();
-        setOutputConsumer( new SupressFooterOutputConsumerProxy( (OutputConsumer) getOutputConsumerMock().proxy() ) );
+        synchronized ( items )
+        {
+            items.add( object );
+            items.notifyAll();
+        }
     }
 
-    public void testConsumeFooterLine()
+    public Object take()
+        throws InterruptedException
     {
-        getOutputConsumer().consumeFooterLine( getLine() );
-        getOutputConsumerMock().verify();
-    }
+        synchronized ( items )
+        {
+            if ( items.size() == 0 )
+            {
+                items.wait();
+            }
 
+            return items.remove( 0 );
+        }
+    }
 }
+

Propchange: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/Java13BlockingQueue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/Java13BlockingQueue.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Copied: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/Java15BlockingQueue.java (from r1097226, maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/NullOutputConsumer.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/Java15BlockingQueue.java?p2=maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/Java15BlockingQueue.java&p1=maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/NullOutputConsumer.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/NullOutputConsumer.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/Java15BlockingQueue.java Wed Apr 27 21:20:12 2011
@@ -1,4 +1,4 @@
-package org.apache.maven.plugin.surefire.booterclient.output;
+package org.apache.maven.surefire.util.internal;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -19,34 +19,25 @@ package org.apache.maven.plugin.surefire
  * under the License.
  */
 
-import org.apache.maven.surefire.report.ReportEntry;
+
+import java.util.concurrent.LinkedBlockingQueue;
 
 /**
  * @author Kristian Rosenvold
  */
-public class NullOutputConsumer implements OutputConsumer
+public class Java15BlockingQueue implements BlockingQueue
 {
-    public void consumeHeaderLine( String line )
-    {
-    }
+    private final java.util.concurrent.BlockingQueue blockingQueue = new LinkedBlockingQueue(  );
 
-    public void consumeMessageLine( String line )
+    public void add( Object object )
     {
+        blockingQueue.add(  object );
     }
 
-    public void consumeFooterLine( String line )
-    {
-    }
-
-    public void consumeOutputLine( String line )
-    {
-    }
-
-    public void testSetStarting( ReportEntry reportEntry )
-    {
-    }
-
-    public void testSetCompleted()
+    public Object take()
+        throws InterruptedException
     {
+        return blockingQueue.take();
     }
 }
+