Repository: maven-surefire Updated Branches: refs/heads/master c26bc4b9e -> cc4dac274
[SUREFIRE-1137] Fix ConsoleOutputIT on systems with default charset encodings that do not contain German umlauts Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/cc4dac27 Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/cc4dac27 Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/cc4dac27 Branch: refs/heads/master Commit: cc4dac274a8d278450c44d72da39cf2a61c4d934 Parents: c26bc4b Author: Andreas Gudian <agud...@apache.org> Authored: Sat Feb 7 20:08:56 2015 +0100 Committer: Andreas Gudian <agud...@apache.org> Committed: Sat Feb 7 20:08:56 2015 +0100 ---------------------------------------------------------------------- .../maven/surefire/its/ConsoleOutputIT.java | 24 ++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/cc4dac27/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java ---------------------------------------------------------------------- diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java index 830341d..e01d798 100644 --- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java +++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ConsoleOutputIT.java @@ -65,13 +65,13 @@ public class ConsoleOutputIT { TestFile xmlReportFile = outputValidator.getSurefireReportsXmlFile( "TEST-consoleOutput.Test1.xml" ); xmlReportFile.assertContainsText( "SoutLine" ); - xmlReportFile.assertContainsText( "äöüÃ" ); - xmlReportFile.assertContainsText( "failing with ü" ); + xmlReportFile.assertContainsText( normalizeToDefaultCharset( "äöüÃ" ) ); + xmlReportFile.assertContainsText( normalizeToDefaultCharset( "failing with ü" ) ); TestFile outputFile = outputValidator.getSurefireReportsFile( "consoleOutput.Test1-output.txt" ); outputFile.assertContainsText( "SoutAgain" ); outputFile.assertContainsText( "SoutLine" ); - outputFile.assertContainsText( "äöüÃ" ); + outputFile.assertContainsText( normalizeToDefaultCharset( "äöüÃ" ) ); if ( includeShutdownHook ) { @@ -79,11 +79,27 @@ public class ConsoleOutputIT } } + /** + * @param string the string to normalize + * @return the string with all characters not available in the current charset being replaced, e.g. for US-ASCII, + * German umlauts would be replaced to ? + */ + private String normalizeToDefaultCharset( String string ) + { + Charset cs = Charset.defaultCharset(); + if ( cs.canEncode() ) + { + string = cs.decode( cs.encode( string ) ).toString(); + } + + return string; + } + @Test public void largerSoutThanMemory() throws Exception { - unpack( "consoleoutput-noisy" ).setMavenOpts( "-Xmx64m" ).sysProp( "thousand", "100000" ).executeTest(); + unpack( "consoleoutput-noisy" ).setMavenOpts( "-Xmx64m" ).sysProp( "thousand", "32000" ).executeTest(); }