Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-1220

Surefire never outputs UTF-8 under Windows

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.19.1
    • Fix Version/s: None
    • Component/s: Maven Surefire Plugin
    • Labels:
      None
    • Environment:
      Windows 10, 64-bit
      DejaVu Sans font

      Description

      I'm having problems getting Surefire to output UTF-8 fonts under Windows.

      When I run a unit test that outputs a Guava Range ("10‥20") the TWO DOT LEADER unicode character always gets rendered as a question mark.

      If I run the exact same code outside of Surefire (using a main() entry point) the UTF-8 character renders just fine. The repro steps are quite simple:

      1. Create a Maven project.
      2. Run
        System.out.println(Range.closed(10, 30));

        in a Java class with a main() entry point, and from a JUnit test.

      3. The main() entry point will output UTF-8 just fine. The JUnit test will output a question mark in place of the unicode.

      Here is my pom.xml file:

      <?xml version="1.0" encoding="UTF-8"?>
      <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/xsd/maven-4.0.0.xsd">
          <modelVersion>4.0.0</modelVersion>
          <groupId>com.mycompany</groupId>
          <artifactId>mavenproject1</artifactId>
          <version>1.0-SNAPSHOT</version>
          <packaging>jar</packaging>
          <build>
              <plugins>
                  <plugin>
                      <groupId>org.apache.maven.plugins</groupId>
                      <artifactId>maven-surefire-plugin</artifactId>
                      <version>2.19.1</version>
                      <configuration>
                          <argLine>-Dfile.encoding=UTF-8</argLine>
                      </configuration>
                  </plugin>
                  <plugin>
                      <groupId>org.codehaus.mojo</groupId>
                      <artifactId>exec-maven-plugin</artifactId>
                      <version>1.4.0</version>
                      <executions>
                          <execution>
                              <goals>
                                  <goal>java</goal>
                              </goals>
                          </execution>
                      </executions>
                      <configuration>
                          <mainClass>foo.Main</mainClass>
                      </configuration>
                  </plugin>
              </plugins>
          </build>
          <dependencies>
              <dependency>
                  <groupId>com.google.guava</groupId>
                  <artifactId>guava</artifactId>
                  <version>19.0</version>
              </dependency>
              <dependency>
                  <groupId>junit</groupId>
                  <artifactId>junit</artifactId>
                  <version>4.12</version>
                  <scope>test</scope>
              </dependency>
          </dependencies>
          <properties>
              <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
              <maven.compiler.source>1.8</maven.compiler.source>
              <maven.compiler.target>1.8</maven.compiler.target>
          </properties>
      </project>
      

      I tried the same thing using TestNG tests and noticed that although output to console was still wrong, the outputted testng-results.xml file contained the correct character.

      Can you reproduce this on your end?

        Attachments

        1. 2016-01-29_113906.png
          4 kB
          Michael Osipov
        2. exec_exec.png
          13 kB
          Michael Osipov
        3. test.png
          8 kB
          Michael Osipov
        4. output.exec.txt
          22 kB
          Gili
        5. output.test.txt
          73 kB
          Gili
        6. surefire-1220.zip
          2 kB
          Michael Osipov

          Issue Links

            Activity

              People

              • Assignee:
                tibordigana Tibor Digana
                Reporter:
                cowwoc Gili
              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: