maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krosenv...@apache.org
Subject svn commit: r1097246 [4/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...
Date Wed, 27 Apr 2011 21:20:16 GMT
Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/StringUtils.java Wed Apr 27 21:20:12 2011
@@ -19,11 +19,15 @@ package org.apache.maven.surefire.util.i
  * under the License.
  */
 
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
 import java.util.StringTokenizer;
+import org.apache.maven.surefire.util.NestedRuntimeException;
 
 /**
  * <p>Common <code>String</code> manipulation routines.</p>
- *
+ * <p/>
  * <p>Originally from
  * <a href="http://jakarta.apache.org/turbine/">Turbine</a> and the
  * GenerationJavaCore library.</p>
@@ -39,14 +43,14 @@ import java.util.StringTokenizer;
  * @author Holger Krauth
  * @author <a href="mailto:alex@purpletech.com">Alexander Day Chaffee</a>
  * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
- * @since 1.0
  * @version $Id: StringUtils.java 8001 2009-01-03 13:17:09Z vsiveton $
  * @noinspection JavaDoc
- *
+ * <p/>
  * A quick borrow from plexus-utils by Kristian Rosenvold, to restore jdk1.3 compat
  * Threw away all the unused stuff.
- *
+ * <p/>
  * NOTE: This class is not part of any api and is public purely for technical reasons !
+ * @since 1.0
  */
 public class StringUtils
 {
@@ -107,7 +111,7 @@ public class StringUtils
 
     /**
      * <p>Replace all occurrences of a String within another String.</p>
-     *
+     * <p/>
      * <p>A <code>null</code> reference passed to this method is a no-op.</p>
      *
      * @param text text to search and replace in
@@ -145,11 +149,559 @@ public class StringUtils
      *
      * @param str the String to check
      * @return <code>true</code> if the String is <code>null</code>, or
-     *  length zero once trimmed
+     *         length zero once trimmed
      */
     public static boolean isBlank( String str )
     {
         return ( ( str == null ) || ( str.trim().length() == 0 ) );
     }
+
+
+    // Ripped from commons-lang StringEscapeUtils. Maybe Use dependency instead
+    public static void unescapeJava( StringWriter out, String str )
+    {
+        if ( out == null )
+        {
+            throw new IllegalArgumentException( "The Writer must not be null" );
+        }
+        if ( str == null )
+        {
+            return;
+        }
+        int sz = str.length();
+        StringBuffer unicode = new StringBuffer( 4 );
+        boolean hadSlash = false;
+        boolean inUnicode = false;
+        for ( int i = 0; i < sz; i++ )
+        {
+            char ch = str.charAt( i );
+            if ( inUnicode )
+            {
+                // if in unicode, then we're reading unicode
+                // values in somehow
+                unicode.append( ch );
+                if ( unicode.length() == 4 )
+                {
+                    // unicode now contains the four hex digits
+                    // which represents our unicode character
+                    try
+                    {
+                        int value = Integer.parseInt( unicode.toString(), 16 );
+                        out.write( (char) value );
+                        unicode.setLength( 0 );
+                        inUnicode = false;
+                        hadSlash = false;
+                    }
+                    catch ( NumberFormatException nfe )
+                    {
+                        throw new NestedRuntimeException( "Unable to parse unicode value: " + unicode, nfe );
+                    }
+                }
+                continue;
+            }
+            if ( hadSlash )
+            {
+                // handle an escaped value
+                hadSlash = false;
+                switch ( ch )
+                {
+                    case '\\':
+                        out.write( '\\' );
+                        break;
+                    case '\'':
+                        out.write( '\'' );
+                        break;
+                    case '\"':
+                        out.write( '"' );
+                        break;
+                    case 'r':
+                        out.write( '\r' );
+                        break;
+                    case 'f':
+                        out.write( '\f' );
+                        break;
+                    case 't':
+                        out.write( '\t' );
+                        break;
+                    case 'n':
+                        out.write( '\n' );
+                        break;
+                    case 'b':
+                        out.write( '\b' );
+                        break;
+                    case 'u':
+                    {
+                        // uh-oh, we're in unicode country....
+                        inUnicode = true;
+                        break;
+                    }
+                    default:
+                        out.write( ch );
+                        break;
+                }
+                continue;
+            }
+            else if ( ch == '\\' )
+            {
+                hadSlash = true;
+                continue;
+            }
+            out.write( ch );
+        }
+        if ( hadSlash )
+        {
+            // then we're in the weird case of a \ at the end of the
+            // string, let's output it anyway.
+            out.write( '\\' );
+        }
+    }
+
+    // Ripped from commons-lang StringEscapeUtils. Maybe Use dependency instead
+    public static int unescapeJava( byte[] out, String str )
+    {
+        int outPos = 0;
+        if ( out == null )
+        {
+            throw new IllegalArgumentException( "The Writer must not be null" );
+        }
+        if ( str == null )
+        {
+            return 0;
+        }
+        int sz = str.length();
+        StringBuffer unicode = new StringBuffer( 4 );
+        boolean hadSlash = false;
+        boolean inUnicode = false;
+        for ( int i = 0; i < sz; i++ )
+        {
+            char ch = str.charAt( i );
+            if ( inUnicode )
+            {
+                // if in unicode, then we're reading unicode
+                // values in somehow
+                unicode.append( ch );
+                if ( unicode.length() == 4 )
+                {
+                    // unicode now contains the four hex digits
+                    // which represents our unicode character
+                    try
+                    {
+                        int value = Integer.parseInt( unicode.toString(), 16 );
+                        out[outPos++] = (byte) value;
+                        unicode.setLength( 0 );
+                        inUnicode = false;
+                        hadSlash = false;
+                    }
+                    catch ( NumberFormatException nfe )
+                    {
+                        throw new NestedRuntimeException( "Unable to parse unicode value: " + unicode, nfe );
+                    }
+                }
+                continue;
+            }
+            if ( hadSlash )
+            {
+                // handle an escaped value
+                hadSlash = false;
+                switch ( ch )
+                {
+                    case '\\':
+                        out[outPos++] = '\\';
+                        break;
+                    case '\'':
+                        out[outPos++] = '\'';
+                        break;
+                    case '\"':
+                        out[outPos++] = '"';
+                        break;
+                    case 'r':
+                        out[outPos++] = '\r';
+                        break;
+                    case 'f':
+                        out[outPos++] = '\f';
+                        break;
+                    case 't':
+                        out[outPos++] = '\t';
+                        break;
+                    case 'n':
+                        out[outPos++] = '\n';
+                        break;
+                    case 'b':
+                        out[outPos++] = '\b';
+                        break;
+                    case 'u':
+                    {
+                        // uh-oh, we're in unicode country....
+                        inUnicode = true;
+                        break;
+                    }
+                    default:
+                        out[outPos++] = (byte) ch;
+                        break;
+                }
+                continue;
+            }
+            else if ( ch == '\\' )
+            {
+                hadSlash = true;
+                continue;
+            }
+            out[outPos++] = (byte) ch;
+        }
+        if ( hadSlash )
+        {
+            // then we're in the weird case of a \ at the end of the
+            // string, let's output it anyway.
+            out[outPos++] = '\\';
+        }
+        return outPos;
+    }
+
+    // Ripped from commons-lang StringEscapeUtils. With a minor modification, we unicode-quote commas
+    // to avoid csv decoding problems ;)
+
+    /**
+     * @param out               write to receieve the escaped string
+     * @param str               String to escape values in, may be null
+     * @param escapeSingleQuote escapes single quotes if <code>true</code>
+     * @throws java.io.IOException if an IOException occurs
+     */
+    public static void escapeJavaStyleString( Writer out, String str, boolean escapeSingleQuote )
+        throws IOException
+    {
+        if ( out == null )
+        {
+            throw new IllegalArgumentException( "The Writer must not be null" );
+        }
+        if ( str == null )
+        {
+            return;
+        }
+        int sz;
+        sz = str.length();
+        for ( int i = 0; i < sz; i++ )
+        {
+            char ch = str.charAt( i );
+
+            // handle unicode
+            if ( ch > 0xfff )
+            {
+                out.write( "\\u" + hex( ch ) );
+            }
+            else if ( ch > 0xff )
+            {
+                out.write( "\\u0" + hex( ch ) );
+            }
+            else if ( ch > 0x7f || ch == ',' )
+            {    // Kr - this line modified from commons
+                out.write( "\\u00" + hex( ch ) );
+            }
+            else if ( ch < 32 )
+            {
+                switch ( ch )
+                {
+                    case '\b':
+                        out.write( '\\' );
+                        out.write( 'b' );
+                        break;
+                    case '\n':
+                        out.write( '\\' );
+                        out.write( 'n' );
+                        break;
+                    case '\t':
+                        out.write( '\\' );
+                        out.write( 't' );
+                        break;
+                    case '\f':
+                        out.write( '\\' );
+                        out.write( 'f' );
+                        break;
+                    case '\r':
+                        out.write( '\\' );
+                        out.write( 'r' );
+                        break;
+                    default:
+                        if ( ch > 0xf )
+                        {
+                            out.write( "\\u00" + hex( ch ) );
+                        }
+                        else
+                        {
+                            out.write( "\\u000" + hex( ch ) );
+                        }
+                        break;
+                }
+            }
+            else
+            {
+                switch ( ch )
+                {
+                    case '\'':
+                        if ( escapeSingleQuote )
+                        {
+                            out.write( '\\' );
+                        }
+                        out.write( '\'' );
+                        break;
+                    case '"':
+                        out.write( '\\' );
+                        out.write( '"' );
+                        break;
+                    case '\\':
+                        out.write( '\\' );
+                        out.write( '\\' );
+                        break;
+                    case '/':
+                        out.write( '\\' );
+                        out.write( '/' );
+                        break;
+                    default:
+                        out.write( ch );
+                        break;
+                }
+            }
+        }
+    }
+
+    public static void escapeJavaStyleString( ByteBuffer out, byte[] str, int off, int len )
+    {
+        if ( out == null )
+        {
+            throw new IllegalArgumentException( "The Writer must not be null" );
+        }
+        final int inputLength = str.length;
+        if ( str == null || inputLength == 0 )
+        {
+            return;
+        }
+        int outputPos = 0;
+        int end = off + len;
+        for ( int i = off; i < end; i++ )
+        {
+            char ch = (char) str[i];
+
+            // handle unicode
+            if ( ch > 0xfff )
+            {
+                outputPos = writeOut( out, outputPos, "\\u" + hex( ch ) );
+            }
+            else if ( ch > 0xff )
+            {
+                outputPos = writeOut( out, outputPos, "\\u0" + hex( ch ) );
+            }
+            else if ( ch > 0x7f || ch == ',' )
+            {    // Kr - this line modified from commons
+                outputPos = writeOut( out, outputPos, "\\u00" + hex( ch ) );
+            }
+            else if ( ch < 32 )
+            {
+                switch ( ch )
+                {
+                    case '\b':
+                        out.append( '\\' );
+                        out.append( 'b' );
+                        break;
+                    case '\n':
+                        out.append( '\\' );
+                        out.append( 'n' );
+                        break;
+                    case '\t':
+                        out.append( '\\' );
+                        out.append( 't' );
+                        break;
+                    case '\f':
+                        out.append( '\\' );
+                        out.append( 'f' );
+                        break;
+                    case '\r':
+                        out.append( '\\' );
+                        out.append( 'r' );
+                        break;
+                    default:
+                        if ( ch > 0xf )
+                        {
+                            outputPos = writeOut( out, outputPos, "\\u00" + hex( ch ) );
+                        }
+                        else
+                        {
+                            outputPos = writeOut( out, outputPos, "\\u000" + hex( ch ) );
+                        }
+                        break;
+                }
+            }
+            else
+            {
+                switch ( ch )
+                {
+                    case '\'':
+                        out.append( '\\' );
+                        out.append( '\'' );
+                        break;
+                    case '"':
+                        out.append( '\\' );
+                        out.append( '"' );
+                        break;
+                    case '\\':
+                        out.append( '\\' );
+                        out.append( '\\' );
+                        break;
+                    case '/':
+                        out.append( '\\' );
+                        out.append( '/' );
+                        break;
+                    default:
+                        out.append( ch );
+                        break;
+                }
+            }
+        }
+    }
+
+    public static int escapeJavaStyleString( byte[] out, int outoff, byte[] str, int off, int len )
+    {
+        if ( out == null )
+        {
+            throw new IllegalArgumentException( "The Writer must not be null" );
+        }
+        final int inputLength = str.length;
+        if ( str == null || inputLength == 0 )
+        {
+            return 0;
+        }
+        int outputPos = outoff;
+        int end = off + len;
+        for ( int i = off; i < end; i++ )
+        {
+            char ch = (char) str[i];
+
+            // handle unicode
+            if ( ch > 0xfff )
+            {
+                outputPos = writeOut( out, outputPos, "\\u" + hex( ch ) );
+            }
+            else if ( ch > 0xff )
+            {
+                outputPos = writeOut( out, outputPos, "\\u0" + hex( ch ) );
+            }
+            else if ( ch > 0x7f || ch == ',' )
+            {    // Kr - this line modified from commons
+                outputPos = writeOut( out, outputPos, "\\u00" + hex( ch ) );
+            }
+            else if ( ch < 32 )
+            {
+                switch ( ch )
+                {
+                    case '\b':
+                        out[outputPos++] = '\\';
+                        out[outputPos++] = 'b';
+                        break;
+                    case '\n':
+                        out[outputPos++] = '\\';
+                        out[outputPos++] = 'n';
+                        break;
+                    case '\t':
+                        out[outputPos++] = '\\';
+                        out[outputPos++] = 't';
+                        break;
+                    case '\f':
+                        out[outputPos++] = '\\';
+                        out[outputPos++] = 'f';
+                        break;
+                    case '\r':
+                        out[outputPos++] = '\\';
+                        out[outputPos++] = 'r';
+                        break;
+                    default:
+                        if ( ch > 0xf )
+                        {
+                            outputPos = writeOut( out, outputPos, "\\u00" + hex( ch ) );
+                        }
+                        else
+                        {
+                            outputPos = writeOut( out, outputPos, "\\u000" + hex( ch ) );
+                        }
+                        break;
+                }
+            }
+            else
+            {
+                switch ( ch )
+                {
+                    case '\'':
+                        out[outputPos++] = '\\';
+                        out[outputPos++] = '\'';
+                        break;
+                    case '"':
+                        out[outputPos++] = '\\';
+                        out[outputPos++] = '"';
+                        break;
+                    case '\\':
+                        out[outputPos++] = '\\';
+                        out[outputPos++] = '\\';
+                        break;
+                    case '/':
+                        out[outputPos++] = '\\';
+                        out[outputPos++] = '/';
+                        break;
+                    default:
+                        out[outputPos++] = (byte) ch;
+                        break;
+                }
+            }
+        }
+        return outputPos - outoff;
+    }
+
+    private static int writeOut( ByteBuffer out, int outputPos, final String msg )
+    {
+        byte[] bytes = msg.getBytes();
+        for ( int cnt = 0; cnt < bytes.length; cnt++ )
+        {
+            out.append( bytes[cnt] );
+        }
+        return outputPos;
+    }
+
+
+    private static int writeOut( byte[] out, int outputPos, final String msg )
+    {
+        byte[] bytes = msg.getBytes();
+        for ( int cnt = 0; cnt < bytes.length; cnt++ )
+        {
+            out[outputPos++] = bytes[cnt];
+        }
+        return outputPos;
+    }
+
+
+    public static String hex( char ch )
+    {
+        return Integer.toHexString( ch ).toUpperCase();
+    }
+
+    /**
+     * Courtesy of commons-lang StringEscapeUtils, slightly modified, see below
+     *
+     * @param str String to escape values in, may be null
+     * @return the escaped string
+     */
+    public static void escapeJavaStyleString( StringBuffer target, String str )
+    {
+        if ( str == null )
+        {
+            return;
+        }
+        try
+        {
+            StringWriter writer = new StringWriter( str.length() * 2 );
+            escapeJavaStyleString( writer, str, true );
+            target.append( writer.toString() ); // todo: be bit smarter
+        }
+        catch ( IOException ioe )
+        {
+            // this should never ever happen while writing to a StringWriter
+            ioe.printStackTrace();
+        }
+    }
 }
 

Added: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueue.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueue.java?rev=1097246&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueue.java (added)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueue.java Wed Apr 27 21:20:12 2011
@@ -0,0 +1,94 @@
+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.
+ *
+ * The producer can actually come in on different threads
+ * (because lastInserted is volatile), but can/will lose
+ * items if they arrive concurrently. Take only supports a single
+ * client.
+ *
+ * This runs like crazy, but is not the most garbage friendly around.
+ *
+ * TwoThreadBlockingQueue insert 5000000 elements in  = 52ms
+ * LinkedBlockingQueue insert 5000000 elements in  = 179ms
+ * LikedBlockingDeque insert 5000000 elements in  = 114ms
+ * ArrayList insert 5000000 elements in  = 18ms (sized at correct size from start)
+ *
+ * @author Kristian Rosenvold
+ */
+public class TwoThreadBlockingQueue
+    implements BlockingQueue
+{
+    private volatile Element lastInserted;
+    private volatile Element lastTaken;
+    private volatile Element first;
+
+    public static final Object poison = new Object();
+
+    public void add( Object object )
+    {
+        Element next = new Element( object);
+        if (lastInserted == null){
+            first = lastInserted = next;
+        } else {
+            lastInserted.next = next;
+            lastInserted = next;
+        }
+    }
+
+    public Object take()
+        throws InterruptedException
+    {
+        if (lastTaken == null){
+            while (first == null){
+                Thread.sleep(1);
+            }
+            lastTaken = first;
+            first = null;
+        } else {
+            Element next = lastTaken.next;
+            while (next == null){
+                Thread.sleep(1);
+                next = lastTaken.next;
+            }
+            lastTaken = next;
+        }
+        return lastTaken.object;
+    }
+
+    private static class Element
+    {
+        private final Object object;
+
+        private volatile Element next;
+
+        Element( Object object )
+        {
+            this.object = object;
+        }
+    }
+
+}

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

Added: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/AsynchRunListenerTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/AsynchRunListenerTest.java?rev=1097246&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/AsynchRunListenerTest.java (added)
+++ maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/AsynchRunListenerTest.java Wed Apr 27 21:20:12 2011
@@ -0,0 +1,79 @@
+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 junit.framework.TestCase;
+
+/**
+ * @author Kristian Rosenvold
+ */
+public class AsynchRunListenerTest
+    extends TestCase
+{
+
+    class MockConsoleOutputReceiver
+        implements ConsoleOutputReceiver
+    {
+        byte[] buf;
+
+        int off;
+
+        int len;
+
+        boolean stdout;
+
+        public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
+        {
+            this.buf = buf;
+            this.off = off;
+            this.len = len;
+            this.stdout = stdout;
+        }
+
+        public byte[] getBuf()
+        {
+            return buf;
+        }
+
+        public int getLen()
+        {
+            return len;
+        }
+    }
+
+    public void testCombiner()
+    {
+        final MockConsoleOutputReceiver consoleOutputReceiver = new MockConsoleOutputReceiver();
+        AsynchRunListener.JoinableTestOutput joinableTestOutput =
+            new AsynchRunListener.JoinableTestOutput( "ABC".getBytes(), 0, 3, true, consoleOutputReceiver );
+        AsynchRunListener.JoinableTestOutput joinableTestOutput2 =
+            new AsynchRunListener.JoinableTestOutput( "DEF".getBytes(), 0, 3, true, consoleOutputReceiver );
+
+        final AsynchRunListener.JoinableTestOutput append = joinableTestOutput.append( joinableTestOutput2 );
+
+        append.run();
+        final byte[] expected = "ABCDEF".getBytes();
+        for ( int i = 0; i < expected.length; i++ )
+        {
+            assertEquals( expected[i], consoleOutputReceiver.getBuf()[i] );
+        }
+        assertEquals( expected.length, consoleOutputReceiver.getLen() );
+    }
+}

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

Modified: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/TestConsoleOutputRunListenerTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/TestConsoleOutputRunListenerTest.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/TestConsoleOutputRunListenerTest.java (original)
+++ maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/TestConsoleOutputRunListenerTest.java Wed Apr 27 21:20:12 2011
@@ -19,7 +19,8 @@ package org.apache.maven.surefire.report
  * under the License.
  */
 
-import java.util.Arrays;
+import java.util.ArrayList;
+import org.apache.maven.plugin.surefire.report.ReporterManagerFactory;
 
 import junit.framework.TestCase;
 
@@ -49,13 +50,12 @@ public class TestConsoleOutputRunListene
     private ReporterFactory createReporterFactory()
     {
         ReporterConfiguration reporterConfiguration = getTestReporterConfiguration();
-        return new ReporterManagerFactory( this.getClass().getClassLoader(), reporterConfiguration );
+        return new ReporterManagerFactory( this.getClass().getClassLoader(), reporterConfiguration, new ArrayList() );
     }
 
     public static ReporterConfiguration getTestReporterConfiguration()
     {
-        return new ReporterConfiguration( Arrays.asList( new Object[]{ ConsoleReporter.class.getName() } ), null,
-                                          Boolean.TRUE, null );
+        return new ReporterConfiguration( null, Boolean.TRUE, ConsoleReporter.class.getName(), null, null, null );
     }
 
 }

Modified: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java (original)
+++ maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/XMLReporterTest.java Wed Apr 27 21:20:12 2011
@@ -19,9 +19,10 @@ package org.apache.maven.surefire.report
  * under the License.
  */
 
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+
 import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
-import org.codehaus.plexus.util.xml.Xpp3Dom;
 
 public class XMLReporterTest
     extends TestCase
@@ -37,9 +38,10 @@ public class XMLReporterTest
         throws Exception
     {
         super.setUp();
-        reporter = new XMLReporter( ForkingConsoleReporterTest.getTestReporterConfiguration() );
+        reporter = new XMLReporter( new ReporterConfiguration( null, Boolean.TRUE ) );
         message = "junit.framework.AssertionFailedError";
-        reportEntry = new SimpleReportEntry( this.getClass().getName(), "XMLReporterTest", new PojoStackTraceWriter( "", "", new AssertionFailedError() ) );
+        reportEntry = new SimpleReportEntry( this.getClass().getName(), "XMLReporterTest",
+                                             new PojoStackTraceWriter( "", "", new AssertionFailedError() ) );
     }
 
     /*

Added: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/suite/RunResultTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/suite/RunResultTest.java?rev=1097246&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/suite/RunResultTest.java (added)
+++ maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/suite/RunResultTest.java Wed Apr 27 21:20:12 2011
@@ -0,0 +1,62 @@
+package org.apache.maven.surefire.suite;
+
+/*
+ * 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 junit.framework.TestCase;
+
+/**
+ * @author Kristian Rosenvold
+ */
+public class RunResultTest
+    extends TestCase
+{
+    public void testGetAsString()
+        throws Exception
+    {
+
+    }
+
+    public void testFromString()
+        throws Exception
+    {
+      RunResult original = new RunResult( 4,3,2,1, true,false);
+        final String asString = original.getAsString();
+        final RunResult runResult = RunResult.fromString( asString );
+        verifySame( original, runResult );
+    }
+    public void testFromString2()
+        throws Exception
+    {
+      RunResult original = new RunResult( 5,6,7,8, false,true );
+        final String asString = original.getAsString();
+        final RunResult runResult = RunResult.fromString( asString );
+        verifySame( original, runResult );
+    }
+
+    private void verifySame( RunResult original, RunResult runResult )
+    {
+        assertEquals( original.getCompletedCount(), runResult.getCompletedCount());
+        assertEquals( original.getErrors(), runResult.getErrors() );
+        assertEquals( original.getFailures(), runResult.getFailures());
+        assertEquals( original.getSkipped(), runResult.getSkipped());
+        assertEquals( original.isFailure(), runResult.isFailure());
+        assertEquals( original.isTimeout(), runResult.isTimeout());
+    }
+}

Propchange: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/suite/RunResultTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/StringUtilsTest.java (from r1097226, maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/ForkingConsoleReporterTest.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/StringUtilsTest.java?p2=maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/StringUtilsTest.java&p1=maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/ForkingConsoleReporterTest.java&r1=1097226&r2=1097246&rev=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/report/ForkingConsoleReporterTest.java (original)
+++ maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/StringUtilsTest.java Wed Apr 27 21:20:12 2011
@@ -1,4 +1,4 @@
-package org.apache.maven.surefire.report;
+package org.apache.maven.surefire.util.internal;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -19,30 +19,37 @@ package org.apache.maven.surefire.report
  * under the License.
  */
 
-import java.util.ArrayList;
+import junit.framework.TestCase;
 
 /**
- * Test for {@link ForkingConsoleReporter}
- *
- * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
- * @version $Id$
+ * @author Kristian Rosenvold
  */
-public class ForkingConsoleReporterTest
-    extends AbstractConsoleReporterTestCase
+public class StringUtilsTest
+    extends TestCase
 {
 
-    protected void setUp()
-        throws Exception
+    public void testUnescape()
     {
-        super.setUp();
-        ReporterConfiguration reporterConfiguration = getTestReporterConfiguration();
-        ForkingConsoleReporter consoleReporter = new ForkingConsoleReporter( reporterConfiguration );
-        setConsoleReporter( consoleReporter );
+        byte[] buffer = new byte[80];
+        final int abc = StringUtils.unescapeJava( buffer, "ABC" );
+        assertEquals( 3, abc );
     }
 
-    public static ReporterConfiguration getTestReporterConfiguration()
+    public void testUnescapeWithEscape()
     {
-        return new ReporterConfiguration( new ArrayList(), null, Boolean.TRUE, null );
+        byte[] buffer = new byte[80];
+        final int abc = StringUtils.unescapeJava( buffer, "AB\tC" );
+        assertEquals( 4, abc );
+    }
+
+    public void testEscape()
+    {
+        ByteBuffer buffer = new ByteBuffer( 80 );
+        StringUtils.escapeJavaStyleString( buffer, "AB\tC".getBytes(), 0, 4 );
+        assertEquals( 5, buffer.getlength() );
+        String temp = buffer.toString();
+        assertEquals( "AB\\tC", temp );
+
     }
 
 }

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

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

Added: maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueueTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueueTest.java?rev=1097246&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueueTest.java (added)
+++ maven/surefire/trunk/surefire-api/src/test/java/org/apache/maven/surefire/util/internal/TwoThreadBlockingQueueTest.java Wed Apr 27 21:20:12 2011
@@ -0,0 +1,196 @@
+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.
+ */
+
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.concurrent.Callable;
+import java.util.concurrent.FutureTask;
+import java.util.concurrent.LinkedBlockingDeque;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Kristian Rosenvold
+ */
+public class TwoThreadBlockingQueueTest
+    extends TestCase
+{
+    final int num = 100000;
+
+    public void testPut()
+        throws Exception
+    {
+        BlockingQueue twoThreadBlockingQueue = new TwoThreadBlockingQueue();
+
+        String[] items = generate( num );
+        long start = System.currentTimeMillis();
+        for ( int i = 0; i < num; i++ )
+        {
+            twoThreadBlockingQueue.add( items[i] );
+        }
+        long elapsed = System.currentTimeMillis() - start;
+        //System.out.println( "TwoThreadBlockingQueue insert " + num + " elements in  = " + elapsed );
+        System.gc();
+    }
+
+    public void testFunkyPut()
+        throws Exception
+    {
+        FunkyTwoThreadBlockingQueue twoThreadBlockingQueue = new FunkyTwoThreadBlockingQueue();
+
+        String[] items = generate( num );
+        long start = System.currentTimeMillis();
+        for ( int i = 0; i < num; i++ )
+        {
+            twoThreadBlockingQueue.put( items[i] );
+        }
+        long elapsed = System.currentTimeMillis() - start;
+        //System.out.println( "FunkyTwoThreadBlockingQueue insert " + num + " elements in  = " + elapsed );
+        System.gc();
+    }
+
+
+    public void testPutAndTake()
+        throws Exception
+    {
+        final FunkyTwoThreadBlockingQueue twoThreadBlockingQueue = new FunkyTwoThreadBlockingQueue();
+
+        Callable consumer = new Callable()
+        {
+            public Object call()
+                throws Exception
+            {
+                int num = 0;
+                Object taken;
+                do
+                {
+                    taken = twoThreadBlockingQueue.take();
+                    if (taken != TwoThreadBlockingQueue.poison) {
+                        assertEquals( "item" + num++, taken );
+                    }
+                }
+                while ( taken != TwoThreadBlockingQueue.poison);
+                return taken;
+            }
+        };
+
+        FutureTask futureTask = new FutureTask( consumer );
+        Thread thread = new Thread( futureTask );
+        thread.start();
+
+        String[] items = generate( num );
+        long start = System.currentTimeMillis();
+        for ( int i = 0; i < num; i++ )
+        {
+            twoThreadBlockingQueue.put( items[i] );
+        }
+        twoThreadBlockingQueue.put( TwoThreadBlockingQueue.poison );
+        long elapsed = System.currentTimeMillis() - start;
+
+        futureTask.get();
+
+       // System.out.println( "TwoThreadBlockingQueue produced and taken " + num + " elements in  = " + elapsed );
+        System.gc();
+    }
+
+    public void testLBQPut()
+        throws Exception
+    {
+        LinkedBlockingQueue twoThreadBlockingQueue = new LinkedBlockingQueue();
+
+        String[] items = generate( num );
+        long start = System.currentTimeMillis();
+        for ( int i = 0; i < num; i++ )
+        {
+            twoThreadBlockingQueue.put( items[i] );
+        }
+        long elapsed = System.currentTimeMillis() - start;
+        //System.out.println( "LinkedBlockingQueue insert " + num + " elements in  = " + elapsed );
+        System.gc();
+    }
+
+    public void testLDBQPut()
+        throws Exception
+    {
+        LinkedBlockingDeque twoThreadBlockingQueue = new LinkedBlockingDeque();
+
+        String[] items = generate( num );
+        long start = System.currentTimeMillis();
+        for ( int i = 0; i < num; i++ )
+        {
+            twoThreadBlockingQueue.put( items[i] );
+        }
+        long elapsed = System.currentTimeMillis() - start;
+        //System.out.println( "LinkedBlockingDeque insert " + num + " elements in  = " + elapsed );
+
+        System.gc();
+    }
+
+    public void testArrayList()
+        throws Exception
+    {
+        ArrayList twoThreadBlockingQueue = new ArrayList( num);
+
+        String[] items = generate( num );
+        long start = System.currentTimeMillis();
+        for ( int i = 0; i < num; i++ )
+        {
+            twoThreadBlockingQueue.add( items[i] );
+        }
+        long elapsed = System.currentTimeMillis() - start;
+        //System.out.println( "ArrayList insert " + num + " elements in  = " + elapsed );
+        System.gc();
+    }
+
+    public void testLinkedList()
+        throws Exception
+    {
+        LinkedList twoThreadBlockingQueue = new LinkedList( );
+
+        String[] items = generate( num );
+        long start = System.currentTimeMillis();
+        for ( int i = 0; i < num; i++ )
+        {
+            twoThreadBlockingQueue.add( items[i] );
+        }
+        long elapsed = System.currentTimeMillis() - start;
+        //System.out.println( "LinkedList insert " + num + " elements in  = " + elapsed );
+        System.gc();
+    }
+
+
+    public void testTake()
+        throws Exception
+    {
+
+    }
+
+    String[] generate( int num )
+    {
+        String[] result = new String[num];
+        for ( int i = 0; i < num; i++ )
+        {
+            result[i] = "item" + i;
+        }
+        return result;
+    }
+}

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

Modified: maven/surefire/trunk/surefire-booter/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/pom.xml?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/pom.xml (original)
+++ maven/surefire/trunk/surefire-booter/pom.xml Wed Apr 27 21:20:12 2011
@@ -17,7 +17,8 @@
   ~ specific language governing permissions and limitations
   ~ under the License.
   -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
 
   <parent>
@@ -56,6 +57,32 @@
           <target>1.3</target>
         </configuration>
       </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <executions>
+          <execution>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <minimizeJar>true</minimizeJar>
+              <artifactSet>
+                <includes>
+                  <include>commons-lang:commons-lang</include>
+                </includes>
+              </artifactSet>
+              <relocations>
+                <relocation>
+                  <pattern>org.apache.commons.lang</pattern>
+                  <shadedPattern>org.apache.maven.surefire.shade.org.apache.commons.lang</shadedPattern>
+                </relocation>
+              </relocations>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
 </project>
\ No newline at end of file

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterConstants.java Wed Apr 27 21:20:12 2011
@@ -29,7 +29,6 @@ public interface BooterConstants
 {
     String INCLUDES_PROPERTY_PREFIX = "includes";
     String EXCLUDES_PROPERTY_PREFIX = "excludes";
-    String REPORT_PROPERTY_PREFIX = "report.";
     String PARAMS_SUFIX = ".params";
     String TYPES_SUFIX = ".types";
     String USESYSTEMCLASSLOADER = "useSystemClassLoader";
@@ -38,6 +37,7 @@ public interface BooterConstants
     String ISTRIMSTACKTRACE = "isTrimStackTrace";
     String REPORTSDIRECTORY = "reportsDirectory";
     String FORKTIMEOUT = "forkTimeout";
+    String FORKMODE = "forkMode";
     String TESTARTIFACT_VERSION = "testFwJarVersion";
     String TESTARTIFACT_CLASSIFIER = "testFwJarClassifier";
     String REQUESTEDTEST = "requestedTest";

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java Wed Apr 27 21:20:12 2011
@@ -19,15 +19,14 @@ package org.apache.maven.surefire.booter
  * under the License.
  */
 
-import org.apache.maven.surefire.report.ReporterConfiguration;
-import org.apache.maven.surefire.testset.DirectoryScannerParameters;
-import org.apache.maven.surefire.testset.TestArtifactInfo;
-import org.apache.maven.surefire.testset.TestRequest;
-
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.List;
+import org.apache.maven.surefire.report.ReporterConfiguration;
+import org.apache.maven.surefire.testset.DirectoryScannerParameters;
+import org.apache.maven.surefire.testset.TestArtifactInfo;
+import org.apache.maven.surefire.testset.TestRequest;
 
 /**
  * Knows how to serialize and deserialize the booter configuration.
@@ -61,7 +60,6 @@ public class BooterDeserializer
     {
 
         final File reportsDirectory = new File( properties.getProperty( REPORTSDIRECTORY ) );
-        Integer timeout = properties.getIntegerObjectProperty( FORKTIMEOUT );
         final String testNgVersion = properties.getProperty( TESTARTIFACT_VERSION );
         final String testArtifactClassifier = properties.getProperty( TESTARTIFACT_CLASSIFIER );
         final Object testForFork = properties.getTypeDecoded( FORKTESTSET );
@@ -69,7 +67,6 @@ public class BooterDeserializer
         final String requestedTestMethod = properties.getProperty( REQUESTEDTESTMETHOD );
         final File sourceDirectory = properties.getFileProperty( SOURCE_DIRECTORY );
 
-        final List reports = properties.getStringList( REPORT_PROPERTY_PREFIX );
         final List excludesList = properties.getStringList( EXCLUDES_PROPERTY_PREFIX );
         final List includesList = properties.getStringList( INCLUDES_PROPERTY_PREFIX );
 
@@ -82,15 +79,16 @@ public class BooterDeserializer
                                             properties.getBooleanObjectProperty( FAILIFNOTESTS ), runOrder );
 
         TestArtifactInfo testNg = new TestArtifactInfo( testNgVersion, testArtifactClassifier );
-        TestRequest testSuiteDefinition = new TestRequest( testSuiteXmlFiles, sourceDirectory, requestedTest, requestedTestMethod );
+        TestRequest testSuiteDefinition =
+            new TestRequest( testSuiteXmlFiles, sourceDirectory, requestedTest, requestedTestMethod );
 
-        ReporterConfiguration reporterConfiguration = new ReporterConfiguration( reports, reportsDirectory,
-                                                                                 properties.getBooleanObjectProperty(
-                                                                                     ISTRIMSTACKTRACE ), timeout );
+        ReporterConfiguration reporterConfiguration =
+            new ReporterConfiguration( reportsDirectory, properties.getBooleanObjectProperty( ISTRIMSTACKTRACE ) );
 
+        String forkMode = properties.getProperty( FORKMODE );
         return new ProviderConfiguration( dirScannerParams, properties.getBooleanProperty( FAILIFNOTESTS ),
                                           reporterConfiguration, testNg, testSuiteDefinition,
-                                          properties.getProperties(), testForFork );
+                                          properties.getProperties(), testForFork, forkMode );
     }
 
     public StartupConfiguration getProviderConfiguration()
@@ -99,13 +97,14 @@ public class BooterDeserializer
         boolean useSystemClassLoader = properties.getBooleanProperty( USESYSTEMCLASSLOADER );
         boolean useManifestOnlyJar = properties.getBooleanProperty( USEMANIFESTONLYJAR );
         String providerConfiguration = properties.getProperty( PROVIDER_CONFIGURATION );
+        String forkMode = properties.getProperty( FORKMODE );
 
         ClassLoaderConfiguration classLoaderConfiguration =
             new ClassLoaderConfiguration( useSystemClassLoader, useManifestOnlyJar );
 
         ClasspathConfiguration classpathConfiguration = new ClasspathConfiguration( properties );
 
-        return StartupConfiguration.inForkedVm( providerConfiguration, classpathConfiguration,
-                                                classLoaderConfiguration );
+        return StartupConfiguration.inForkedVm( providerConfiguration, classpathConfiguration, classLoaderConfiguration,
+                                                forkMode );
     }
 }

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java Wed Apr 27 21:20:12 2011
@@ -23,6 +23,7 @@ import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
 import java.util.Properties;
+import org.apache.maven.surefire.suite.RunResult;
 
 /**
  * The part of the booter that is unique to a forked vm.
@@ -51,6 +52,7 @@ public class ForkedBooter
     {
         try
         {
+            long start = System.currentTimeMillis();
             if ( args.length > 1 )
             {
                 SystemPropertyManager.setSystemProperties( new File( args[1] ) );
@@ -62,16 +64,16 @@ public class ForkedBooter
             ProviderConfiguration booterConfiguration = booterDeserializer.deserialize();
             final StartupConfiguration providerConfiguration = booterDeserializer.getProviderConfiguration();
 
-            SurefireStarter starter = new SurefireStarter( providerConfiguration, booterConfiguration );
+
+            SurefireStarter starter = new SurefireStarter( providerConfiguration, booterConfiguration, true );
 
             Object forkedTestSet = booterConfiguration.getTestForFork();
-            Properties p = booterConfiguration.getProviderProperties();
-            final int result = forkedTestSet != null
-                ? starter.runSuitesInProcess( forkedTestSet, surefirePropertiesFile, p )
-                : starter.runSuitesInProcess();
+            final RunResult result = forkedTestSet != null
+                ? starter.runSuitesInProcessWhenForked(forkedTestSet )
+                : starter.runSuitesInProcessWhenForked();
 
             // noinspection CallToSystemExit
-            System.exit( result );
+            System.exit( result.getBooterCode() );
         }
         catch ( Throwable t )
         {

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java Wed Apr 27 21:20:12 2011
@@ -22,6 +22,7 @@ package org.apache.maven.surefire.booter
 import java.io.File;
 import java.util.List;
 import java.util.Properties;
+import org.apache.maven.surefire.forking.ForkConfigurationInfo;
 import org.apache.maven.surefire.report.ReporterConfiguration;
 import org.apache.maven.surefire.testset.DirectoryScannerParameters;
 import org.apache.maven.surefire.testset.TestArtifactInfo;
@@ -62,9 +63,12 @@ public class ProviderConfiguration
 
     private final Object forkTestSet;
 
+    private final String forkMode;
+
     public ProviderConfiguration( DirectoryScannerParameters directoryScannerParameters, boolean failIfNoTests,
                                   ReporterConfiguration reporterConfiguration, TestArtifactInfo testArtifact,
-                                  TestRequest testSuiteDefinition, Properties providerProperties, Object forkTestSet )
+                                  TestRequest testSuiteDefinition, Properties providerProperties, Object forkTestSet,
+                                  String forkMode )
     {
         this.providerProperties = providerProperties;
         this.reporterConfiguration = reporterConfiguration;
@@ -73,6 +77,7 @@ public class ProviderConfiguration
         this.dirScannerParams = directoryScannerParameters;
         this.failIfNoTests = failIfNoTests;
         this.forkTestSet = forkTestSet;
+        this.forkMode = forkMode;
     }
 
 
@@ -128,6 +133,11 @@ public class ProviderConfiguration
         return forkTestSet;
     }
 
+    public ForkConfigurationInfo getForkConfigurationInfo( boolean isInFork )
+    {
+        return new ForkConfigurationInfo( forkMode, isInFork ? Boolean.TRUE : Boolean.FALSE );
+    }
+
     public String getTestForForkString()
     {
         if ( forkTestSet instanceof File )
@@ -137,11 +147,15 @@ public class ProviderConfiguration
         return (String) forkTestSet;
     }
 
+    public String getForkMode()
+    {
+        return forkMode;
+    }
+
     public boolean isSurefireForkReturnCode( int returnCode )
     {
-        return TESTS_SUCCEEDED_EXIT_CODE == returnCode ||
-               NO_TESTS_EXIT_CODE == returnCode ||
-            TESTS_FAILED_EXIT_CODE == returnCode;
+        return TESTS_SUCCEEDED_EXIT_CODE == returnCode || NO_TESTS_EXIT_CODE == returnCode
+            || TESTS_FAILED_EXIT_CODE == returnCode;
 
     }
 

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderFactory.java Wed Apr 27 21:20:12 2011
@@ -19,16 +19,15 @@ package org.apache.maven.surefire.booter
  * under the License.
  */
 
-import org.apache.maven.surefire.providerapi.SurefireProvider;
-
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
+import org.apache.maven.surefire.forking.ForkConfigurationInfo;
+import org.apache.maven.surefire.providerapi.SurefireProvider;
 
 /**
  * Creates the surefire provider.
  * <p/>
- * Todo: This class does a little bit too little ;)
  *
  * @author Kristian Rosenvold
  */
@@ -44,15 +43,22 @@ public class ProviderFactory
 
     private final SurefireReflector surefireReflector;
 
+    private final ForkConfigurationInfo forkConfigurationInfo;
+
+    private final Object reporterManagerFactory;
+
 
     public ProviderFactory( StartupConfiguration startupConfiguration, ProviderConfiguration providerConfiguration,
-                            ClassLoader surefireClassLoader, ClassLoader testsClassLoader )
+                            ClassLoader surefireClassLoader, ClassLoader testsClassLoader,
+                            ForkConfigurationInfo forkMode, Object reporterManagerFactory )
     {
         this.providerConfiguration = providerConfiguration;
         this.surefireClassLoader = surefireClassLoader;
         this.startupConfiguration = startupConfiguration;
         this.surefireReflector = new SurefireReflector( surefireClassLoader );
         this.testsClassLoader = testsClassLoader;
+        this.forkConfigurationInfo = forkMode;
+        this.reporterManagerFactory = reporterManagerFactory;
     }
 
     public SurefireProvider createProvider()
@@ -61,13 +67,15 @@ public class ProviderFactory
         Thread.currentThread().setContextClassLoader( surefireClassLoader );
 
         StartupConfiguration starterConfiguration = startupConfiguration;
-        final Object o = surefireReflector.createBooterConfiguration();
+
+        final Object o = surefireReflector.createBooterConfiguration( surefireClassLoader, reporterManagerFactory );
         surefireReflector.setTestSuiteDefinitionAware( o, providerConfiguration.getTestSuiteDefinition() );
         surefireReflector.setProviderPropertiesAware( o, providerConfiguration.getProviderProperties() );
         surefireReflector.setReporterConfigurationAware( o, providerConfiguration.getReporterConfiguration() );
         surefireReflector.setTestClassLoaderAware( o, surefireClassLoader, testsClassLoader );
         surefireReflector.setTestArtifactInfoAware( o, providerConfiguration.getTestArtifact() );
         surefireReflector.setIfDirScannerAware( o, providerConfiguration.getDirScannerParams() );
+        surefireReflector.setForkConfigurationInfo( o, this.forkConfigurationInfo );
 
         Object provider = surefireReflector.instantiateProvider( starterConfiguration.getProviderClassName(), o );
         Thread.currentThread().setContextClassLoader( context );
@@ -109,5 +117,4 @@ public class ProviderFactory
             }
         }
     }
-
 }

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StartupConfiguration.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StartupConfiguration.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StartupConfiguration.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/StartupConfiguration.java Wed Apr 27 21:20:12 2011
@@ -38,24 +38,27 @@ public class StartupConfiguration
 
     private final boolean redirectTestOutputToFile;
 
+    private final String forkMode;
+
 
     public StartupConfiguration( String providerClassName, ClasspathConfiguration classpathConfiguration,
-                                 ClassLoaderConfiguration classLoaderConfiguration, boolean forkRequested,
-                                 boolean inForkedVm, boolean redirectTestOutputToFile )
+                                 ClassLoaderConfiguration classLoaderConfiguration, String forkMode, boolean inForkedVm,
+                                 boolean redirectTestOutputToFile )
     {
         this.providerClassName = providerClassName;
         this.classpathConfiguration = classpathConfiguration;
         this.classLoaderConfiguration = classLoaderConfiguration;
-        isForkRequested = forkRequested;
+        this.forkMode = forkMode;
+        isForkRequested = !"never".equals( forkMode );
         isInForkedVm = inForkedVm;
         this.redirectTestOutputToFile = redirectTestOutputToFile;
     }
 
     public static StartupConfiguration inForkedVm( String providerClassName,
                                                    ClasspathConfiguration classpathConfiguration,
-                                                   ClassLoaderConfiguration classLoaderConfiguration )
+                                                   ClassLoaderConfiguration classLoaderConfiguration, String forkMode )
     {
-        return new StartupConfiguration( providerClassName, classpathConfiguration, classLoaderConfiguration, false,
+        return new StartupConfiguration( providerClassName, classpathConfiguration, classLoaderConfiguration, forkMode,
                                          true, false );
     }
 
@@ -90,7 +93,8 @@ public class StartupConfiguration
         return classLoaderConfiguration;
     }
 
-    public boolean isShadefire(){
-        return providerClassName.startsWith( "org.apache.maven.surefire.shadefire");
+    public boolean isShadefire()
+    {
+        return providerClassName.startsWith( "org.apache.maven.surefire.shadefire" );
     }
 }

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java Wed Apr 27 21:20:12 2011
@@ -19,18 +19,14 @@ package org.apache.maven.surefire.booter
  * under the License.
  */
 
+import java.io.IOException;
+import java.io.PrintStream;
 import org.apache.maven.surefire.providerapi.SurefireProvider;
-import org.apache.maven.surefire.report.ReporterConfiguration;
 import org.apache.maven.surefire.report.ReporterException;
 import org.apache.maven.surefire.suite.RunResult;
 import org.apache.maven.surefire.testset.TestSetFailedException;
 import org.apache.maven.surefire.util.NestedRuntimeException;
 
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.Properties;
-
 /**
  * Invokes surefire with the correct classloader setup.
  * <p/>
@@ -46,50 +42,91 @@ import java.util.Properties;
  */
 public class SurefireStarter
 {
-    private static final int NO_TESTS = 254;
-
     private final ProviderConfiguration providerConfiguration;
 
     private final StartupConfiguration startupConfiguration;
 
-    private final String SUREFIRE_TEST_CLASSPATH = "surefire.test.class.path";
+    private final static String SUREFIRE_TEST_CLASSPATH = "surefire.test.class.path";
 
-    public SurefireStarter( StartupConfiguration startupConfiguration, ProviderConfiguration providerConfiguration )
+    private final boolean inFork;
+
+    public SurefireStarter( StartupConfiguration startupConfiguration, ProviderConfiguration providerConfiguration,
+                            boolean inFork )
     {
         this.providerConfiguration = providerConfiguration;
         this.startupConfiguration = startupConfiguration;
+        this.inFork = inFork;
     }
 
-    public int runSuitesInProcess( Object testSet, File surefirePropertiesFile, Properties p )
+    public RunResult runSuitesInProcessWhenForked( Object testSet )
         throws SurefireExecutionException, IOException
     {
         writeSurefireTestClasspathProperty();
         final ClasspathConfiguration classpathConfiguration = startupConfiguration.getClasspathConfiguration();
 
+        // todo: Find out....
+        // Why is the classloader structure created differently when a testSet is specified ?
+        // Smells like a legacy bug. Need to check issue tracker.
         ClassLoader testsClassLoader = classpathConfiguration.createTestClassLoaderConditionallySystem(
             startupConfiguration.useSystemClassLoader() );
 
         ClassLoader surefireClassLoader = classpathConfiguration.createSurefireClassLoader( testsClassLoader );
 
-        final RunResult runResult = invokeProvider( testSet, testsClassLoader, surefireClassLoader );
-        updateResultsProperties( runResult, p );
-        SystemPropertyManager.writePropertiesFile( surefirePropertiesFile, "surefire", p );
-        return processRunCount( runResult );
+        SurefireReflector surefireReflector = new SurefireReflector( surefireClassLoader );
+
+        final Object forkingReporterFactory = createForkingReporterFactory( surefireReflector );
+
+        return invokeProvider( testSet, testsClassLoader, surefireClassLoader, forkingReporterFactory );
+    }
+
+    private Object createForkingReporterFactory( SurefireReflector surefireReflector )
+    {
+        return surefireReflector.createForkingReporterFactory(
+            this.providerConfiguration.getReporterConfiguration().isTrimStackTrace(),
+            this.providerConfiguration.getReporterConfiguration().getOriginalSystemOut() );
+    }
+
+    // todo: Fix duplication in this method and runSuitesInProcess
+    // This should be fixed "at a higher level", because this whole way
+    // of organizing the code stinks.
+
+    public RunResult runSuitesInProcessWhenForked()
+        throws SurefireExecutionException
+    {
+        ClassLoader testsClassLoader = createInProcessTestClassLoader();
+
+        ClassLoader surefireClassLoader = createSurefireClassloader( testsClassLoader );
+
+        SurefireReflector surefireReflector = new SurefireReflector( surefireClassLoader );
+
+        final Object factory = createForkingReporterFactory( surefireReflector );
+
+        return invokeProvider( null, testsClassLoader, surefireClassLoader, factory );
     }
 
-    public int runSuitesInProcess()
+    public RunResult runSuitesInProcess()
         throws SurefireExecutionException
     {
         // The test classloader must be constructed first to avoid issues with commons-logging until we properly
         // separate the TestNG classloader
         ClassLoader testsClassLoader = createInProcessTestClassLoader();
 
-        final ClasspathConfiguration classpathConfiguration = startupConfiguration.getClasspathConfiguration();
+        ClassLoader surefireClassLoader = createSurefireClassloader( testsClassLoader );
 
-        ClassLoader surefireClassLoader = classpathConfiguration.createSurefireClassLoader( testsClassLoader );
+        SurefireReflector surefireReflector = new SurefireReflector( surefireClassLoader );
 
-        final RunResult runResult = invokeProvider( null, testsClassLoader, surefireClassLoader );
-        return processRunCount( runResult);
+        final Object factory =
+            surefireReflector.createReportingReporterFactory( this.providerConfiguration.getReporterConfiguration() );
+
+        return invokeProvider( null, testsClassLoader, surefireClassLoader, factory );
+    }
+
+    private ClassLoader createSurefireClassloader( ClassLoader testsClassLoader )
+        throws SurefireExecutionException
+    {
+        final ClasspathConfiguration classpathConfiguration = startupConfiguration.getClasspathConfiguration();
+
+        return classpathConfiguration.createSurefireClassLoader( testsClassLoader );
     }
 
     private ClassLoader createInProcessTestClassLoader()
@@ -118,32 +155,18 @@ public class SurefireStarter
         classpathConfiguration.getTestClasspath().writeToSystemProperty( SUREFIRE_TEST_CLASSPATH );
     }
 
-    private static final String RESULTS_ERRORS = "errors";
-
-    private static final String RESULTS_COMPLETED_COUNT = "completedCount";
-
-    private static final String RESULTS_FAILURES = "failures";
-
-    private static final String RESULTS_SKIPPED = "skipped";
-
-
-    private void updateResultsProperties( RunResult runResult, Properties results )
-    {
-        results.setProperty( RESULTS_ERRORS, String.valueOf( runResult.getErrors() ) );
-        results.setProperty( RESULTS_COMPLETED_COUNT, String.valueOf( runResult.getCompletedCount() ) );
-        results.setProperty( RESULTS_FAILURES, String.valueOf( runResult.getFailures() ) );
-        results.setProperty( RESULTS_SKIPPED, String.valueOf( runResult.getSkipped() ) );
-    }
-
-    private RunResult invokeProvider( Object testSet, ClassLoader testsClassLoader, ClassLoader surefireClassLoader )
+    private RunResult invokeProvider( Object testSet, ClassLoader testsClassLoader, ClassLoader surefireClassLoader,
+                                      Object factory )
     {
         final PrintStream orgSystemOut = System.out;
         final PrintStream orgSystemErr = System.err;
         // Note that System.out/System.err are also read in the "ReporterConfiguration" instatiation
         // in createProvider below. These are the same values as here.
+
         ProviderFactory providerFactory =
-            new ProviderFactory( startupConfiguration, providerConfiguration, surefireClassLoader, testsClassLoader );
-        final SurefireProvider provider = providerFactory.createProvider( );
+            new ProviderFactory( startupConfiguration, providerConfiguration, surefireClassLoader, testsClassLoader,
+                                 providerConfiguration.getForkConfigurationInfo( inFork ), factory );
+        final SurefireProvider provider = providerFactory.createProvider();
 
         try
         {
@@ -163,23 +186,4 @@ public class SurefireStarter
             System.setErr( orgSystemErr );
         }
     }
-
-    /**
-     * Returns the process return code based on the RunResult
-     *
-     * @param runCount The run result
-     * @return The process result code
-     * @throws SurefireExecutionException When an exception is found
-     */
-    private int processRunCount( RunResult runCount )
-        throws SurefireExecutionException
-    {
-
-        if ( runCount.getCompletedCount() == 0 && providerConfiguration.isFailIfNoTests().booleanValue() )
-        {
-            return NO_TESTS;
-        }
-
-        return runCount.getBooterCode();
-    }
 }

Modified: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ForkTimeoutTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ForkTimeoutTest.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ForkTimeoutTest.java (original)
+++ maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/ForkTimeoutTest.java Wed Apr 27 21:20:12 2011
@@ -19,6 +19,7 @@ package org.apache.maven.surefire.booter
  * under the License.
  */
 
+import java.util.Iterator;
 import org.apache.maven.surefire.providerapi.AbstractProvider;
 import org.apache.maven.surefire.providerapi.SurefireProvider;
 import org.apache.maven.surefire.report.ReporterConfiguration;
@@ -26,8 +27,6 @@ import org.apache.maven.surefire.report.
 import org.apache.maven.surefire.suite.RunResult;
 import org.apache.maven.surefire.testset.TestSetFailedException;
 
-import java.util.Iterator;
-
 import junit.framework.TestCase;
 
 /**
@@ -41,7 +40,7 @@ public class ForkTimeoutTest
     {
         final Integer forkTimeout1 = new Integer( 100 );
         SurefireProvider surefireProvider = new TestProvider();
-        ReporterConfiguration reporterConfiguration = new ReporterConfiguration( null, null, null, forkTimeout1 );
+        ReporterConfiguration reporterConfiguration = new ReporterConfiguration( null, null );
         new ForkTimeout( 100, reporterConfiguration, surefireProvider );
         try
         {

Modified: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java (original)
+++ maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/SurefireReflectorTest.java Wed Apr 27 21:20:12 2011
@@ -20,20 +20,19 @@ nse agreements.  See the NOTICE file
  * under the License.
  */
 
-import org.apache.maven.surefire.report.ReporterConfiguration;
-import org.apache.maven.surefire.testset.DirectoryScannerParameters;
-import org.apache.maven.surefire.testset.TestArtifactInfo;
-import org.apache.maven.surefire.testset.TestRequest;
-
 import java.io.File;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Properties;
+import org.apache.maven.surefire.report.ReporterConfiguration;
+import org.apache.maven.surefire.testset.DirectoryScannerParameters;
+import org.apache.maven.surefire.testset.TestArtifactInfo;
+import org.apache.maven.surefire.testset.TestRequest;
+import org.apache.maven.surefire.util.NestedRuntimeException;
 
 import junit.framework.TestCase;
-import org.apache.maven.surefire.util.NestedRuntimeException;
 
 /**
  * @author Kristian Rosenvold
@@ -91,7 +90,7 @@ public class SurefireReflectorTest
 
     private ReporterConfiguration getReporterConfiguration()
     {
-        return new ReporterConfiguration( new ArrayList(), new File( "CDE" ), Boolean.TRUE, null );
+        return new ReporterConfiguration( new File( "CDE" ), Boolean.TRUE );
     }
 
     public void testTestClassLoaderAware()

Modified: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgExecuteErrorIT.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgExecuteErrorIT.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgExecuteErrorIT.java (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgExecuteErrorIT.java Wed Apr 27 21:20:12 2011
@@ -18,12 +18,11 @@ package org.apache.maven.surefire.its;
  * under the License.
  */
 
+import java.io.File;
 import org.apache.maven.it.VerificationException;
 import org.apache.maven.it.Verifier;
 import org.apache.maven.it.util.ResourceExtractor;
 
-import java.io.File;
-
 /**
  * Test for checking that the output from a forked suite is properly captured even if the suite encounters a severe error.
  *
@@ -47,6 +46,6 @@ public class CheckTestNgExecuteErrorIT
         } // expected 
 
         verifier.resetStreams();
-        assertTrue( new File( testDir, "target/surefire-reports/TestSuite-output.txt" ).length() > 0 );
+        verifier.verifyTextInLog( "at org.apache.maven.surefire.testng.TestNGExecutor.run" );
     }
 }

Modified: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire628ConsoleOutputBeforeAndAfterClassIT.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire628ConsoleOutputBeforeAndAfterClassIT.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire628ConsoleOutputBeforeAndAfterClassIT.java (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire628ConsoleOutputBeforeAndAfterClassIT.java Wed Apr 27 21:20:12 2011
@@ -20,7 +20,7 @@ package org.apache.maven.surefire.its;
 
 
 /**
- * SUREFIRE-621 Asserts that console output always goes somewhere ;)
+ * Asserts that console output always goes somewhere ;)
  *
  * @author Kristian Rosenvold
  */

Copied: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire674BuildFailingWhenFailsafeErrorsIT.java (from r1097226, maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire628ConsoleOutputBeforeAndAfterClassIT.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire674BuildFailingWhenFailsafeErrorsIT.java?p2=maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire674BuildFailingWhenFailsafeErrorsIT.java&p1=maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire628ConsoleOutputBeforeAndAfterClassIT.java&r1=1097226&r2=1097246&rev=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire628ConsoleOutputBeforeAndAfterClassIT.java (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire674BuildFailingWhenFailsafeErrorsIT.java Wed Apr 27 21:20:12 2011
@@ -19,32 +19,35 @@ package org.apache.maven.surefire.its;
  */
 
 
+import org.apache.maven.it.VerificationException;
+
+import junit.framework.Assert;
+
 /**
- * SUREFIRE-621 Asserts that console output always goes somewhere ;)
+ * SUREFIRE-674 Asserts that the build fails when tests have errors
  *
  * @author Kristian Rosenvold
  */
-public class Surefire628ConsoleOutputBeforeAndAfterClassIT
+public class Surefire674BuildFailingWhenFailsafeErrorsIT
     extends SurefireVerifierTestClass
 {
 
-    public Surefire628ConsoleOutputBeforeAndAfterClassIT()
+    public Surefire674BuildFailingWhenFailsafeErrorsIT()
     {
-        super( "/surefire-628-consoleoutputbeforeandafterclass" );
+        super( "/failsafe-buildfail" );
     }
 
-    public void testJunit3ParallelBuildResultCount()
+    public void testBuildFailingWhenErrors()
         throws Exception
     {
-        failNever();
-        executeTest();
-
-        verifyTextInLog( "628Test1" );
-        verifyTextInLog( "Before628Test1" );
-        verifyTextInLog( "After628Test1" );
-        verifyTextInLog( "628Test2" );
-        verifyTextInLog( "Before628Test2" );
-        verifyTextInLog( "After628Test2" );
+        try
+        {
+            executeVerify();
+            Assert.fail( "The verifier should throw an exception" );
+        }
+        catch ( VerificationException ignore )
+        {
+        }
+        verifyTextInLog( "BUILD FAILURE" );
     }
-
 }
\ No newline at end of file

Modified: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SurefireVerifierTestClass.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SurefireVerifierTestClass.java?rev=1097246&r1=1097245&r2=1097246&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SurefireVerifierTestClass.java (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SurefireVerifierTestClass.java Wed Apr 27 21:20:12 2011
@@ -39,7 +39,7 @@ import junit.framework.TestCase;
 /**
  * Contains commonly used featurtes for most tests, encapsulating
  * common use cases.
- *
+ * <p/>
  * Also includes thread-safe access to the extracted resource
  * files, which AbstractSurefireIntegrationTestClass does not.
  * Thread safe only for running in "classes" mode.
@@ -84,8 +84,6 @@ public abstract class SurefireVerifierTe
     {
         String tempDirPath = System.getProperty( "maven.test.tmpdir", System.getProperty( "java.io.tmpdir" ) );
         File tempDir = new File( tempDirPath, this.getClass().getSimpleName() );
-        System.out.println( "tempDir = " + tempDir );
-
         File testDir = new File( tempDir, resourcePath );
         FileUtils.deleteDirectory( testDir );
 
@@ -199,6 +197,12 @@ public abstract class SurefireVerifierTe
         return execute( "test" );
     }
 
+    protected Verifier executeVerify()
+        throws VerificationException
+    {
+        return execute( "verify" );
+    }
+
     protected Verifier execute( String goal )
         throws VerificationException
     {
@@ -235,7 +239,7 @@ public abstract class SurefireVerifierTe
 
     protected File getSiteFile( String moduleName, String fileName )
     {
-        File targetDir = getSubFile(moduleName + "/target/site" );
+        File targetDir = getSubFile( moduleName + "/target/site" );
         return new File( targetDir, fileName );
     }
 
@@ -355,7 +359,8 @@ public abstract class SurefireVerifierTe
         }
         catch ( InvalidVersionSpecificationException e )
         {
-            throw (RuntimeException) new IllegalArgumentException( "Invalid version range: " + versionRangeStr ).initCause( e );
+            throw (RuntimeException) new IllegalArgumentException(
+                "Invalid version range: " + versionRangeStr ).initCause( e );
         }
 
         ArtifactVersion version = getMavenVersion();

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/invoker.properties
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/invoker.properties?rev=1097246&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/invoker.properties (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/invoker.properties Wed Apr 27 21:20:12 2011
@@ -0,0 +1,19 @@
+#
+# 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.
+#
+invoker.buildResult=failure

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/failsafe-buildfail/invoker.properties
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message