Author: krosenvold
Date: Sun May 8 20:37:27 2011
New Revision: 1100808
URL: http://svn.apache.org/viewvc?rev=1100808&view=rev
Log:
o Simplified reporter that captures console -output.txt files
Removed source of testSetStarting/testSetFinished problems since algorithim
simplification made whole
logic redundant.
Added IT for checking new reporter logic
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit47-redirect-output/src/test/java/junit47ConsoleOutput/Test3.java
(with props)
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/JUnit47RedirectOutputIT.java
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=1100808&r1=1100807&r2=1100808&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
Sun May 8 20:37:27 2011
@@ -46,7 +46,6 @@ public class ConsoleOutputFileReporter
private final StringBuffer outputBuffer = new StringBuffer();
- private volatile PrintWriter printWriter;
public ConsoleOutputFileReporter( File reportsDirectory )
{
@@ -55,10 +54,12 @@ public class ConsoleOutputFileReporter
public void testSetStarting( ReportEntry reportEntry )
{
- if ( printWriter != null )
- {
- throw new IllegalStateException( "testSetStarting called twice" );
- }
+ }
+
+ public void testSetCompleted( ReportEntry report )
+ throws ReporterException
+ {
+ PrintWriter printWriter;
if ( !reportsDirectory.exists() )
{
@@ -66,10 +67,17 @@ public class ConsoleOutputFileReporter
reportsDirectory.mkdirs();
}
- File file = new File( reportsDirectory, reportEntry.getName() +
"-output.txt" );
try
{
- this.printWriter = new PrintWriter( new BufferedWriter( new
FileWriter( file ) ) );
+ if ( outputBuffer.length() > 0 )
+ {
+ File file = new File( reportsDirectory, report.getName() +
"-output.txt" );
+ printWriter = new PrintWriter( new BufferedWriter( new
FileWriter( file ) ) );
+ printWriter.write( outputBuffer.toString() );
+ printWriter.write( LINE_SEPARATOR );
+ outputBuffer.setLength( 0 );
+ printWriter.close();
+ }
}
catch ( IOException e )
{
@@ -77,23 +85,6 @@ public class ConsoleOutputFileReporter
}
}
- public void testSetCompleted( ReportEntry report )
- throws ReporterException
- {
- if ( printWriter == null )
- {
- throw new IllegalStateException( "testSetCompleted called before
testSetStarting" );
- }
- if ( outputBuffer.length() > 0 )
- {
- printWriter.write( outputBuffer.toString() );
- printWriter.write( LINE_SEPARATOR );
- outputBuffer.setLength( 0 );
- }
- printWriter.close();
- this.printWriter = null;
- }
-
public void testStarting( ReportEntry report )
{
}
@@ -121,18 +112,7 @@ public class ConsoleOutputFileReporter
public void writeMessage( byte[] b, int off, int len )
{
String line = new String( b, off, len );
- if ( printWriter == null )
- {
- outputBuffer.append( line );
- return;
- }
-
- if ( outputBuffer.length() > 0 )
- {
- printWriter.write( outputBuffer.toString() );
- outputBuffer.setLength( 0 );
- }
- printWriter.write( line );
+ outputBuffer.append( line );
}
public void reset()
Modified:
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit47RedirectOutputIT.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit47RedirectOutputIT.java?rev=1100808&r1=1100807&r2=1100808&view=diff
==============================================================================
---
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit47RedirectOutputIT.java
(original)
+++
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/JUnit47RedirectOutputIT.java
Sun May 8 20:37:27 2011
@@ -63,6 +63,7 @@ public class JUnit47RedirectOutputIT
String report2 = StringUtils.trimToNull( FileUtils.readFileToString(
getSurefireReportsFile( "junit47ConsoleOutput.Test2-output.txt" )
) );
assertNotNull(report2);
+ assertFalse(
getSurefireReportsFile("junit47ConsoleOutput.Test3-output.txt").exists());
}
}
Added:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit47-redirect-output/src/test/java/junit47ConsoleOutput/Test3.java
URL:
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit47-redirect-output/src/test/java/junit47ConsoleOutput/Test3.java?rev=1100808&view=auto
==============================================================================
---
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit47-redirect-output/src/test/java/junit47ConsoleOutput/Test3.java
(added)
+++
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit47-redirect-output/src/test/java/junit47ConsoleOutput/Test3.java
Sun May 8 20:37:27 2011
@@ -0,0 +1,30 @@
+package junit47ConsoleOutput;
+
+/*
+ * 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.junit.Test;
+
+public class Test3
+{
+ @Test
+ public void test3() {
+ }
+
+}
Propchange:
maven/surefire/trunk/surefire-integration-tests/src/test/resources/junit47-redirect-output/src/test/java/junit47ConsoleOutput/Test3.java
------------------------------------------------------------------------------
svn:eol-style = native