You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kr...@apache.org on 2011/11/14 16:13:38 UTC

svn commit: r1201745 - in /maven/surefire/trunk: surefire-api/src/main/java/org/apache/maven/surefire/report/ surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ surefire-integration-tests/src/test/resources/consoleOutput/ surefire-...

Author: krosenvold
Date: Mon Nov 14 15:13:37 2011
New Revision: 1201745

URL: http://svn.apache.org/viewvc?rev=1201745&view=rev
Log:
[SUREFIRE-785] Newlines in console output

Fixed with integration test, also cleaned up some integration test settings

Added:
    maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java
      - copied, changed from r1200541, maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.java
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/consoleOutput/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/consoleOutput/pom.xml
      - copied, changed from r1200541, maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/consoleOutput/src/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/consoleOutput/src/test/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/consoleOutput/src/test/java/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/consoleOutput/src/test/java/consoleOutput/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/consoleOutput/src/test/java/consoleOutput/Test1.java
      - copied, changed from r1200541, maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.java
Modified:
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputFileReporter.java
    maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.java
    maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SurefireVerifierTestClass.java
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/consoleoutput-noisy/pom.xml
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputFileReporter.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputFileReporter.java?rev=1201745&r1=1201744&r2=1201745&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputFileReporter.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputFileReporter.java Mon Nov 14 15:13:37 2011
@@ -40,16 +40,12 @@ import org.apache.maven.surefire.util.Ne
 public class ConsoleOutputFileReporter
     implements Reporter
 {
-    private static final String LINE_SEPARATOR = System.getProperty( "line.separator" );
-
     private final File reportsDirectory;
 
     private PrintWriter printWriter = null;
 
     private String reportEntryName;
 
-    private ReportEntry report;
-
     private final String reportNameSuffix;
 
     public ConsoleOutputFileReporter( File reportsDirectory )
@@ -93,8 +89,6 @@ public class ConsoleOutputFileReporter
                 printWriter = new PrintWriter( new BufferedWriter( new FileWriter( file ) ) );
             }
             printWriter.write( new String( b, off, len ) );
-            printWriter.write( LINE_SEPARATOR );
-
         }
         catch ( IOException e )
         {
@@ -127,7 +121,6 @@ public class ConsoleOutputFileReporter
     {
     }
 
-
     public void reset()
     {
     }

Copied: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java (from r1200541, maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java?p2=maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java&p1=maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.java&r1=1200541&r2=1201745&rev=1201745&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.java (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java Mon Nov 14 15:13:37 2011
@@ -22,28 +22,27 @@ package org.apache.maven.surefire.its;
 import java.io.File;
 
 /**
- * Asserts proper behaviour of console output when forking
- * SUREFIRE-639
- * SUREFIRE-651
+ * Basic suite test using all known versions of JUnit 4.x
  *
  * @author Kristian Rosenvold
  */
-public class ForkConsoleOutputWithErrorsIT
+public class ConsoleOutputIT
     extends SurefireVerifierTestClass
 {
 
-    public ForkConsoleOutputWithErrorsIT()
+    public ConsoleOutputIT()
     {
-        super( "/fork-consoleOutputWithErrors" );
+        super( "/consoleOutput" );
     }
 
-    public void testXmlFileContainsConsoleOutput()
+    public void testProperNewlines()
         throws Exception
     {
-        failNever();
-        execute( "test" );
-        final File surefireReportsFile = getSurefireReportsFile( "TEST-forkConsoleOutput.Test2.xml" );
-        assertContainsText(  surefireReportsFile, "sout: Will Fail soon" );
-        assertContainsText(  surefireReportsFile, "serr: Will Fail now" );
+        redirectToFile(true);
+        addGoal("-DjunitVersion=4.7");
+        executeTest();
+        final File surefireReportsFile = getSurefireReportsFile( "consoleOutput.Test1-output.txt" );
+        assertContainsText(  surefireReportsFile, "SoutAgain" );
+
     }
-}
+}
\ No newline at end of file

Modified: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.java?rev=1201745&r1=1201744&r2=1201745&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.java (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.java Mon Nov 14 15:13:37 2011
@@ -41,6 +41,7 @@ public class ForkConsoleOutputWithErrors
         throws Exception
     {
         failNever();
+        redirectToFile( true);
         execute( "test" );
         final File surefireReportsFile = getSurefireReportsFile( "TEST-forkConsoleOutput.Test2.xml" );
         assertContainsText(  surefireReportsFile, "sout: Will Fail soon" );

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=1201745&r1=1201744&r2=1201745&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 Mon Nov 14 15:13:37 2011
@@ -259,9 +259,14 @@ public abstract class SurefireVerifierTe
         addGoal( "-DprintSummary=" + printsummary );
     }
 
+    protected void redirectToFileReally(boolean redirect){
+        addGoal( "-Dmaven.test.redirectTestOutputToFile=" + redirect);
+    }
+
     protected void redirectToFile( boolean redirect )
     {
-        addGoal( "-Dredirect.to.file=" + redirect );
+        redirectToFileReally(redirect);
+        //addGoal( "-Dredirect.to.file=" + redirect );
     }
 
     protected void forkOnce()

Copied: maven/surefire/trunk/surefire-integration-tests/src/test/resources/consoleOutput/pom.xml (from r1200541, maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/consoleOutput/pom.xml?p2=maven/surefire/trunk/surefire-integration-tests/src/test/resources/consoleOutput/pom.xml&p1=maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml&r1=1200541&r2=1201745&rev=1201745&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/consoleOutput/pom.xml Mon Nov 14 15:13:37 2011
@@ -2,10 +2,10 @@
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.maven.plugins.surefire</groupId>
-  <artifactId>fork-consoleOutput</artifactId>
+  <artifactId>consoleOutputTest</artifactId>
   <packaging>jar</packaging>
   <version>1.0-SNAPSHOT</version>
-  <name>fork-consoleOutput</name>
+  <name>consoleOutputTest</name>
   <url>http://maven.apache.org</url>
 
   <dependencies>
@@ -34,7 +34,7 @@
              <printSummary>${printSummary}</printSummary>
              <useFile>true</useFile>
              <reportFormat>${reportFormat}</reportFormat>
-             <redirectTestOutputToFile>${redirect.to.file}</redirectTestOutputToFile>
+             <!-- redirectTestOutputToFile>${redirect.to.file}</redirectTestOutputToFile -->
              <includes>
                 <include>**/Test*.java</include>
              </includes>
@@ -46,7 +46,7 @@
 
     <properties>
       <junit.version>4.8.1</junit.version>
-      <redirect.to.file>true</redirect.to.file>
+      <!-- redirect.to.file>false</redirect.to.file -->
       <forkMode>once</forkMode>
       <printSummary>true</printSummary>
       <reportFormat>brief</reportFormat>

Copied: maven/surefire/trunk/surefire-integration-tests/src/test/resources/consoleOutput/src/test/java/consoleOutput/Test1.java (from r1200541, maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.java)
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/consoleOutput/src/test/java/consoleOutput/Test1.java?p2=maven/surefire/trunk/surefire-integration-tests/src/test/resources/consoleOutput/src/test/java/consoleOutput/Test1.java&p1=maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.java&r1=1200541&r2=1201745&rev=1201745&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkConsoleOutputWithErrorsIT.java (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/consoleOutput/src/test/java/consoleOutput/Test1.java Mon Nov 14 15:13:37 2011
@@ -1,4 +1,5 @@
-package org.apache.maven.surefire.its;
+package consoleOutput;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -18,32 +19,35 @@ package org.apache.maven.surefire.its;
  * under the License.
  */
 
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
-import java.io.File;
-
-/**
- * Asserts proper behaviour of console output when forking
- * SUREFIRE-639
- * SUREFIRE-651
- *
- * @author Kristian Rosenvold
- */
-public class ForkConsoleOutputWithErrorsIT
-    extends SurefireVerifierTestClass
+public class Test1
 {
-
-    public ForkConsoleOutputWithErrorsIT()
-    {
-        super( "/fork-consoleOutputWithErrors" );
+    @Test
+    public void testSystemOut() {
+        
+        char c = 'C';
+        System.out.print("Sout");
+        System.out.print("Again");
+        System.out.print("\n");
+        System.out.print(c);
+        System.out.println("SoutLine");
+        System.out.println("A");
+        System.out.println("");
+        System.out.println("==END==");
     }
-
-    public void testXmlFileContainsConsoleOutput()
-        throws Exception
-    {
-        failNever();
-        execute( "test" );
-        final File surefireReportsFile = getSurefireReportsFile( "TEST-forkConsoleOutput.Test2.xml" );
-        assertContainsText(  surefireReportsFile, "sout: Will Fail soon" );
-        assertContainsText(  surefireReportsFile, "serr: Will Fail now" );
+    @Test
+    public void testSystemErr() {
+        char e = 'E';
+        System.err.print("Serr");
+        System.err.print("\n");
+        System.err.print(e);
+        System.err.println("SerrLine");
+        System.err.println("A");
+        System.err.println("");
+        System.err.println("==END==");
     }
+
 }

Modified: maven/surefire/trunk/surefire-integration-tests/src/test/resources/consoleoutput-noisy/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/consoleoutput-noisy/pom.xml?rev=1201745&r1=1201744&r2=1201745&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/consoleoutput-noisy/pom.xml (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/consoleoutput-noisy/pom.xml Mon Nov 14 15:13:37 2011
@@ -2,7 +2,7 @@
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.apache.maven.plugins.surefire</groupId>
-  <artifactId>fork-consoleOutput</artifactId>
+  <artifactId>fork-consoleOutput-noisy</artifactId>
   <packaging>jar</packaging>
   <version>1.0-SNAPSHOT</version>
   <name>consoleOutput-noisy</name>

Modified: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml?rev=1201745&r1=1201744&r2=1201745&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml (original)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-consoleOutput/pom.xml Mon Nov 14 15:13:37 2011
@@ -34,7 +34,6 @@
              <printSummary>${printSummary}</printSummary>
              <useFile>true</useFile>
              <reportFormat>${reportFormat}</reportFormat>
-             <redirectTestOutputToFile>${redirect.to.file}</redirectTestOutputToFile>
              <includes>
                 <include>**/Test*.java</include>
              </includes>
@@ -46,7 +45,6 @@
 
     <properties>
       <junit.version>4.8.1</junit.version>
-      <redirect.to.file>true</redirect.to.file>
       <forkMode>once</forkMode>
       <printSummary>true</printSummary>
       <reportFormat>brief</reportFormat>