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 2013/03/22 11:37:25 UTC
git commit: [SUREFIRE-975] System default encoding in xml output file
Updated Branches:
refs/heads/master 81e39803d -> 9c4bba6f4
[SUREFIRE-975] System default encoding in xml output file
Fixed with IT
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/9c4bba6f
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/9c4bba6f
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/9c4bba6f
Branch: refs/heads/master
Commit: 9c4bba6f49828c97653c2a1e7ad008bc01cc4954
Parents: 81e3980
Author: Kristian Rosenvold <kr...@apache.org>
Authored: Fri Mar 22 11:32:33 2013 +0100
Committer: Kristian Rosenvold <kr...@apache.org>
Committed: Fri Mar 22 11:36:26 2013 +0100
----------------------------------------------------------------------
.../surefire/report/StatelessXmlReporter.java | 16 ++++--
.../surefire/its/fixture/SurefireLauncher.java | 5 ++
.../its/jiras/Surefire740TruncatedCommaIT.java | 2 +-
.../its/jiras/Surefire975DefaultVMEncodingIT.java | 41 +++++++++++++++
.../resources/surefire-975-wrong-encoding/pom.xml | 32 +++++++++++
.../src/test/java/EncodingInReportTest.java | 14 +++++
6 files changed, 104 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/9c4bba6f/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
index 7690d0a..d72a08e 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
@@ -20,8 +20,9 @@ package org.apache.maven.plugin.surefire.report;
*/
import java.io.File;
-import java.io.FileWriter;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.OutputStreamWriter;
import java.util.Enumeration;
import java.util.Properties;
import java.util.StringTokenizer;
@@ -72,6 +73,8 @@ public class StatelessXmlReporter
private final boolean trimStackTrace;
+ private final String encoding = "UTF-8";
+
public StatelessXmlReporter( File reportsDirectory, String reportNameSuffix, boolean trimStackTrace )
{
this.reportsDirectory = reportsDirectory;
@@ -83,13 +86,13 @@ public class StatelessXmlReporter
throws ReporterException
{
- FileWriter fw = getFileWriter( testSetReportEntry );
+ OutputStreamWriter fw = getWriter( testSetReportEntry );
try
{
org.apache.maven.shared.utils.xml.XMLWriter ppw =
new org.apache.maven.shared.utils.xml.PrettyPrintXMLWriter( fw );
- ppw.setEncoding( "UTF-8" );
+ ppw.setEncoding( encoding );
createTestSuiteElement( ppw, testSetReportEntry, testSetStats, reportNameSuffix );
@@ -117,7 +120,7 @@ public class StatelessXmlReporter
}
}
- private FileWriter getFileWriter( WrappedReportEntry testSetReportEntry )
+ private OutputStreamWriter getWriter( WrappedReportEntry testSetReportEntry )
{
File reportFile = getReportFile( testSetReportEntry, reportsDirectory, reportNameSuffix );
@@ -128,7 +131,10 @@ public class StatelessXmlReporter
try
{
- return new FileWriter( reportFile );
+
+ FileOutputStream fos = new FileOutputStream( reportFile );
+
+ return new OutputStreamWriter( fos, encoding );
}
catch ( IOException e )
{
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/9c4bba6f/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
index 201738f..5b0ecdd 100755
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java
@@ -89,6 +89,11 @@ public class SurefireLauncher
return this;
}
+ public SurefireLauncher setMavenOpts(String opts){
+ addEnvVar( "MAVEN_OPTS", opts );
+ return this;
+ }
+
private List<String> getInitialGoals( String testNgVersion )
{
List<String> goals1 = new ArrayList<String>();
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/9c4bba6f/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire740TruncatedCommaIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire740TruncatedCommaIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire740TruncatedCommaIT.java
index bef5432..e05cee7 100644
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire740TruncatedCommaIT.java
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire740TruncatedCommaIT.java
@@ -37,7 +37,7 @@ public class Surefire740TruncatedCommaIT
@Test
public void testRussianLocaleReport()
{
- OutputValidator validator = unpack( "/surefire-740-comma-truncated" ).addEnvVar( "MAVEN_OPTS",
+ OutputValidator validator = unpack( "/surefire-740-comma-truncated" ).setMavenOpts(
"-Duser.language=ru -Duser.country=RU" ).failNever().addSurefireReportGoal().executeCurrentGoals();
TestFile siteFile = validator.getSiteFile( "surefire-report.html" );
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/9c4bba6f/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire975DefaultVMEncodingIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire975DefaultVMEncodingIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire975DefaultVMEncodingIT.java
new file mode 100644
index 0000000..9469126
--- /dev/null
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire975DefaultVMEncodingIT.java
@@ -0,0 +1,41 @@
+package org.apache.maven.surefire.its.jiras;
+
+/*
+ * 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.surefire.its.fixture.OutputValidator;
+import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class Surefire975DefaultVMEncodingIT
+ extends SurefireJUnit4IntegrationTestCase
+{
+
+ @Test
+ public void runWithRussian1251()
+ throws Exception
+ {
+ OutputValidator outputValidator =
+ unpack( "surefire-975-wrong-encoding" ).setMavenOpts( "-Dfile.encoding=windows-1251" ).executeTest();
+ outputValidator.getSurefireReportsFile( "TEST-EncodingInReportTest.xml" ).assertContainsText(
+ "\u043A\u0438\u0440\u0438\u043B\u043B\u0438\u0446\u0435" );
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/9c4bba6f/surefire-integration-tests/src/test/resources/surefire-975-wrong-encoding/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-975-wrong-encoding/pom.xml b/surefire-integration-tests/src/test/resources/surefire-975-wrong-encoding/pom.xml
new file mode 100755
index 0000000..d768749
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-975-wrong-encoding/pom.xml
@@ -0,0 +1,32 @@
+<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>
+
+ <artifactId>encoding-bug</artifactId>
+ <groupId>ru.fors.encoding</groupId>
+ <version>1.0-SNAPSHOT</version>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</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>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/9c4bba6f/surefire-integration-tests/src/test/resources/surefire-975-wrong-encoding/src/test/java/EncodingInReportTest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/surefire-975-wrong-encoding/src/test/java/EncodingInReportTest.java b/surefire-integration-tests/src/test/resources/surefire-975-wrong-encoding/src/test/java/EncodingInReportTest.java
new file mode 100755
index 0000000..81b6cac
--- /dev/null
+++ b/surefire-integration-tests/src/test/resources/surefire-975-wrong-encoding/src/test/java/EncodingInReportTest.java
@@ -0,0 +1,14 @@
+import org.junit.Test;
+
+public class EncodingInReportTest {
+
+ @Test
+ public void test1() {
+
+ }
+
+ @Test
+ public void кириллице() {
+
+ }
+}
\ No newline at end of file