You are viewing a plain text version of this content. The canonical link for it is here.
Posted to surefire-commits@maven.apache.org by kr...@apache.org on 2011/04/29 15:20:39 UTC

svn commit: r1097809 - in /maven/surefire/trunk: ./ surefire-api/src/main/java/org/apache/maven/surefire/booter/ surefire-api/src/main/java/org/apache/maven/surefire/report/ surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ surefi...

Author: krosenvold
Date: Fri Apr 29 13:20:38 2011
New Revision: 1097809

URL: http://svn.apache.org/viewvc?rev=1097809&view=rev
Log:
[SUREFIRE-733] All overrides captured

Fixed with IT

Added:
    maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire733AllOverrridesCapturedIT.java   (with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-733-allOverridesCaptured/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-733-allOverridesCaptured/pom.xml   (with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-733-allOverridesCaptured/src/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-733-allOverridesCaptured/src/test/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-733-allOverridesCaptured/src/test/java/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-733-allOverridesCaptured/src/test/java/junit/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-733-allOverridesCaptured/src/test/java/junit/surefire733/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-733-allOverridesCaptured/src/test/java/junit/surefire733/ATest.java   (with props)
Modified:
    maven/surefire/trunk/.gitignore
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
    maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputCapture.java

Modified: maven/surefire/trunk/.gitignore
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/.gitignore?rev=1097809&r1=1097808&r2=1097809&view=diff
==============================================================================
--- maven/surefire/trunk/.gitignore (original)
+++ maven/surefire/trunk/.gitignore Fri Apr 29 13:20:38 2011
@@ -8,3 +8,5 @@ build
 .classpath
 .project
 .settings
+.idea
+

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java?rev=1097809&r1=1097808&r2=1097809&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/booter/ForkingRunListener.java Fri Apr 29 13:20:38 2011
@@ -173,7 +173,7 @@ public class ForkingRunListener
     public void writeTestOutput( byte[] buf, int off, int len, boolean stdout )
     {
         byte[] header = stdout ? stdOutHeader : stdErrHeader;
-        byte[] content = new byte[buf.length * 2];
+        byte[] content = new byte[buf.length * 6 + 1]; // Unicode escapes can be up to 6 times length of regular char. Yuck.
         int i = StringUtils.escapeJavaStyleString( content, 0, buf, off, len );
         content[i++] = (byte) '\n';
 
@@ -217,7 +217,7 @@ public class ForkingRunListener
     public void writeMessage( String message )
     {
         byte[] buf = message.getBytes();
-        ByteBuffer byteBuffer = new ByteBuffer( buf.length * 2 );
+        ByteBuffer byteBuffer = new ByteBuffer( buf.length * 6);
         byteBuffer.append( BOOTERCODE_CONSOLE );
         byteBuffer.comma();
         byteBuffer.append( testSetChannelId );

Modified: maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputCapture.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputCapture.java?rev=1097809&r1=1097808&r2=1097809&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputCapture.java (original)
+++ maven/surefire/trunk/surefire-api/src/main/java/org/apache/maven/surefire/report/ConsoleOutputCapture.java Fri Apr 29 13:20:38 2011
@@ -19,10 +19,11 @@ package org.apache.maven.surefire.report
  * under the License.
  */
 
+import org.apache.maven.surefire.util.internal.ByteBuffer;
+
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.PrintStream;
-import org.apache.maven.surefire.util.internal.ByteBuffer;
 
 /**
  * Deals with system.out/err.
@@ -62,6 +63,20 @@ public class ConsoleOutputCapture
             target.writeTestOutput( b, 0, b.length, isStdout );
         }
 
+        public void write( int b )
+        {
+            byte[] buf = new byte[1];
+            buf[0] = (byte) b;
+            try
+            {
+                write( buf );
+            }
+            catch ( IOException e )
+            {
+                setError();
+            }
+        }
+
         static final byte[] newline = new byte[]{ (byte) '\n' };
 
         public void println( String s )

Added: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire733AllOverrridesCapturedIT.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire733AllOverrridesCapturedIT.java?rev=1097809&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire733AllOverrridesCapturedIT.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire733AllOverrridesCapturedIT.java Fri Apr 29 13:20:38 2011
@@ -0,0 +1,39 @@
+package org.apache.maven.surefire.its;
+/*
+ * 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 org.apache.maven.it.VerificationException;
+
+/**
+ * @author Kristian Rosenvold
+ */
+public class Surefire733AllOverrridesCapturedIT
+    extends SurefireVerifierTestClass
+{
+    public Surefire733AllOverrridesCapturedIT()
+    {
+        super( "/surefire-733-allOverridesCaptured" );
+    }
+
+    public void testLogOutput() throws VerificationException {
+        executeTest();
+        verifyTextInLog( "abc" );
+    }
+}

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire733AllOverrridesCapturedIT.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-733-allOverridesCaptured/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-733-allOverridesCaptured/pom.xml?rev=1097809&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-733-allOverridesCaptured/pom.xml (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-733-allOverridesCaptured/pom.xml Fri Apr 29 13:20:38 2011
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<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">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.plugins.surefire</groupId>
+  <artifactId>surefire-733-allOverridesCaptured</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <name>Ensures that all versions of system.out capture are handled</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>${surefire.version}</version>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-733-allOverridesCaptured/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-733-allOverridesCaptured/src/test/java/junit/surefire733/ATest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-733-allOverridesCaptured/src/test/java/junit/surefire733/ATest.java?rev=1097809&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-733-allOverridesCaptured/src/test/java/junit/surefire733/ATest.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-733-allOverridesCaptured/src/test/java/junit/surefire733/ATest.java Fri Apr 29 13:20:38 2011
@@ -0,0 +1,14 @@
+package junit.surefire733;
+import junit.framework.TestCase;
+
+
+public class ATest
+    extends TestCase
+{
+    public void testConsoleOut() {
+        System.out.write( (int) 'a');
+        final byte[] bytes = "bc".getBytes();
+        System.out.write(bytes, 0, bytes.length);
+        System.out.write('\n');
+    }
+}

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/surefire-733-allOverridesCaptured/src/test/java/junit/surefire733/ATest.java
------------------------------------------------------------------------------
    svn:eol-style = native