You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2018/03/08 09:04:22 UTC
maven-surefire git commit: [SUREFIRE-1495] Encoding of TXT report
file should be configured by ${project.reporting.outputEncoding} and MOJO
parameter encoding [Forced Update!]
Repository: maven-surefire
Updated Branches:
refs/heads/SUREFIRE-1495 ae497d580 -> dc2bc4555 (forced update)
[SUREFIRE-1495] Encoding of TXT report file should be configured by ${project.reporting.outputEncoding} and MOJO parameter encoding
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/dc2bc455
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/dc2bc455
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/dc2bc455
Branch: refs/heads/SUREFIRE-1495
Commit: dc2bc45552c7a0769fb178816dccb5926017c1f5
Parents: aee2bb4
Author: Tibor17 <ti...@apache.org>
Authored: Thu Mar 8 08:19:02 2018 +0100
Committer: Tibor17 <ti...@apache.org>
Committed: Thu Mar 8 10:03:47 2018 +0100
----------------------------------------------------------------------
.../plugin/failsafe/IntegrationTestMojo.java | 18 ++++++++--
.../plugin/surefire/AbstractSurefireMojo.java | 3 +-
.../maven/plugin/surefire/CommonReflector.java | 5 +--
.../surefire/StartupReportConfiguration.java | 38 ++++++--------------
.../surefire/SurefireExecutionParameters.java | 4 +++
.../report/ConsoleOutputFileReporter.java | 2 +-
.../surefire/report/DefaultReporterFactory.java | 11 ------
.../plugin/surefire/report/FileReporter.java | 14 +++++---
.../surefire/report/NullFileReporter.java | 2 +-
.../AbstractSurefireMojoJava7PlusTest.java | 12 +++++++
.../surefire/AbstractSurefireMojoTest.java | 12 +++++++
.../TestSetMockReporterFactory.java | 17 ++++++++-
.../report/DefaultReporterFactoryTest.java | 2 +-
.../maven/surefire/report/FileReporterTest.java | 4 +--
.../maven/plugin/surefire/SurefirePlugin.java | 21 +++++++++++
.../maven/surefire/its/UnicodeTestNamesIT.java | 2 +-
.../test/resources/unicode-testnames/pom.xml | 1 +
.../junitcore/ConcurrentRunListenerTest.java | 2 +-
.../surefire/junitcore/JUnitCoreTester.java | 27 ++++++++++++--
.../surefire/junitcore/Surefire746Test.java | 3 +-
20 files changed, 139 insertions(+), 61 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/dc2bc455/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
----------------------------------------------------------------------
diff --git a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
index 3474b16..781a9f8 100644
--- a/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
+++ b/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
@@ -256,10 +256,10 @@ public class IntegrationTestMojo
private boolean useManifestOnlyJar;
/**
- * The character encoding scheme to be applied.
- * Deprecated since 2.20.1 and used encoding UTF-8 in <tt>failsafe-summary.xml</tt>.
+ * The character encoding scheme to be applied while generating test report
+ * output files (see target/surefire-reports/yourTestName.txt).
*
- * @deprecated since of 2.20.1
+ * @since 3.0.0-M1
*/
@Parameter( property = "encoding", defaultValue = "${project.reporting.outputEncoding}" )
private String encoding;
@@ -703,6 +703,18 @@ public class IntegrationTestMojo
this.useManifestOnlyJar = useManifestOnlyJar;
}
+ @Override
+ public String getEncoding()
+ {
+ return encoding;
+ }
+
+ @Override
+ public void setEncoding( String encoding )
+ {
+ this.encoding = encoding;
+ }
+
// the following will be refactored out once the common code is all in one place
public boolean isTestFailureIgnore()
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/dc2bc455/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
index 38d18db..34f805a 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
@@ -1807,7 +1807,7 @@ public abstract class AbstractSurefireMojo
isRedirectTestOutputToFile(), isDisableXmlReport(),
getReportsDirectory(), isTrimStackTrace(), getReportNameSuffix(),
getStatisticsFile( configChecksum ), requiresRunHistory(),
- getRerunFailingTestsCount(), getReportSchemaLocation() );
+ getRerunFailingTestsCount(), getReportSchemaLocation(), getEncoding() );
}
private boolean isSpecificTestSpecified()
@@ -2337,6 +2337,7 @@ public abstract class AbstractSurefireMojo
checksum.add( isDisableXmlReport() );
checksum.add( isUseSystemClassLoader() );
checksum.add( isUseManifestOnlyJar() );
+ checksum.add( getEncoding() );
checksum.add( isEnableAssertions() );
checksum.add( getObjectFactory() );
checksum.add( getFailIfNoTests() );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/dc2bc455/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/CommonReflector.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/CommonReflector.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/CommonReflector.java
index 1918930..220f33c 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/CommonReflector.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/CommonReflector.java
@@ -72,14 +72,15 @@ public class CommonReflector
Constructor<?> constructor = getConstructor( startupReportConfiguration, boolean.class, boolean.class,
String.class, boolean.class, boolean.class, File.class,
boolean.class, String.class, File.class, boolean.class,
- int.class, String.class );
+ int.class, String.class, String.class );
//noinspection BooleanConstructorCall
Object[] params = { reporterConfiguration.isUseFile(), reporterConfiguration.isPrintSummary(),
reporterConfiguration.getReportFormat(), reporterConfiguration.isRedirectTestOutputToFile(),
reporterConfiguration.isDisableXmlReport(), reporterConfiguration.getReportsDirectory(),
reporterConfiguration.isTrimStackTrace(), reporterConfiguration.getReportNameSuffix(),
reporterConfiguration.getStatisticsFile(), reporterConfiguration.isRequiresRunHistory(),
- reporterConfiguration.getRerunFailingTestsCount(), reporterConfiguration.getXsdSchemaLocation() };
+ reporterConfiguration.getRerunFailingTestsCount(), reporterConfiguration.getXsdSchemaLocation(),
+ reporterConfiguration.getEncoding() };
return newInstance( constructor, params );
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/dc2bc455/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java
index 28e7ff0..5be1661 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java
@@ -80,6 +80,8 @@ public final class StartupReportConfiguration
private final Map<String, Map<String, List<WrappedReportEntry>>> testClassMethodRunHistory
= new ConcurrentHashMap<String, Map<String, List<WrappedReportEntry>>>();
+ private final String encoding;
+
private StatisticsReporter statisticsReporter;
@SuppressWarnings( "checkstyle:parameternumber" )
@@ -87,7 +89,7 @@ public final class StartupReportConfiguration
boolean redirectTestOutputToFile, boolean disableXmlReport,
@Nonnull File reportsDirectory, boolean trimStackTrace, String reportNameSuffix,
File statisticsFile, boolean requiresRunHistory,
- int rerunFailingTestsCount, String xsdSchemaLocation )
+ int rerunFailingTestsCount, String xsdSchemaLocation, String encoding )
{
this.useFile = useFile;
this.printSummary = printSummary;
@@ -103,32 +105,7 @@ public final class StartupReportConfiguration
this.originalSystemErr = System.err;
this.rerunFailingTestsCount = rerunFailingTestsCount;
this.xsdSchemaLocation = xsdSchemaLocation;
- }
-
- /**
- * For testing purposes only.
- *
- * @return StartupReportConfiguration fo testing purposes
- */
- public static StartupReportConfiguration defaultValue()
- {
- File target = new File( "./target" );
- File statisticsFile = new File( target, "TESTHASH" );
- return new StartupReportConfiguration( true, true, "PLAIN", false, false, target, false, null, statisticsFile,
- false, 0, null );
- }
-
- /**
- * For testing purposes only.
- *
- * @return StartupReportConfiguration fo testing purposes
- */
- public static StartupReportConfiguration defaultNoXml()
- {
- File target = new File( "./target" );
- File statisticsFile = new File( target, "TESTHASHxXML" );
- return new StartupReportConfiguration( true, true, "PLAIN", false, true, target, false, null, statisticsFile,
- false, 0, null );
+ this.encoding = encoding;
}
public boolean isUseFile()
@@ -182,7 +159,7 @@ public final class StartupReportConfiguration
public FileReporter instantiateFileReporter()
{
return isUseFile() && isBriefOrPlainFormat()
- ? new FileReporter( reportsDirectory, getReportNameSuffix() )
+ ? new FileReporter( reportsDirectory, getReportNameSuffix(), encoding )
: null;
}
@@ -232,4 +209,9 @@ public final class StartupReportConfiguration
{
return xsdSchemaLocation;
}
+
+ public String getEncoding()
+ {
+ return encoding;
+ }
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/dc2bc455/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
index 240427f..4425ddc 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireExecutionParameters.java
@@ -118,6 +118,10 @@ public interface SurefireExecutionParameters
void setUseManifestOnlyJar( boolean useManifestOnlyJar );
+ String getEncoding();
+
+ void setEncoding( String encoding );
+
Boolean getFailIfNoSpecifiedTests();
void setFailIfNoSpecifiedTests( boolean failIfNoSpecifiedTests );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/dc2bc455/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
index 84cbabe..8bbd9ec 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/ConsoleOutputFileReporter.java
@@ -107,7 +107,7 @@ public class ConsoleOutputFileReporter
reportsDirectory.mkdirs();
}
File file = getReportFile( reportsDirectory, reportEntryName, reportNameSuffix, "-output.txt" );
- fileOutputStream = new BufferedOutputStream( new FileOutputStream( file ), 16 * 1024 );
+ fileOutputStream = new BufferedOutputStream( new FileOutputStream( file ), 16 * 1024 ); //todo encoding
}
fileOutputStream.write( buf, off, len );
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/dc2bc455/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java
index bbc9591..8812156 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactory.java
@@ -22,7 +22,6 @@ package org.apache.maven.plugin.surefire.report;
import org.apache.maven.plugin.surefire.StartupReportConfiguration;
import org.apache.maven.plugin.surefire.log.api.ConsoleLogger;
import org.apache.maven.plugin.surefire.log.api.Level;
-import org.apache.maven.plugin.surefire.log.api.NullConsoleLogger;
import org.apache.maven.plugin.surefire.runorder.StatisticsReporter;
import org.apache.maven.shared.utils.logging.MessageBuilder;
import org.apache.maven.surefire.report.ReporterFactory;
@@ -208,16 +207,6 @@ public class DefaultReporterFactory
}
/**
- * For testing purposes only.
- *
- * @return DefaultReporterFactory for testing purposes
- */
- public static DefaultReporterFactory defaultNoXml()
- {
- return new DefaultReporterFactory( StartupReportConfiguration.defaultNoXml(), new NullConsoleLogger() );
- }
-
- /**
* Get the result of a test based on all its runs. If it has success and failures/errors, then it is a flake;
* if it only has errors or failures, then count its result based on its first run
*
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/dc2bc455/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java
index 15b902d..513fb78 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporter.java
@@ -24,9 +24,12 @@ import org.apache.maven.surefire.report.ReporterException;
import java.io.BufferedWriter;
import java.io.File;
-import java.io.FileWriter;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.OutputStreamWriter;
import java.io.PrintWriter;
+import java.io.Writer;
+import java.nio.charset.Charset;
import java.util.List;
import static org.apache.maven.plugin.surefire.report.FileReporterUtils.stripIllegalFilenameChars;
@@ -41,13 +44,14 @@ import static org.apache.maven.surefire.util.internal.StringUtils.isNotBlank;
public class FileReporter
{
private final File reportsDirectory;
-
private final String reportNameSuffix;
+ private final Charset encoding;
- public FileReporter( File reportsDirectory, String reportNameSuffix )
+ public FileReporter( File reportsDirectory, String reportNameSuffix, String encoding )
{
this.reportsDirectory = reportsDirectory;
this.reportNameSuffix = reportNameSuffix;
+ this.encoding = encoding == null ? Charset.defaultCharset() : Charset.forName( encoding );
}
private PrintWriter testSetStarting( ReportEntry report )
@@ -61,7 +65,9 @@ public class FileReporter
try
{
- PrintWriter writer = new PrintWriter( new BufferedWriter( new FileWriter( reportFile ), 16 * 1024 ) );
+ Writer encodedStream = new OutputStreamWriter( new FileOutputStream( reportFile ), encoding );
+
+ PrintWriter writer = new PrintWriter( new BufferedWriter( encodedStream, 16 * 1024 ) );
writer.println( "-------------------------------------------------------------------------------" );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/dc2bc455/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullFileReporter.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullFileReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullFileReporter.java
index bca3c4c..df1bf9d 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullFileReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullFileReporter.java
@@ -35,7 +35,7 @@ class NullFileReporter
private NullFileReporter()
{
- super( null, null );
+ super( null, null, null );
}
@Override
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/dc2bc455/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java
index e34d7d1..8310fe3 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java
@@ -473,6 +473,18 @@ public class AbstractSurefireMojoJava7PlusTest
}
@Override
+ public String getEncoding()
+ {
+ return null;
+ }
+
+ @Override
+ public void setEncoding( String encoding )
+ {
+
+ }
+
+ @Override
public Boolean getFailIfNoSpecifiedTests()
{
return null;
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/dc2bc455/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java
index a5ef345..481d91e 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java
@@ -494,6 +494,18 @@ public class AbstractSurefireMojoTest
}
@Override
+ public String getEncoding()
+ {
+ return null;
+ }
+
+ @Override
+ public void setEncoding( String encoding )
+ {
+
+ }
+
+ @Override
public Boolean getFailIfNoSpecifiedTests()
{
return null;
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/dc2bc455/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/TestSetMockReporterFactory.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/TestSetMockReporterFactory.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/TestSetMockReporterFactory.java
index 5e4f682..b0acaa3 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/TestSetMockReporterFactory.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/TestSetMockReporterFactory.java
@@ -19,11 +19,12 @@ package org.apache.maven.plugin.surefire.booterclient;
* under the License.
*/
+import org.apache.maven.plugin.surefire.StartupReportConfiguration;
import org.apache.maven.plugin.surefire.report.DefaultReporterFactory;
import org.apache.maven.plugin.surefire.log.api.NullConsoleLogger;
import org.apache.maven.surefire.report.RunListener;
-import static org.apache.maven.plugin.surefire.StartupReportConfiguration.defaultValue;
+import java.io.File;
/**
* Internal tests use only.
@@ -43,4 +44,18 @@ public class TestSetMockReporterFactory
{
return new MockReporter();
}
+
+
+ /**
+ * For testing purposes only.
+ *
+ * @return StartupReportConfiguration fo testing purposes
+ */
+ private static StartupReportConfiguration defaultValue()
+ {
+ File target = new File( "./target" );
+ File statisticsFile = new File( target, "TESTHASH" );
+ return new StartupReportConfiguration( true, true, "PLAIN", false, false, target, false, null, statisticsFile,
+ false, 0, null, null );
+ }
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/dc2bc455/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactoryTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactoryTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactoryTest.java
index 659040d..87d6800 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactoryTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactoryTest.java
@@ -66,7 +66,7 @@ public class DefaultReporterFactoryTest
File reportsDirectory = new File("target");
StartupReportConfiguration reportConfig =
new StartupReportConfiguration( true, true, "PLAIN", false, false, reportsDirectory, false, null,
- new File( reportsDirectory, "TESTHASH" ), false, 1, null );
+ new File( reportsDirectory, "TESTHASH" ), false, 1, null, null );
DummyTestReporter reporter = new DummyTestReporter();
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/dc2bc455/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java b/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java
index 7c49547..d6e3033 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/surefire/report/FileReporterTest.java
@@ -44,7 +44,7 @@ public class FileReporterTest
reportEntry = new SimpleReportEntry( this.getClass().getName(), testName );
WrappedReportEntry wrappedReportEntry =
new WrappedReportEntry( reportEntry, ReportEntryType.SUCCESS, 12, null, null );
- reporter = new FileReporter( reportDir, null );
+ reporter = new FileReporter( reportDir, null, null );
reporter.testSetCompleted( wrappedReportEntry, createTestSetStats(), new ArrayList<String>() );
File expectedReportFile = new File( reportDir, testName + ".txt" );
@@ -65,7 +65,7 @@ public class FileReporterTest
reportEntry = new SimpleReportEntry( this.getClass().getName(), testName );
WrappedReportEntry wrappedReportEntry =
new WrappedReportEntry( reportEntry, ReportEntryType.SUCCESS, 12, null, null );
- reporter = new FileReporter( reportDir, suffixText );
+ reporter = new FileReporter( reportDir, suffixText, null );
reporter.testSetCompleted( wrappedReportEntry, createTestSetStats(), new ArrayList<String>() );
File expectedReportFile = new File( reportDir, testName + "-" + suffixText + ".txt" );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/dc2bc455/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
----------------------------------------------------------------------
diff --git a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
index 6873ad0..5f3dc09 100644
--- a/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
+++ b/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
@@ -237,6 +237,15 @@ public class SurefirePlugin
private boolean useManifestOnlyJar;
/**
+ * The character encoding scheme to be applied while generating test report
+ * output files (see target/surefire-reports/yourTestName.txt).
+ *
+ * @since 3.0.0-M1
+ */
+ @Parameter( property = "surefire.encoding", defaultValue = "${project.reporting.outputEncoding}" )
+ private String encoding;
+
+ /**
* (JUnit 4+ providers)
* The number of times each failing test will be rerun. If set larger than 0, rerun failing tests immediately after
* they fail. If a failing test passes in any of those reruns, it will be marked as pass and reported as a "flake".
@@ -514,6 +523,18 @@ public class SurefirePlugin
}
@Override
+ public String getEncoding()
+ {
+ return encoding;
+ }
+
+ @Override
+ public void setEncoding( String encoding )
+ {
+ this.encoding = encoding;
+ }
+
+ @Override
public Boolean getFailIfNoSpecifiedTests()
{
return failIfNoSpecifiedTests;
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/dc2bc455/surefire-its/src/test/java/org/apache/maven/surefire/its/UnicodeTestNamesIT.java
----------------------------------------------------------------------
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/UnicodeTestNamesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/UnicodeTestNamesIT.java
index 64db960..69c78f3 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/UnicodeTestNamesIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/UnicodeTestNamesIT.java
@@ -64,7 +64,7 @@ public class UnicodeTestNamesIT
TestFile surefireReportFile = outputValidator.getSurefireReportsFile( TXT_REPORT );
assertTrue( surefireReportFile.exists() );
- surefireReportFile.assertContainsText( "junit.twoTestCases.????Test" );
+ surefireReportFile.assertContainsText( "junit.twoTestCases.\u800C\u7D22\u5176\u60C5Test" );
TestFile surefireXmlReportFile = outputValidator.getSurefireReportsXmlFile( XML_REPORT );
assertTrue( surefireXmlReportFile.exists() );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/dc2bc455/surefire-its/src/test/resources/unicode-testnames/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-its/src/test/resources/unicode-testnames/pom.xml b/surefire-its/src/test/resources/unicode-testnames/pom.xml
index eb52b53..cd0a7b8 100644
--- a/surefire-its/src/test/resources/unicode-testnames/pom.xml
+++ b/surefire-its/src/test/resources/unicode-testnames/pom.xml
@@ -30,6 +30,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/dc2bc455/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentRunListenerTest.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentRunListenerTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentRunListenerTest.java
index dc504b6..de18f55 100644
--- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentRunListenerTest.java
+++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/ConcurrentRunListenerTest.java
@@ -382,7 +382,7 @@ public class ConcurrentRunListenerTest
private DefaultReporterFactory createReporterFactory()
{
- return DefaultReporterFactory.defaultNoXml();
+ return JUnitCoreTester.defaultNoXml();
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/dc2bc455/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreTester.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreTester.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreTester.java
index 41ae610..17a2197 100644
--- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreTester.java
+++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreTester.java
@@ -19,6 +19,8 @@ package org.apache.maven.surefire.junitcore;
* under the License.
*/
+import org.apache.maven.plugin.surefire.StartupReportConfiguration;
+import org.apache.maven.plugin.surefire.log.api.NullConsoleLogger;
import org.apache.maven.plugin.surefire.report.DefaultReporterFactory;
import org.apache.maven.surefire.report.ConsoleOutputReceiver;
import org.apache.maven.surefire.report.DefaultDirectConsoleReporter;
@@ -29,6 +31,7 @@ import org.junit.runner.Computer;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
+import java.io.File;
import java.util.HashMap;
import java.util.concurrent.ExecutionException;
@@ -40,7 +43,6 @@ import static org.apache.maven.surefire.report.ConsoleOutputCapture.startCapture
*/
public class JUnitCoreTester
{
-
private final Computer computer;
public JUnitCoreTester()
@@ -56,7 +58,7 @@ public class JUnitCoreTester
public Result run( boolean parallelClasses, Class<?>... classes )
throws TestSetFailedException, ExecutionException
{
- ReporterFactory reporterManagerFactory = DefaultReporterFactory.defaultNoXml();
+ ReporterFactory reporterManagerFactory = defaultNoXml();
try
{
@@ -83,5 +85,26 @@ public class JUnitCoreTester
}
}
+ /**
+ * For testing purposes only.
+ *
+ * @return DefaultReporterFactory for testing purposes
+ */
+ public static DefaultReporterFactory defaultNoXml()
+ {
+ return new DefaultReporterFactory( defaultStartupReportConfiguration(), new NullConsoleLogger() );
+ }
+ /**
+ * For testing purposes only.
+ *
+ * @return StartupReportConfiguration fo testing purposes
+ */
+ private static StartupReportConfiguration defaultStartupReportConfiguration()
+ {
+ File target = new File( "./target" );
+ File statisticsFile = new File( target, "TESTHASHxXML" );
+ return new StartupReportConfiguration( true, true, "PLAIN", false, true, target, false, null, statisticsFile,
+ false, 0, null, null );
+ }
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/dc2bc455/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java
----------------------------------------------------------------------
diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java
index eb5534e..6fba6ab 100644
--- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java
+++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/Surefire746Test.java
@@ -21,7 +21,6 @@ import java.io.File;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
-import org.apache.maven.plugin.surefire.report.DefaultReporterFactory;
import org.apache.maven.surefire.booter.BaseProviderFactory;
import org.apache.maven.surefire.booter.ProviderParameterNames;
import org.apache.maven.surefire.common.junit4.JUnit4RunListener;
@@ -87,7 +86,7 @@ public class Surefire746Test
public void surefireIsConfused_ByMultipleIgnore_OnClassLevel()
throws Exception
{
- ReporterFactory reporterFactory = DefaultReporterFactory.defaultNoXml();
+ ReporterFactory reporterFactory = JUnitCoreTester.defaultNoXml();
BaseProviderFactory providerParameters = new BaseProviderFactory( reporterFactory, true );
providerParameters.setReporterConfiguration( new ReporterConfiguration( new File( "" ), false ) );