maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From car...@apache.org
Subject svn commit: r415349 - in /maven/surefire/trunk/surefire-booter: ./ src/main/java/org/apache/maven/surefire/booter/ src/main/java/org/apache/maven/surefire/booter/output/ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apache/ src/test/jav...
Date Mon, 19 Jun 2006 15:00:45 GMT
Author: carlos
Date: Mon Jun 19 08:00:44 2006
New Revision: 415349

URL: http://svn.apache.org/viewvc?rev=415349&view=rev
Log:
[MSUREFIRE-136] Added option to redirect test output to a file, redirectTestOutputToFile

Added:
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/FileOutputConsumerProxy.java   (with props)
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/ForkingStreamConsumer.java   (with props)
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/OutputConsumer.java   (with props)
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/OutputConsumerProxy.java   (with props)
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/PrintWriterOutputConsumer.java   (with props)
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/StandardOutputConsumer.java   (with props)
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/SupressFooterOutputConsumerProxy.java   (with props)
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/SupressHeaderOutputConsumerProxy.java   (with props)
    maven/surefire/trunk/surefire-booter/src/test/
    maven/surefire/trunk/surefire-booter/src/test/java/
    maven/surefire/trunk/surefire-booter/src/test/java/org/
    maven/surefire/trunk/surefire-booter/src/test/java/org/apache/
    maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/
    maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/
    maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/
    maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/
    maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/AbstractOutputConsumerTest.java   (with props)
    maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/FileOutputConsumerProxyTest.java   (with props)
    maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/ForkingStreamConsumerTest.java   (with props)
    maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/OutputConsumerProxyTest.java   (with props)
    maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/PrintWriterOutputConsumerTest.java   (with props)
    maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/StandardOutputConsumerTest.java   (with props)
    maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/SupressFooterOutputConsumerProxyTest.java   (with props)
    maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/SupressHeaderOutputConsumerProxyTest.java   (with props)
Modified:
    maven/surefire/trunk/surefire-booter/pom.xml
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkingWriterStreamConsumer.java
    maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java

Modified: maven/surefire/trunk/surefire-booter/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/pom.xml?rev=415349&r1=415348&r2=415349&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/pom.xml (original)
+++ maven/surefire/trunk/surefire-booter/pom.xml Mon Jun 19 08:00:44 2006
@@ -15,7 +15,9 @@
   ~ 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/maven-v4_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/maven-v4_0_0.xsd">
   <parent>
     <artifactId>surefire</artifactId>
     <groupId>org.apache.maven.surefire</groupId>
@@ -34,6 +36,12 @@
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>jmock</groupId>
+      <artifactId>jmock</artifactId>
+      <version>1.0.1</version>
       <scope>test</scope>
     </dependency>
   </dependencies>

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkingWriterStreamConsumer.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkingWriterStreamConsumer.java?rev=415349&r1=415348&r2=415349&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkingWriterStreamConsumer.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkingWriterStreamConsumer.java Mon Jun 19 08:00:44 2006
@@ -16,6 +16,7 @@
  * limitations under the License.
  */
 
+import org.apache.maven.surefire.booter.output.ForkingStreamConsumer;
 import org.apache.maven.surefire.report.ForkingConsoleReporter;
 import org.codehaus.plexus.util.cli.StreamConsumer;
 
@@ -23,6 +24,7 @@
 import java.io.Writer;
 
 /**
+ * @deprecated use {@link ForkingStreamConsumer}
  * @author Jason van Zyl
  * @version $Revision$
  */

Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java?rev=415349&r1=415348&r2=415349&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java (original)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireBooter.java Mon Jun 19 08:00:44 2006
@@ -16,22 +16,11 @@
  * limitations under the License.
  */
 
-import org.apache.maven.surefire.Surefire;
-import org.apache.maven.surefire.testset.TestSetFailedException;
-import org.apache.maven.surefire.util.NestedRuntimeException;
-import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.cli.CommandLineException;
-import org.codehaus.plexus.util.cli.CommandLineUtils;
-import org.codehaus.plexus.util.cli.StreamConsumer;
-
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.net.MalformedURLException;
@@ -43,7 +32,21 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
-import java.util.Arrays;
+
+import org.apache.maven.surefire.Surefire;
+import org.apache.maven.surefire.booter.output.FileOutputConsumerProxy;
+import org.apache.maven.surefire.booter.output.ForkingStreamConsumer;
+import org.apache.maven.surefire.booter.output.OutputConsumer;
+import org.apache.maven.surefire.booter.output.StandardOutputConsumer;
+import org.apache.maven.surefire.booter.output.SupressFooterOutputConsumerProxy;
+import org.apache.maven.surefire.booter.output.SupressHeaderOutputConsumerProxy;
+import org.apache.maven.surefire.testset.TestSetFailedException;
+import org.apache.maven.surefire.util.NestedRuntimeException;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+import org.codehaus.plexus.util.cli.StreamConsumer;
 
 /**
  * @author Jason van Zyl
@@ -61,6 +64,8 @@
     private List surefireBootClassPathUrls = new ArrayList();
 
     private List testSuites = new ArrayList();
+    
+    private boolean redirectTestOutputToFile = false;
 
     // ----------------------------------------------------------------------
     //
@@ -76,6 +81,8 @@
 
     private boolean childDelegation = true;
 
+    private File reportsDirectory;
+
     static
     {
         try
@@ -123,6 +130,35 @@
             surefireClassPathUrls.add( path );
         }
     }
+    
+    /**
+     * When forking, setting this to true will make the test output to be saved in a file
+     * instead of showing it on the standard output 
+     *  
+     * @param redirectTestOutputToFile
+     */
+    public void setRedirectTestOutputToFile( boolean redirectTestOutputToFile )
+    {
+        this.redirectTestOutputToFile = redirectTestOutputToFile;
+    }
+
+    /**
+     * Set the directory where reports will be saved
+     * 
+     * @param reportsDirectory the directory
+     */
+    public void setReportsDirectory( File reportsDirectory )
+    {
+        this.reportsDirectory = reportsDirectory;
+    }
+
+    /**
+     * Get the directory where reports will be saved
+     */
+    public File getReportsDirectory()
+    {
+        return reportsDirectory;
+    }
 
     public void setForkConfiguration( ForkConfiguration forkConfiguration )
     {
@@ -466,11 +502,9 @@
             cli.createArgument().setFile( systemProperties );
         }
 
-        Writer consoleWriter = new OutputStreamWriter( System.out );
+        StreamConsumer out = getForkingStreamConsumer( showHeading, showFooter, redirectTestOutputToFile );
 
-        StreamConsumer out = new ForkingWriterStreamConsumer( consoleWriter, showHeading, showFooter );
-
-        StreamConsumer err = new ForkingWriterStreamConsumer( consoleWriter, showHeading, showFooter );
+        StreamConsumer err = getForkingStreamConsumer( showHeading, showFooter, redirectTestOutputToFile );
 
         if ( forkConfiguration.isDebug() )
         {
@@ -775,5 +809,27 @@
         }
         addSurefireClassPathUrl( path );
     }
+
+    private StreamConsumer getForkingStreamConsumer( boolean showHeading, boolean showFooter, boolean showTestOutput )
+    {
+        OutputConsumer outputConsumer = new StandardOutputConsumer();
+
+        if ( !showTestOutput )
+        {
+            outputConsumer = new FileOutputConsumerProxy( outputConsumer, getReportsDirectory() );
+        }
+
+        if ( !showHeading )
+        {
+            outputConsumer = new SupressHeaderOutputConsumerProxy( outputConsumer );
+        }
+        if ( !showFooter )
+        {
+            outputConsumer = new SupressFooterOutputConsumerProxy( outputConsumer );
+        }
+
+        return new ForkingStreamConsumer( outputConsumer );
+    }
 }
+
 

Added: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/FileOutputConsumerProxy.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/FileOutputConsumerProxy.java?rev=415349&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/FileOutputConsumerProxy.java (added)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/FileOutputConsumerProxy.java Mon Jun 19 08:00:44 2006
@@ -0,0 +1,141 @@
+package org.apache.maven.surefire.booter.output;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import org.apache.maven.surefire.report.ReportEntry;
+
+/**
+ * Surefire output consumer proxy that writes test output to a {@link File} for each test suite.
+ * 
+ * @since 2.1
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class FileOutputConsumerProxy
+    extends OutputConsumerProxy
+{
+
+    private static final String USER_DIR = System.getProperty( "user.dir" );
+
+    private File reportsDirectory;
+
+    private PrintWriter printWriter;
+
+    /**
+     * Create a consumer that will write to a {@link File} for each test.
+     * Files will be saved in working directory.
+     */
+    public FileOutputConsumerProxy( OutputConsumer outputConsumer )
+    {
+        this( outputConsumer, new File( USER_DIR ) );
+    }
+
+    /**
+     * Create a consumer that will write to a {@link File} for each test
+     * 
+     * @param reportsDirectory directory where files will be saved 
+     */
+    public FileOutputConsumerProxy( OutputConsumer outputConsumer, File reportsDirectory )
+    {
+        super( outputConsumer );
+        this.setReportsDirectory( reportsDirectory );
+    }
+
+    /**
+     * Set the directory where reports will be saved
+     * 
+     * @param reportsDirectory the directory
+     */
+    public void setReportsDirectory( File reportsDirectory )
+    {
+        this.reportsDirectory = reportsDirectory;
+    }
+
+    /**
+     * Get the directory where reports will be saved
+     */
+    public File getReportsDirectory()
+    {
+        return reportsDirectory;
+    }
+
+    /**
+     * Set the {@link PrintWriter} used for the current test suite
+     * 
+     * @param writer
+     */
+    public void setPrintWriter( PrintWriter writer )
+    {
+        this.printWriter = writer;
+    }
+
+    /**
+     * Get the {@link PrintWriter} used for the current test suite
+     */
+    public PrintWriter getPrintWriter()
+    {
+        return printWriter;
+    }
+
+    public void testSetStarting( ReportEntry reportEntry )
+    {
+        if ( getPrintWriter() != null )
+        {
+            throw new IllegalStateException( "testSetStarting called twice" );
+        }
+        File file = new File( getReportsDirectory(), reportEntry.getName() + "-output.txt" );
+        try
+        {
+            setPrintWriter( new PrintWriter( new BufferedWriter( new FileWriter( file ) ) ) );
+        }
+        catch ( IOException e )
+        {
+            throw new RuntimeException( e );
+        }
+        super.testSetStarting( reportEntry );
+    }
+
+    public void testSetCompleted()
+    {
+        if ( getPrintWriter() == null )
+        {
+            throw new IllegalStateException( "testSetCompleted called before testSetStarting" );
+        }
+        getPrintWriter().close();
+        setPrintWriter( null );
+        super.testSetCompleted();
+    }
+
+    /**
+     * Write the output to the current test file 
+     */
+    public void consumeOutputLine( String line )
+    {
+        if ( getPrintWriter() == null )
+        {
+            throw new IllegalStateException( "consumeOutputLine called before testSetStarting" );
+        }
+        getPrintWriter().write( line );
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/FileOutputConsumerProxy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/FileOutputConsumerProxy.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/ForkingStreamConsumer.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/ForkingStreamConsumer.java?rev=415349&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/ForkingStreamConsumer.java (added)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/ForkingStreamConsumer.java Mon Jun 19 08:00:44 2006
@@ -0,0 +1,74 @@
+package org.apache.maven.surefire.booter.output;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.surefire.report.ForkingConsoleReporter;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+/**
+ * {@link StreamConsumer} that understands Surefire output made by {@link ForkingConsoleReporter}
+ * and filters it depending on configuration options
+ * 
+ * @since 2.1
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class ForkingStreamConsumer
+    implements StreamConsumer
+{
+    private static int STANDARD_PREFIX_LENGTH = ForkingConsoleReporter.FORKING_PREFIX_STANDARD.length();
+
+    private static int HEADING_PREFIX_LENGTH = ForkingConsoleReporter.FORKING_PREFIX_HEADING.length();
+
+    private static int FOOTER_PREFIX_LENGTH = ForkingConsoleReporter.FORKING_PREFIX_FOOTER.length();
+
+    private OutputConsumer outputConsumer;
+
+    public ForkingStreamConsumer( OutputConsumer outputConsumer )
+    {
+        this.outputConsumer = outputConsumer;
+    }
+
+    public void consumeLine( String line )
+    {
+        if ( line.startsWith( ForkingConsoleReporter.FORKING_PREFIX_HEADING ) )
+        {
+            outputConsumer.consumeHeaderLine( line.substring( HEADING_PREFIX_LENGTH ) );
+        }
+        else if ( line.startsWith( ForkingConsoleReporter.FORKING_PREFIX_STANDARD ) )
+        {
+            String message = line.substring( STANDARD_PREFIX_LENGTH );
+            if ( ForkingConsoleReporter.isTestSetStartingMessage( message ) )
+            {
+                outputConsumer.testSetStarting( ForkingConsoleReporter.parseTestSetStartingMessage( message ) );
+            }
+            else if ( ForkingConsoleReporter.isTestSetCompletedMessage( message ) )
+            {
+                outputConsumer.testSetCompleted();
+            }
+            outputConsumer.consumeMessageLine( message );
+        }
+        else if ( line.startsWith( ForkingConsoleReporter.FORKING_PREFIX_FOOTER ) )
+        {
+            outputConsumer.consumeFooterLine( line.substring( FOOTER_PREFIX_LENGTH ) );
+        }
+        else
+        {
+            outputConsumer.consumeOutputLine( line );
+        }
+    }
+}

Propchange: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/ForkingStreamConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/ForkingStreamConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/OutputConsumer.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/OutputConsumer.java?rev=415349&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/OutputConsumer.java (added)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/OutputConsumer.java Mon Jun 19 08:00:44 2006
@@ -0,0 +1,72 @@
+package org.apache.maven.surefire.booter.output;
+
+import org.apache.maven.surefire.report.ReportEntry;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * Surefire output consumer that will be called from Surefire when forking tests to process
+ * the lines of the surefire header, messages, footer and test output from the forked Surefire execution.
+ * 
+ * @since 2.1
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public interface OutputConsumer
+{
+
+    /**
+     * Process a line from Surefire header
+     * 
+     * @param line the line to process
+     */
+    void consumeHeaderLine( String line );
+
+    /**
+     * Process a line with a Surefire message (not part of test output)
+     * 
+     * @param line the line to process
+     */
+    void consumeMessageLine( String line );
+
+    /**
+     * Process a line from Surefire footer
+     * 
+     * @param line the line to process
+     */
+    void consumeFooterLine( String line );
+
+    /**
+     * Process a line from test output
+     * 
+     * @param line the line to process
+     */
+    void consumeOutputLine( String line );
+
+    /**
+     * This method will be called when a test set starts, before consuming surefire message lines.
+     * 
+     * @param reportEntry The {@link ReportEntry} with the name and group (optional) of the test that starts
+     */
+    void testSetStarting( ReportEntry reportEntry );
+
+    /**
+     * This method will be called when a test set ends, after consuming all its surefire message lines.
+     */
+    void testSetCompleted();
+
+}

Propchange: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/OutputConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/OutputConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/OutputConsumerProxy.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/OutputConsumerProxy.java?rev=415349&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/OutputConsumerProxy.java (added)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/OutputConsumerProxy.java Mon Jun 19 08:00:44 2006
@@ -0,0 +1,112 @@
+package org.apache.maven.surefire.booter.output;
+
+import org.apache.maven.surefire.report.ReportEntry;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * Surefire output consumer that will delegate to another {@link OutputConsumer}
+ * 
+ * @since 2.1
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class OutputConsumerProxy
+    implements OutputConsumer
+{
+
+    private OutputConsumer outputConsumer;
+
+    /**
+     * Create a output consumer that will delegate all calls to the proxied output consumer
+     * 
+     * @param outputConsumer output consumer to delegate to
+     */
+    public OutputConsumerProxy( OutputConsumer outputConsumer )
+    {
+        this.setOutputConsumer( outputConsumer );
+    }
+
+    /**
+     * {@link OutputConsumer} that calls will be delegated to 
+     * 
+     * @param outputConsumer the proxied {@link OutputConsumer}
+     */
+    public void setOutputConsumer( OutputConsumer outputConsumer )
+    {
+        this.outputConsumer = outputConsumer;
+    }
+
+    /**
+     * {@link OutputConsumer} that calls will be delegated to 
+     * 
+     * @return the proxied {@link OutputConsumer}
+     */
+    public OutputConsumer getOutputConsumer()
+    {
+        return outputConsumer;
+    }
+
+    /**
+     * Delegate to proxied {@link OutputConsumer}
+     */
+    public void consumeHeaderLine( String line )
+    {
+        getOutputConsumer().consumeHeaderLine( line );
+    }
+
+    /**
+     * Delegate to proxied {@link OutputConsumer}
+     */
+    public void consumeMessageLine( String line )
+    {
+        getOutputConsumer().consumeMessageLine( line );
+    }
+
+    /**
+     * Delegate to proxied {@link OutputConsumer}
+     */
+    public void consumeFooterLine( String line )
+    {
+        getOutputConsumer().consumeFooterLine( line );
+    }
+
+    /**
+     * Delegate to proxied {@link OutputConsumer}
+     */
+    public void consumeOutputLine( String line )
+    {
+        getOutputConsumer().consumeOutputLine( line );
+    }
+
+    /**
+     * Delegate to proxied {@link OutputConsumer}
+     */
+    public void testSetStarting( ReportEntry reportEntry )
+    {
+        getOutputConsumer().testSetStarting( reportEntry );
+    }
+
+    /**
+     * Delegate to proxied {@link OutputConsumer}
+     */
+    public void testSetCompleted()
+    {
+        getOutputConsumer().testSetCompleted();
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/OutputConsumerProxy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/OutputConsumerProxy.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/PrintWriterOutputConsumer.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/PrintWriterOutputConsumer.java?rev=415349&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/PrintWriterOutputConsumer.java (added)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/PrintWriterOutputConsumer.java Mon Jun 19 08:00:44 2006
@@ -0,0 +1,119 @@
+package org.apache.maven.surefire.booter.output;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.PrintWriter;
+import java.io.Writer;
+
+import org.apache.maven.surefire.report.ReportEntry;
+
+/**
+ * Surefire output consumer that writes everything to a {@link Writer}
+ * 
+ * @since 2.1
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class PrintWriterOutputConsumer
+    implements OutputConsumer
+{
+
+    private PrintWriter printWriter;
+
+    /**
+     * Create a consumer uninitialized, {@link #setPrintWriter(PrintWriter)} must be called before using it
+     */
+    public PrintWriterOutputConsumer()
+    {
+    }
+
+    /**
+     * Create a consumer that will write to the specified {@link Writer}
+     * 
+     * @param writer where to write to
+     */
+    public PrintWriterOutputConsumer( Writer writer )
+    {
+        this.setPrintWriter( new PrintWriter( writer ) );
+    }
+
+    /**
+     * Set the {@link PrintWriter} used by this object
+     * 
+     * @param writer
+     */
+    public void setPrintWriter( PrintWriter writer )
+    {
+        this.printWriter = writer;
+    }
+
+    /**
+     * Get the {@link PrintWriter} used by this object
+     */
+    public PrintWriter getPrintWriter()
+    {
+        return printWriter;
+    }
+
+    public void consumeHeaderLine( String line )
+    {
+        write( line );
+    }
+
+    public void consumeMessageLine( String line )
+    {
+        write( line );
+    }
+
+    public void consumeFooterLine( String line )
+    {
+        write( line );
+    }
+
+    public void consumeOutputLine( String line )
+    {
+        write( line );
+    }
+
+    /**
+     * Do nothing
+     */
+    public void testSetStarting( ReportEntry reportEntry )
+    {
+        // do nothing
+    }
+
+    /**
+     * Do nothing
+     */
+    public void testSetCompleted()
+    {
+        // do nothing
+    }
+
+    /**
+     * Write a line and flush
+     * 
+     * @param line
+     */
+    private void write( String line )
+    {
+        getPrintWriter().println( line );
+        getPrintWriter().flush();
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/PrintWriterOutputConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/PrintWriterOutputConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/StandardOutputConsumer.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/StandardOutputConsumer.java?rev=415349&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/StandardOutputConsumer.java (added)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/StandardOutputConsumer.java Mon Jun 19 08:00:44 2006
@@ -0,0 +1,40 @@
+package org.apache.maven.surefire.booter.output;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.PrintWriter;
+
+/**
+ * Surefire output consumer that writes everything to {@link System#out}
+ * 
+ * @since 2.1
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class StandardOutputConsumer
+    extends PrintWriterOutputConsumer
+{
+
+    /**
+     * Create a consumer that will write to {@link System#out}
+     */
+    public StandardOutputConsumer()
+    {
+        setPrintWriter( new PrintWriter( System.out ) );
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/StandardOutputConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/StandardOutputConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/SupressFooterOutputConsumerProxy.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/SupressFooterOutputConsumerProxy.java?rev=415349&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/SupressFooterOutputConsumerProxy.java (added)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/SupressFooterOutputConsumerProxy.java Mon Jun 19 08:00:44 2006
@@ -0,0 +1,48 @@
+package org.apache.maven.surefire.booter.output;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * Surefire output consumer that will take out the surefire footer
+ * 
+ * @since 2.1
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class SupressFooterOutputConsumerProxy
+    extends OutputConsumerProxy
+{
+
+    /**
+     * Create a consumer that will delegate all calls to the next filter but {@link #consumeFooterLine(String)}
+     * 
+     * @param nextFilter filter to delegate to
+     */
+    public SupressFooterOutputConsumerProxy( OutputConsumer nextFilter )
+    {
+        super( nextFilter );
+    }
+
+    /**
+     * Do nothing
+     */
+    public void consumeFooterLine( String line )
+    {
+        /* do nothing */
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/SupressFooterOutputConsumerProxy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/SupressFooterOutputConsumerProxy.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/SupressHeaderOutputConsumerProxy.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/SupressHeaderOutputConsumerProxy.java?rev=415349&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/SupressHeaderOutputConsumerProxy.java (added)
+++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/SupressHeaderOutputConsumerProxy.java Mon Jun 19 08:00:44 2006
@@ -0,0 +1,48 @@
+package org.apache.maven.surefire.booter.output;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * Surefire output consumer that will take out the surefire header
+ * 
+ * @since 2.1
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class SupressHeaderOutputConsumerProxy
+    extends OutputConsumerProxy
+{
+
+    /**
+     * Create a consumer that will delegate all calls to the next filter but {@link #consumeHeaderLine(String)}
+     * 
+     * @param nextFilter filter to delegate to
+     */
+    public SupressHeaderOutputConsumerProxy( OutputConsumer nextFilter )
+    {
+        super( nextFilter );
+    }
+
+    /**
+     * Do nothing
+     */
+    public void consumeHeaderLine( String line )
+    {
+        /* do nothing */
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/SupressHeaderOutputConsumerProxy.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/output/SupressHeaderOutputConsumerProxy.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/AbstractOutputConsumerTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/AbstractOutputConsumerTest.java?rev=415349&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/AbstractOutputConsumerTest.java (added)
+++ maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/AbstractOutputConsumerTest.java Mon Jun 19 08:00:44 2006
@@ -0,0 +1,119 @@
+package org.apache.maven.surefire.booter.output;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.surefire.report.ReportEntry;
+
+import junit.framework.TestCase;
+
+/**
+ * Test for {@link OutputConsumer}
+ * 
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class AbstractOutputConsumerTest
+    extends TestCase
+{
+
+    private OutputConsumer outputConsumer;
+
+    private String line;
+
+    private ReportEntry reportEntry;
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        setLine( "line" );
+        setReportEntry( new ReportEntry() );
+        getReportEntry().setGroup( "group" );
+        getReportEntry().setName( "name" );
+    }
+
+    public void setOutputConsumer( OutputConsumer outputConsumer )
+    {
+        this.outputConsumer = outputConsumer;
+    }
+
+    public OutputConsumer getOutputConsumer()
+    {
+        return outputConsumer;
+    }
+
+    public void setLine( String line )
+    {
+        this.line = line;
+    }
+
+    public String getLine()
+    {
+        return line;
+    }
+
+    public void setReportEntry( ReportEntry reportEntry )
+    {
+        this.reportEntry = reportEntry;
+    }
+
+    public ReportEntry getReportEntry()
+    {
+        return reportEntry;
+    }
+
+    public void testConsumeHeaderLine()
+    {
+        getOutputConsumer().testSetStarting( getReportEntry() );
+        getOutputConsumer().consumeHeaderLine( getLine() );
+        getOutputConsumer().testSetCompleted();
+    }
+
+    public void testConsumeMessageLine()
+    {
+        getOutputConsumer().testSetStarting( getReportEntry() );
+        getOutputConsumer().consumeMessageLine( getLine() );
+        getOutputConsumer().testSetCompleted();
+    }
+
+    public void testConsumeFooterLine()
+    {
+        getOutputConsumer().testSetStarting( getReportEntry() );
+        getOutputConsumer().consumeFooterLine( getLine() );
+        getOutputConsumer().testSetCompleted();
+    }
+
+    public void testConsumeOutputLine()
+        throws Exception
+    {
+        getOutputConsumer().testSetStarting( getReportEntry() );
+        getOutputConsumer().consumeOutputLine( getLine() );
+        getOutputConsumer().testSetCompleted();
+    }
+
+    public void testTestSetStarting()
+    {
+        getOutputConsumer().testSetStarting( getReportEntry() );
+    }
+
+    public void testTestSetCompleted()
+    {
+        getOutputConsumer().testSetStarting( getReportEntry() );
+        getOutputConsumer().testSetCompleted();
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/AbstractOutputConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/AbstractOutputConsumerTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/FileOutputConsumerProxyTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/FileOutputConsumerProxyTest.java?rev=415349&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/FileOutputConsumerProxyTest.java (added)
+++ maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/FileOutputConsumerProxyTest.java Mon Jun 19 08:00:44 2006
@@ -0,0 +1,81 @@
+package org.apache.maven.surefire.booter.output;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+
+import org.jmock.core.constraint.IsEqual;
+import org.jmock.core.matcher.InvokeOnceMatcher;
+
+/**
+ * Test for {@link FileOutputConsumerProxy}
+ * 
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class FileOutputConsumerProxyTest
+    extends OutputConsumerProxyTest
+{
+
+    private static final String USER_DIR = System.getProperty( "user.dir" );
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        setOutputConsumer( new FileOutputConsumerProxy( (OutputConsumer) getOutputConsumerMock().proxy() ) );
+    }
+
+    public void testConsumeOutputLine()
+        throws Exception
+    {
+        File reportFile = new File( USER_DIR, getReportEntry().getName() + "-output.txt" );
+        reportFile.delete();
+
+        getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "testSetStarting" )
+            .with( new IsEqual( getReportEntry() ) );
+        getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "testSetCompleted" );
+        getOutputConsumer().testSetStarting( getReportEntry() );
+        getOutputConsumer().consumeOutputLine( getLine() );
+        getOutputConsumer().testSetCompleted();
+        getOutputConsumerMock().verify();
+
+        assertTrue( reportFile.exists() );
+
+        BufferedReader in = null;
+        try
+        {
+            in = new BufferedReader( new InputStreamReader( new FileInputStream( reportFile ) ) );
+            String content = in.readLine();
+            assertEquals( getLine(), content );
+            assertNull( in.readLine() );
+        }
+        finally
+        {
+            if ( in != null )
+            {
+                in.close();
+            }
+        }
+
+        reportFile.delete();
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/FileOutputConsumerProxyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/FileOutputConsumerProxyTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/ForkingStreamConsumerTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/ForkingStreamConsumerTest.java?rev=415349&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/ForkingStreamConsumerTest.java (added)
+++ maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/ForkingStreamConsumerTest.java Mon Jun 19 08:00:44 2006
@@ -0,0 +1,103 @@
+package org.apache.maven.surefire.booter.output;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.surefire.report.ForkingConsoleReporter;
+import org.apache.maven.surefire.report.ReportEntry;
+import org.jmock.Mock;
+import org.jmock.MockObjectTestCase;
+
+/**
+ * Test for {@link ForkingStreamConsumer}
+ * 
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class ForkingStreamConsumerTest
+    extends MockObjectTestCase
+{
+
+    private ForkingStreamConsumer streamConsumer;
+
+    private Mock outputConsumerMock;
+
+    private String message;
+
+    private ReportEntry reportEntry;
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        outputConsumerMock = new Mock( OutputConsumer.class );
+        streamConsumer = new ForkingStreamConsumer( (OutputConsumer) outputConsumerMock.proxy() );
+        message = "message";
+        reportEntry = new ReportEntry();
+        reportEntry.setGroup( "group" );
+        reportEntry.setName( "name" );
+    }
+
+    public void testConsumeHeaderLine()
+    {
+        String message = "message";
+        String line = ForkingConsoleReporter.FORKING_PREFIX_HEADING + message;
+        outputConsumerMock.expects( once() ).method( "consumeHeaderLine" ).with( eq( message ) );
+        streamConsumer.consumeLine( line );
+    }
+
+    public void testConsumeMessageLine()
+    {
+        String message = "message";
+        String line = ForkingConsoleReporter.FORKING_PREFIX_STANDARD + message;
+        outputConsumerMock.expects( once() ).method( "consumeMessageLine" ).with( eq( message ) );
+        streamConsumer.consumeLine( line );
+    }
+
+    public void testConsumeFooterLine()
+    {
+        String message = "message";
+        String line = ForkingConsoleReporter.FORKING_PREFIX_FOOTER + message;
+        outputConsumerMock.expects( once() ).method( "consumeFooterLine" ).with( eq( message ) );
+        streamConsumer.consumeLine( line );
+    }
+
+    public void testConsumeOutputLine()
+    {
+        String line = message;
+        outputConsumerMock.expects( once() ).method( "consumeOutputLine" ).with( eq( message ) );
+        streamConsumer.consumeLine( line );
+    }
+
+    public void testTestSetStarting()
+    {
+        message = ForkingConsoleReporter.getTestSetStartingMessage( reportEntry );
+        String line = ForkingConsoleReporter.FORKING_PREFIX_STANDARD + message;
+        outputConsumerMock.expects( once() ).method( "testSetStarting" ).with( eq( reportEntry ) );
+        outputConsumerMock.expects( once() ).method( "consumeMessageLine" ).with( eq( message ) );
+        streamConsumer.consumeLine( line );
+    }
+
+    public void testTestSetCompleted()
+    {
+        message = "Tests run: xxxx";
+        String line = ForkingConsoleReporter.FORKING_PREFIX_STANDARD + message;
+        outputConsumerMock.expects( once() ).method( "testSetCompleted" );
+        outputConsumerMock.expects( once() ).method( "consumeMessageLine" ).with( eq( message ) );
+        streamConsumer.consumeLine( line );
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/ForkingStreamConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/ForkingStreamConsumerTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/OutputConsumerProxyTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/OutputConsumerProxyTest.java?rev=415349&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/OutputConsumerProxyTest.java (added)
+++ maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/OutputConsumerProxyTest.java Mon Jun 19 08:00:44 2006
@@ -0,0 +1,114 @@
+package org.apache.maven.surefire.booter.output;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.jmock.Mock;
+import org.jmock.core.constraint.IsEqual;
+import org.jmock.core.matcher.InvokeOnceMatcher;
+
+/**
+ * Test for {@link OutputConsumerProxy}
+ * 
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class OutputConsumerProxyTest
+    extends AbstractOutputConsumerTest
+{
+    private Mock outputConsumerMock;
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        setOutputConsumerMock( new Mock( OutputConsumer.class ) );
+        setOutputConsumer( new OutputConsumerProxy( (OutputConsumer) getOutputConsumerMock().proxy() ) );
+    }
+
+    public void setOutputConsumerMock( Mock outputConsumerMock )
+    {
+        this.outputConsumerMock = outputConsumerMock;
+    }
+
+    public Mock getOutputConsumerMock()
+    {
+        return outputConsumerMock;
+    }
+
+    public void testConsumeFooterLine()
+    {
+        getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "testSetStarting" )
+            .with( new IsEqual( getReportEntry() ) );
+        getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "consumeFooterLine" )
+            .with( new IsEqual( getLine() ) );
+        getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "testSetCompleted" );
+        super.testConsumeFooterLine();
+        getOutputConsumerMock().verify();
+    }
+
+    public void testConsumeHeaderLine()
+    {
+        getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "testSetStarting" )
+            .with( new IsEqual( getReportEntry() ) );
+        getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "consumeHeaderLine" )
+            .with( new IsEqual( getLine() ) );
+        getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "testSetCompleted" );
+        super.testConsumeHeaderLine();
+        getOutputConsumerMock().verify();
+    }
+
+    public void testConsumeMessageLine()
+    {
+        getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "testSetStarting" )
+            .with( new IsEqual( getReportEntry() ) );
+        getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "consumeMessageLine" )
+            .with( new IsEqual( getLine() ) );
+        getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "testSetCompleted" );
+        super.testConsumeMessageLine();
+        getOutputConsumerMock().verify();
+    }
+
+    public void testConsumeOutputLine()
+        throws Exception
+    {
+        getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "testSetStarting" )
+            .with( new IsEqual( getReportEntry() ) );
+        getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "consumeOutputLine" )
+            .with( new IsEqual( getLine() ) );
+        getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "testSetCompleted" );
+        super.testConsumeOutputLine();
+        getOutputConsumerMock().verify();
+    }
+
+    public void testTestSetStarting()
+    {
+        getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "testSetStarting" )
+            .with( new IsEqual( getReportEntry() ) );
+        super.testTestSetStarting();
+        getOutputConsumerMock().verify();
+    }
+
+    public void testTestSetCompleted()
+    {
+        getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "testSetStarting" )
+            .with( new IsEqual( getReportEntry() ) );
+        getOutputConsumerMock().expects( new InvokeOnceMatcher() ).method( "testSetCompleted" );
+        super.testTestSetCompleted();
+        getOutputConsumerMock().verify();
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/OutputConsumerProxyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/OutputConsumerProxyTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/PrintWriterOutputConsumerTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/PrintWriterOutputConsumerTest.java?rev=415349&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/PrintWriterOutputConsumerTest.java (added)
+++ maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/PrintWriterOutputConsumerTest.java Mon Jun 19 08:00:44 2006
@@ -0,0 +1,78 @@
+package org.apache.maven.surefire.booter.output;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.StringWriter;
+
+/**
+ * Test for {@link PrintWriterOutputConsumer}
+ * 
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class PrintWriterOutputConsumerTest
+    extends AbstractOutputConsumerTest
+{
+    private StringWriter writer;
+
+    private static final String LINE_SEPARATOR = System.getProperty( "line.separator" );
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        writer = new StringWriter();
+        setOutputConsumer( new PrintWriterOutputConsumer( writer ) );
+    }
+
+    public void testConsumeFooterLine()
+    {
+        super.testConsumeFooterLine();
+        assertEquals( this.getLine() + LINE_SEPARATOR, writer.toString() );
+    }
+
+    public void testConsumeHeaderLine()
+    {
+        super.testConsumeHeaderLine();
+        assertEquals( getLine() + LINE_SEPARATOR, writer.toString() );
+    }
+
+    public void testConsumeMessageLine()
+    {
+        super.testConsumeMessageLine();
+        assertEquals( getLine() + LINE_SEPARATOR, writer.toString() );
+    }
+
+    public void testConsumeOutputLine() throws Exception
+    {
+        super.testConsumeOutputLine();
+        assertEquals( getLine() + LINE_SEPARATOR, writer.toString() );
+    }
+
+    public void testTestSetCompleted()
+    {
+        super.testTestSetCompleted();
+        assertEquals( "", writer.toString() );
+    }
+
+    public void testTestSetStarting()
+    {
+        super.testTestSetStarting();
+        assertEquals( "", writer.toString() );
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/PrintWriterOutputConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/PrintWriterOutputConsumerTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/StandardOutputConsumerTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/StandardOutputConsumerTest.java?rev=415349&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/StandardOutputConsumerTest.java (added)
+++ maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/StandardOutputConsumerTest.java Mon Jun 19 08:00:44 2006
@@ -0,0 +1,36 @@
+package org.apache.maven.surefire.booter.output;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * Test for {@link StandardOutputConsumer}
+ * 
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class StandardOutputConsumerTest
+    extends AbstractOutputConsumerTest
+{
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        setOutputConsumer( new StandardOutputConsumer() );
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/StandardOutputConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/StandardOutputConsumerTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/SupressFooterOutputConsumerProxyTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/SupressFooterOutputConsumerProxyTest.java?rev=415349&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/SupressFooterOutputConsumerProxyTest.java (added)
+++ maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/SupressFooterOutputConsumerProxyTest.java Mon Jun 19 08:00:44 2006
@@ -0,0 +1,42 @@
+package org.apache.maven.surefire.booter.output;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * Test for {@link SupressFooterOutputConsumerProxy}
+ * 
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class SupressFooterOutputConsumerProxyTest
+    extends OutputConsumerProxyTest
+{
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        setOutputConsumer( new SupressFooterOutputConsumerProxy( (OutputConsumer) getOutputConsumerMock().proxy() ) );
+    }
+
+    public void testConsumeFooterLine()
+    {
+        getOutputConsumer().consumeFooterLine( getLine() );
+        getOutputConsumerMock().verify();
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/SupressFooterOutputConsumerProxyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/SupressFooterOutputConsumerProxyTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/SupressHeaderOutputConsumerProxyTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/SupressHeaderOutputConsumerProxyTest.java?rev=415349&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/SupressHeaderOutputConsumerProxyTest.java (added)
+++ maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/SupressHeaderOutputConsumerProxyTest.java Mon Jun 19 08:00:44 2006
@@ -0,0 +1,42 @@
+package org.apache.maven.surefire.booter.output;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * Test for {@link SupressHeaderOutputConsumerProxy}
+ * 
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class SupressHeaderOutputConsumerProxyTest
+    extends OutputConsumerProxyTest
+{
+
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        setOutputConsumer( new SupressHeaderOutputConsumerProxy( (OutputConsumer) getOutputConsumerMock().proxy() ) );
+    }
+
+    public void testConsumeHeaderLine()
+    {
+        getOutputConsumer().consumeHeaderLine( getLine() );
+        getOutputConsumerMock().verify();
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/SupressHeaderOutputConsumerProxyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-booter/src/test/java/org/apache/maven/surefire/booter/output/SupressHeaderOutputConsumerProxyTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message