maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krosenv...@apache.org
Subject git commit: [SUREFIRE-938] Removed memory binding for stdout/stderr capture.
Date Thu, 02 May 2013 19:35:02 GMT
Updated Branches:
  refs/heads/master 19939cb45 -> 33e110fc4


[SUREFIRE-938] Removed memory binding for stdout/stderr capture.

Starts streaming to disk after 1MB of stdout or stderr traffic for a single test.

Added -Dthousand parameter to consoleoutput-noisy that indicates the number of KB log to produce.
 -Dthousand=500000 to
produce half a gig of log.

Added a cute integration test


Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/33e110fc
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/33e110fc
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/33e110fc

Branch: refs/heads/master
Commit: 33e110fc46aa43d10b38a93b3db74c09be6bc6d5
Parents: 19939cb
Author: Kristian Rosenvold <krosenvold@apache.org>
Authored: Thu May 2 20:53:27 2013 +0200
Committer: Kristian Rosenvold <krosenvold@apache.org>
Committed: Thu May 2 21:26:25 2013 +0200

----------------------------------------------------------------------
 maven-surefire-common/pom.xml                      |    9 ++
 .../output/ThreadedStreamConsumer.java             |   43 ++++--
 .../surefire/report/StatelessXmlReporter.java      |  110 ++++++++++++---
 .../plugin/surefire/report/TestSetRunListener.java |   69 +++++-----
 .../plugin/surefire/report/WrappedReportEntry.java |   16 ++-
 .../surefire/util/internal/BlockingQueue.java      |   33 -----
 .../util/internal/Java15BlockingQueue.java         |   44 ------
 .../surefire/report/StatelessXMLReporterTest.java  |   17 ++-
 .../apache/maven/surefire/its/ConsoleOutputIT.java |    8 +
 .../src/test/java/consoleoutput_noisy/Test1.java   |    9 +-
 .../src/test/java/consoleoutput_noisy/Test2.java   |    6 +-
 11 files changed, 198 insertions(+), 166 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/33e110fc/maven-surefire-common/pom.xml
----------------------------------------------------------------------
diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml
index a848ce5..1330eec 100644
--- a/maven-surefire-common/pom.xml
+++ b/maven-surefire-common/pom.xml
@@ -71,6 +71,10 @@
       <artifactId>maven-project</artifactId>
     </dependency>
     <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-model</artifactId>
     </dependency>
@@ -129,6 +133,7 @@
                 <includes>
                   <include>org.apache.maven.shared:maven-shared-utils</include>
                   <include>org.apache.maven.shared:maven-common-artifact-filters</include>
+                  <include>commons-io:commons-io</include>
                 </includes>
               </artifactSet>
               <relocations>
@@ -136,6 +141,10 @@
                   <pattern>org.apache.maven.shared</pattern>
                   <shadedPattern>org.apache.maven.surefire.shade.org.apache.maven.shared</shadedPattern>
                 </relocation>
+                <relocation>
+                  <pattern>org.apache.commons.io</pattern>
+                  <shadedPattern>org.apache.maven.surefire.shade.org.apache.commons.io</shadedPattern>
+                </relocation>
               </relocations>
             </configuration>
           </execution>

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/33e110fc/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
index c2c1519..d4d6991 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ThreadedStreamConsumer.java
@@ -19,10 +19,10 @@ package org.apache.maven.plugin.surefire.booterclient.output;
  * under the License.
  */
 
-import org.apache.maven.plugin.surefire.util.internal.BlockingQueue;
-import org.apache.maven.plugin.surefire.util.internal.Java15BlockingQueue;
 import org.apache.maven.shared.utils.cli.StreamConsumer;
 
+import java.util.concurrent.LinkedBlockingQueue;
+
 /**
  * Knows how to reconstruct *all* the state transmitted over stdout by the forked process.
  *
@@ -32,7 +32,7 @@ public class ThreadedStreamConsumer
     implements StreamConsumer
 {
 
-    private final BlockingQueue items = new Java15BlockingQueue();
+    private final java.util.concurrent.BlockingQueue<String> items = new LinkedBlockingQueue<String>();
 
     private static final String poison = "Pioson";
 
@@ -43,14 +43,14 @@ public class ThreadedStreamConsumer
     static class Pumper
         implements Runnable
     {
-        private final BlockingQueue queue;
+        private final java.util.concurrent.BlockingQueue<String> queue;
 
         private final StreamConsumer target;
 
-        private volatile InterruptedException interruptedException;
+        private volatile Throwable throwable;
 
 
-        Pumper( BlockingQueue queue, StreamConsumer target )
+        Pumper( java.util.concurrent.BlockingQueue<String> queue, StreamConsumer target
)
         {
             this.queue = queue;
             this.target = target;
@@ -68,15 +68,17 @@ public class ThreadedStreamConsumer
                     item = queue.take();
                 }
             }
-            catch ( InterruptedException e )
+            catch ( Throwable t )
             {
-                this.interruptedException = e;
+                // Think about what happens if the producer overruns us and creates an OOME.
Not nice.
+                // Maybe limit length of blocking queue
+                this.throwable = t;
             }
         }
 
-        public InterruptedException getInterruptedException()
+        public Throwable getThrowable()
         {
-            return interruptedException;
+            return throwable;
         }
     }
 
@@ -90,6 +92,16 @@ public class ThreadedStreamConsumer
     public void consumeLine( String s )
     {
         items.add( s );
+        if ( items.size() > 10000 )
+        {
+            try
+            {
+                Thread.sleep( 100 );
+            }
+            catch ( InterruptedException ignore )
+            {
+            }
+        }
     }
 
 
@@ -99,15 +111,16 @@ public class ThreadedStreamConsumer
         {
             items.add( poison );
             thread.join();
-            //noinspection ThrowableResultOfMethodCallIgnored
-            if ( pumper.getInterruptedException() != null )
-            {
-                throw pumper.getInterruptedException();
-            }
         }
         catch ( InterruptedException e )
         {
             throw new RuntimeException( e );
         }
+
+        //noinspection ThrowableResultOfMethodCallIgnored
+        if ( pumper.getThrowable() != null )
+        {
+            throw new RuntimeException( pumper.getThrowable() );
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/33e110fc/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
index cb3314f..0c97101 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
@@ -21,11 +21,16 @@ package org.apache.maven.plugin.surefire.report;
 
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.FilterOutputStream;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.io.OutputStreamWriter;
+import java.io.Writer;
 import java.util.Enumeration;
 import java.util.Properties;
 import java.util.StringTokenizer;
+
+import org.apache.commons.io.output.DeferredFileOutputStream;
 import org.apache.maven.shared.utils.io.IOUtil;
 import org.apache.maven.shared.utils.xml.XMLWriter;
 import org.apache.maven.surefire.report.ReportEntry;
@@ -69,6 +74,8 @@ import static org.apache.maven.plugin.surefire.report.FileReporterUtils.stripIll
 public class StatelessXmlReporter
 {
 
+    private static final byte[] ampBytes = "&amp#".getBytes();
+
     private final File reportsDirectory;
 
     private final String reportNameSuffix;
@@ -88,7 +95,8 @@ public class StatelessXmlReporter
         throws ReporterException
     {
 
-        OutputStreamWriter fw = getWriter( testSetReportEntry );
+        FileOutputStream outputStream = getOutputStream( testSetReportEntry );
+        OutputStreamWriter fw = getWriter( outputStream );
         try
         {
 
@@ -109,7 +117,7 @@ public class StatelessXmlReporter
                 }
                 else
                 {
-                    getTestProblems( ppw, entry, trimStackTrace, reportNameSuffix );
+                    getTestProblems( fw, ppw, entry, trimStackTrace, reportNameSuffix, outputStream
);
                 }
 
             }
@@ -122,7 +130,20 @@ public class StatelessXmlReporter
         }
     }
 
-    private OutputStreamWriter getWriter( WrappedReportEntry testSetReportEntry )
+    private OutputStreamWriter getWriter( FileOutputStream fos )
+    {
+        try
+        {
+
+            return new OutputStreamWriter( fos, encoding );
+        }
+        catch ( IOException e )
+        {
+            throw new ReporterException( "When writing report", e );
+        }
+    }
+
+    private FileOutputStream getOutputStream( WrappedReportEntry testSetReportEntry )
     {
         File reportFile = getReportFile( testSetReportEntry, reportsDirectory, reportNameSuffix
);
 
@@ -134,11 +155,9 @@ public class StatelessXmlReporter
         try
         {
 
-            FileOutputStream fos = new FileOutputStream( reportFile );
-
-            return new OutputStreamWriter( fos, encoding );
+            return new FileOutputStream( reportFile );
         }
-        catch ( IOException e )
+        catch ( Exception e )
         {
             throw new ReporterException( "When writing report", e );
         }
@@ -150,9 +169,8 @@ public class StatelessXmlReporter
 
         if ( reportNameSuffix != null && reportNameSuffix.length() > 0 )
         {
-            reportFile =
-                new File( reportsDirectory, stripIllegalFilenameChars( "TEST-" + report.getName()
+ "-"
-                    + reportNameSuffix + ".xml" ) );
+            reportFile = new File( reportsDirectory, stripIllegalFilenameChars(
+                "TEST-" + report.getName() + "-" + reportNameSuffix + ".xml" ) );
         }
         else
         {
@@ -161,7 +179,7 @@ public class StatelessXmlReporter
 
         return reportFile;
     }
-    
+
     private static void startTestElement( XMLWriter ppw, WrappedReportEntry report, String
reportNameSuffix )
     {
         ppw.startElement( "testcase" );
@@ -209,8 +227,8 @@ public class StatelessXmlReporter
     }
 
 
-    private void getTestProblems( XMLWriter ppw, WrappedReportEntry report, boolean trimStackTrace,
-                                  String reportNameSuffix )
+    private void getTestProblems( OutputStreamWriter outputStreamWriter, XMLWriter ppw, WrappedReportEntry
report,
+                                  boolean trimStackTrace, String reportNameSuffix, FileOutputStream
fw )
     {
 
         startTestElement( ppw, report, reportNameSuffix );
@@ -250,19 +268,35 @@ public class StatelessXmlReporter
 
         ppw.endElement(); // entry type
 
-        addOutputStreamElement( ppw, report.getStdout(), "system-out" );
+        EncodingOutputStream eos = new EncodingOutputStream( fw );
 
-        addOutputStreamElement( ppw, report.getStdErr(), "system-err" );
+        addOutputStreamElement( outputStreamWriter, fw, eos, ppw, report.getStdout(), "system-out"
);
+
+        addOutputStreamElement( outputStreamWriter, fw, eos, ppw, report.getStdErr(), "system-err"
);
 
         ppw.endElement(); // test element
     }
 
-    private void addOutputStreamElement( XMLWriter xmlWriter, String stdOut, String name
)
+    private void addOutputStreamElement( OutputStreamWriter outputStreamWriter, OutputStream
fw, EncodingOutputStream eos, XMLWriter xmlWriter, DeferredFileOutputStream stdOut,
+                                         String name )
     {
-        if ( stdOut != null && stdOut.trim().length() > 0 )
+        if ( stdOut != null && stdOut.getByteCount() > 0 )
         {
+
             xmlWriter.startElement( name );
-            xmlWriter.writeText( extraEscape( stdOut, false ) );
+
+            try
+            {
+                xmlWriter.writeText( "" ); // Cheat sax to emit element
+                outputStreamWriter.flush();
+                stdOut.close();
+                stdOut.writeTo( eos );
+                eos.flush();
+            }
+            catch ( IOException e )
+            {
+                throw new ReporterException( "When writing xml report stdout/stderr", e );
+            }
             xmlWriter.endElement();
         }
     }
@@ -298,7 +332,7 @@ public class StatelessXmlReporter
 
                 xmlWriter.addAttribute( "name", key );
 
-                xmlWriter.addAttribute( "value", extraEscape( value, true ));
+                xmlWriter.addAttribute( "value", extraEscape( value, true ) );
 
                 xmlWriter.endElement();
 
@@ -311,7 +345,7 @@ public class StatelessXmlReporter
      * Handle stuff that may pop up in java that is not legal in xml
      *
      * @param message   The string
-     * @param attribute
+     * @param attribute true if the escaped value is inside an attribute
      * @return The escaped string
      */
     private static String extraEscape( String message, boolean attribute )
@@ -324,6 +358,37 @@ public class StatelessXmlReporter
         return escapeXml( message, attribute );
     }
 
+    private static class EncodingOutputStream
+        extends FilterOutputStream
+    {
+
+        public EncodingOutputStream( OutputStream out )
+        {
+            super( out );
+        }
+
+        @Override
+        public void write( int b )
+            throws IOException
+        {
+            if ( isIllegalEscape( b ) )
+            {
+                // uh-oh!  This character is illegal in XML 1.0!
+                // http://www.w3.org/TR/1998/REC-xml-19980210#charsets
+                // we're going to deliberately doubly-XML escape it...
+                // there's nothing better we can do! :-(
+                // SUREFIRE-456
+                out.write( ampBytes );
+                out.write( b );
+                out.write( ';' ); // & Will be encoded to amp inside xml encodingSHO
+            }
+            else
+            {
+                out.write( b );    //To change body of overridden methods use File | Settings
| File Templates.
+            }
+        }
+    }
+
     private static boolean containsEscapesIllegalnXml10( String message )
     {
         int size = message.length();
@@ -343,6 +408,11 @@ public class StatelessXmlReporter
         return c < 32 && c != '\n' && c != '\r' && c != '\t';
     }
 
+    private static boolean isIllegalEscape( int c )
+    {
+        return c < 32 && c != '\n' && c != '\r' && c != '\t';
+    }
+
     private static String escapeXml( String text, boolean attribute )
     {
         StringBuilder sb = new StringBuilder( text.length() * 2 );

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/33e110fc/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
index c366435..596a041 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/TestSetRunListener.java
@@ -19,21 +19,23 @@ package org.apache.maven.plugin.surefire.report;
  * under the License.
  */
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
+import org.apache.commons.io.output.DeferredFileOutputStream;
 import org.apache.maven.plugin.surefire.runorder.StatisticsReporter;
 import org.apache.maven.surefire.report.ConsoleLogger;
 import org.apache.maven.surefire.report.ConsoleOutputReceiver;
 import org.apache.maven.surefire.report.ReportEntry;
 import org.apache.maven.surefire.report.RunListener;
 import org.apache.maven.surefire.report.RunStatistics;
-import org.apache.maven.surefire.util.internal.ByteBuffer;
+import org.apache.maven.surefire.util.NestedRuntimeException;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
 
 /**
  * Reports data for a single test set.
  * <p/>
- * 
+ *
  * @author Kristian Rosenvold
  */
 public class TestSetRunListener
@@ -43,9 +45,15 @@ public class TestSetRunListener
 
     private final TestSetStats detailsForThis;
 
-    private final List<ByteBuffer> testStdOut = Collections.synchronizedList( new ArrayList<ByteBuffer>()
);
+    private DeferredFileOutputStream testStdOut = initDeferred( "stdout" );
+
+    private DeferredFileOutputStream testStdErr = initDeferred( "stderr" );
+
+    private DeferredFileOutputStream initDeferred( String stdout )
+    {
+        return new DeferredFileOutputStream( 1000000, "deferred", stdout, new File( "target"
) );
+    }
 
-    private final List<ByteBuffer> testStdErr = Collections.synchronizedList( new ArrayList<ByteBuffer>()
);
 
     private final TestcycleConsoleOutputReceiver consoleOutputReceiver;
 
@@ -62,8 +70,8 @@ public class TestSetRunListener
     public TestSetRunListener( ConsoleReporter consoleReporter, FileReporter fileReporter,
                                StatelessXmlReporter simpleXMLReporter,
                                TestcycleConsoleOutputReceiver consoleOutputReceiver,
-                               StatisticsReporter statisticsReporter, RunStatistics globalStats,
-                               boolean trimStackTrace, boolean isPlainFormat, boolean briefOrPlainFormat
)
+                               StatisticsReporter statisticsReporter, RunStatistics globalStats,
boolean trimStackTrace,
+                               boolean isPlainFormat, boolean briefOrPlainFormat )
     {
         this.consoleReporter = consoleReporter;
         this.fileReporter = fileReporter;
@@ -85,14 +93,20 @@ public class TestSetRunListener
 
     public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
     {
-        ByteBuffer byteBuffer = new ByteBuffer( buf, off, len );
-        if ( stdout )
+        try
         {
-            testStdOut.add( byteBuffer );
+            if ( stdout )
+            {
+                testStdOut.write( buf, off, len );
+            }
+            else
+            {
+                testStdErr.write( buf, off, len );
+            }
         }
-        else
+        catch ( IOException e )
         {
-            testStdErr.add( byteBuffer );
+            throw new NestedRuntimeException( e );
         }
         consoleOutputReceiver.writeTestOutput( buf, off, len, stdout );
     }
@@ -109,8 +123,8 @@ public class TestSetRunListener
 
     public void clearCapture()
     {
-        testStdErr.clear();
-        testStdOut.clear();
+        testStdOut = initDeferred( "stdout" );
+        testStdErr = initDeferred( "stderr" );
     }
 
     public void testSetCompleted( ReportEntry report )
@@ -209,19 +223,6 @@ public class TestSetRunListener
         testSkipped( report );
     }
 
-    public String getAsString( List<ByteBuffer> byteBufferList )
-    {
-        StringBuilder stringBuffer = new StringBuilder();
-        // To avoid getting a java.util.ConcurrentModificationException while iterating (see
SUREFIRE-879) we need to
-        // iterate over a copy or the elements array. Since the passed in byteBufferList
is always wrapped with
-        // Collections.synchronizedList( ) we are guaranteed toArray() is going to be atomic,
so we are safe.
-        for ( Object byteBuffer : byteBufferList.toArray() )
-        {
-            stringBuffer.append( byteBuffer.toString() );
-        }
-        return stringBuffer.toString();
-    }
-
     private WrappedReportEntry wrap( ReportEntry other, ReportEntryType reportEntryType )
     {
         final int estimatedElapsed;
@@ -241,16 +242,14 @@ public class TestSetRunListener
             estimatedElapsed = 0;
         }
 
-        return new WrappedReportEntry( other, reportEntryType, estimatedElapsed, getAsString(
testStdOut ),
-                                       getAsString( testStdErr ) );
+        return new WrappedReportEntry( other, reportEntryType, estimatedElapsed, testStdOut,
testStdErr );
     }
 
     private WrappedReportEntry wrapTestSet( ReportEntry other )
     {
-        return new WrappedReportEntry( other, null, other.getElapsed() != null 
-                        ? other.getElapsed()
-                        : detailsForThis.getElapsedSinceTestSetStart(), getAsString( testStdOut
),
-                                       getAsString( testStdErr ) );
+        return new WrappedReportEntry( other, null, other.getElapsed() != null
+            ? other.getElapsed()
+            : detailsForThis.getElapsedSinceTestSetStart(), testStdOut, testStdErr );
     }
 
     public void close()

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/33e110fc/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/WrappedReportEntry.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/WrappedReportEntry.java
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/WrappedReportEntry.java
index 028898f..cd7a956 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/WrappedReportEntry.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/WrappedReportEntry.java
@@ -19,11 +19,13 @@ package org.apache.maven.plugin.surefire.report;
  * under the License.
  */
 
-import java.text.NumberFormat;
-import java.util.Locale;
+import org.apache.commons.io.output.DeferredFileOutputStream;
 import org.apache.maven.surefire.report.ReportEntry;
 import org.apache.maven.surefire.report.StackTraceWriter;
 
+import java.text.NumberFormat;
+import java.util.Locale;
+
 /**
  * @author Kristian Rosenvold
  */
@@ -36,9 +38,9 @@ public class WrappedReportEntry
 
     private final Integer elapsed;
 
-    private final String stdout;
+    private final DeferredFileOutputStream stdout;
 
-    private final String stdErr;
+    private final DeferredFileOutputStream stdErr;
 
     private final NumberFormat numberFormat = NumberFormat.getInstance( Locale.ENGLISH );
 
@@ -47,7 +49,7 @@ public class WrappedReportEntry
     static final String NL = System.getProperty( "line.separator" );
 
     public WrappedReportEntry( ReportEntry original, ReportEntryType reportEntryType, Integer
estimatedElapsed,
-                               String stdout, String stdErr )
+                               DeferredFileOutputStream stdout, DeferredFileOutputStream
stdErr )
     {
         this.original = original;
         this.reportEntryType = reportEntryType;
@@ -66,12 +68,12 @@ public class WrappedReportEntry
         return reportEntryType;
     }
 
-    public String getStdout()
+    public DeferredFileOutputStream getStdout()
     {
         return stdout;
     }
 
-    public String getStdErr()
+    public DeferredFileOutputStream getStdErr()
     {
         return stdErr;
     }

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/33e110fc/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/internal/BlockingQueue.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/internal/BlockingQueue.java
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/internal/BlockingQueue.java
deleted file mode 100644
index a0de80b..0000000
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/internal/BlockingQueue.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.apache.maven.plugin.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 very simple blocking queue that might have stricter constraints than the standard jdk1.5
blockingqueues.
- *
- * @author Kristian Rosenvold
- */
-public interface BlockingQueue
-{
-    void add( String object );
-
-    String take()
-        throws InterruptedException;
-}

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/33e110fc/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/internal/Java15BlockingQueue.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/internal/Java15BlockingQueue.java
b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/internal/Java15BlockingQueue.java
deleted file mode 100644
index 1b3f839..0000000
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/util/internal/Java15BlockingQueue.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.apache.maven.plugin.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.
- */
-
-
-import java.util.concurrent.LinkedBlockingQueue;
-
-/**
- * @author Kristian Rosenvold
- */
-public class Java15BlockingQueue
-    implements BlockingQueue
-{
-    private final java.util.concurrent.BlockingQueue<String> blockingQueue = new LinkedBlockingQueue<String>();
-
-    public void add( String object )
-    {
-        blockingQueue.add( object );
-    }
-
-    public String take()
-        throws InterruptedException
-    {
-        return blockingQueue.take();
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/33e110fc/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXMLReporterTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXMLReporterTest.java
b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXMLReporterTest.java
index ae312ee..dc18b45 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXMLReporterTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXMLReporterTest.java
@@ -19,9 +19,9 @@ package org.apache.maven.plugin.surefire.report;
  * under the License.
  */
 
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
+import junit.framework.AssertionFailedError;
+import junit.framework.TestCase;
+import org.apache.commons.io.output.DeferredFileOutputStream;
 import org.apache.maven.plugin.surefire.booterclient.output.DeserializedStacktraceWriter;
 import org.apache.maven.shared.utils.StringUtils;
 import org.apache.maven.shared.utils.xml.Xpp3Dom;
@@ -31,8 +31,9 @@ import org.apache.maven.surefire.report.ReportEntry;
 import org.apache.maven.surefire.report.SimpleReportEntry;
 import org.apache.maven.surefire.report.StackTraceWriter;
 
-import junit.framework.AssertionFailedError;
-import junit.framework.TestCase;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
 
 @SuppressWarnings( "ResultOfMethodCallIgnored" )
 public class StatelessXMLReporterTest
@@ -85,9 +86,13 @@ public class StatelessXMLReporterTest
 
         stats.testSucceeded( testSetReportEntry );
         StackTraceWriter stackTraceWriter = new DeserializedStacktraceWriter( "A fud msg",
"trimmed", "fail at foo" );
+        DeferredFileOutputStream s = new DeferredFileOutputStream( 1000000, "fds", "fdx",
new File( "" ) );
+        s.write( "std-out!".getBytes() );
+        DeferredFileOutputStream s1 = new DeferredFileOutputStream( 1000000, "fds", "fdx",
new File( "" ) );
+        s1.write( "std-err?".getBytes() );
         WrappedReportEntry t2 =
             new WrappedReportEntry( new SimpleReportEntry( Inner.class.getName(), testName2,
stackTraceWriter, 13 ),
-                                    ReportEntryType.error, 13, "std-out!", "std-err?" );
+                                    ReportEntryType.error, 13, s, s1 );
 
         stats.testSucceeded( t2 );
         StatelessXmlReporter reporter = new StatelessXmlReporter( new File( "." ), null,
false );

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/33e110fc/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java
b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java
index 36d1ff5..cfce481 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java
@@ -42,4 +42,12 @@ public class ConsoleOutputIT
         surefireReportsFile.assertContainsText( "Printline in shutdown hook" );
     }
 
+    @Test
+    public void largerSoutThanMemory()
+        throws Exception
+    {
+        unpack( "consoleoutput-noisy" ).setMavenOpts( "-Xmx64m" ).sysProp( "thousand", "100000"
).executeTest();
+    }
+
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/33e110fc/surefire-integration-tests/src/test/resources/consoleoutput-noisy/src/test/java/consoleoutput_noisy/Test1.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/consoleoutput-noisy/src/test/java/consoleoutput_noisy/Test1.java
b/surefire-integration-tests/src/test/resources/consoleoutput-noisy/src/test/java/consoleoutput_noisy/Test1.java
index d4a677b..4b5a21f 100644
--- a/surefire-integration-tests/src/test/resources/consoleoutput-noisy/src/test/java/consoleoutput_noisy/Test1.java
+++ b/surefire-integration-tests/src/test/resources/consoleoutput-noisy/src/test/java/consoleoutput_noisy/Test1.java
@@ -24,9 +24,12 @@ import junit.framework.TestCase;
 public class Test1
     extends TestCase
 {
+
+    public static final int thousand = Integer.parseInt( System.getProperty( "thousand",
"1000" ) );
+
     public void test1MillionBytes()
     {
-        for ( int i = 0; i < 10000; i++ )
+        for ( int i = 0; i < ( 10 * thousand ); i++ )
         {
             System.out.println(
                 "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
);
@@ -35,7 +38,7 @@ public class Test1
 
     public static void testHundredThousand()
     {
-        for ( int i = 0; i < 1000; i++ )
+        for ( int i = 0; i < thousand; i++ )
         {
             System.out.println(
                 "AAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDDEEEEEEEEEEFFFFFFFFFFGGGGGGGGGGHHHHHHHHHHIIIIIIIIIIJJJJJJJJJJ"
);
@@ -44,7 +47,7 @@ public class Test1
 
     public static void testAnotherHundredThousand()
     {
-        for ( int i = 0; i < 1000; i++ )
+        for ( int i = 0; i < thousand; i++ )
         {
             System.out.println(
                 "AAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDDEEEEEEEEEEFFFFFFFFFFGGGGGGGGGGHHHHHHHHHHIIIIIIIIIIJJJJJJJJJJ"
);

http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/33e110fc/surefire-integration-tests/src/test/resources/consoleoutput-noisy/src/test/java/consoleoutput_noisy/Test2.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/consoleoutput-noisy/src/test/java/consoleoutput_noisy/Test2.java
b/surefire-integration-tests/src/test/resources/consoleoutput-noisy/src/test/java/consoleoutput_noisy/Test2.java
index de4e0fc..10f607f 100644
--- a/surefire-integration-tests/src/test/resources/consoleoutput-noisy/src/test/java/consoleoutput_noisy/Test2.java
+++ b/surefire-integration-tests/src/test/resources/consoleoutput-noisy/src/test/java/consoleoutput_noisy/Test2.java
@@ -26,7 +26,7 @@ public class Test2
 {
     public void test2MillionBytes()
     {
-        for ( int i = 0; i < 10000; i++ )
+        for ( int i = 0; i < 20 * Test1.thousand; i++ )
         {
             System.out.println(
                 "0-2-3-6-8-012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789"
);
@@ -35,7 +35,7 @@ public class Test2
 
     public static void testHundredThousand()
     {
-        for ( int i = 0; i < 1000; i++ )
+        for ( int i = 0; i < Test1.thousand; i++ )
         {
             System.out.println(
                 "A-A-3-A-A-BBBBBBBBBBCCCCCCCCCCDDDDDDDDDDEEEEEEEEEEFFFFFFFFFFGGGGGGGGGGHHHHHHHHHHIIIIIIIIIIJJJJJJJJJJ"
);
@@ -44,7 +44,7 @@ public class Test2
 
     public static void testAnotherHundredThousand()
     {
-        for ( int i = 0; i < 1000; i++ )
+        for ( int i = 0; i < Test1.thousand; i++ )
         {
             System.out.println(
                 "A-A-A-3-3-ABBBBBBBBBCCCCCCCCCCDDDDDDDDDDEEEEEEEEEEFFFFFFFFFFGGGGGGGGGGHHHHHHHHHHIIIIIIIIIIJJJJJJJJJJ"
);


Mime
View raw message