Adjust unit test to verify console encoding of XML formatter

This commit is contained in:
Andreas Dangel
2017-01-21 11:57:46 +01:00
parent 4c1890d56c
commit ba260e753c
2 changed files with 9 additions and 2 deletions

View File

@ -149,6 +149,7 @@ public class PMDTaskTest extends AbstractAntTestHelper {
executeTarget("testFormatterEncodingWithXMLConsole");
String report = getOutput();
assertTrue(report.contains("unusedVariableWithÜmlaut"));
assertTrue(report.startsWith("<?xml version=\"1.0\" encoding=\"windows-1252\"?>"));
assertTrue(report.contains("unusedVariableWith&#xdc;mlaut"));
}
}

View File

@ -131,7 +131,13 @@
<pmd encoding="cp1252">
<ruleset>java-unusedcode</ruleset>
<formatter type="xml" toConsole="true">
<param name="encoding" value="UTF-8" /> <!-- report encoding -->
<!-- specifying a encoding here will override the console encoding.
The output might have junk characters in it.
<param name="encoding" value="UTF-8" />
The test doesn't specify the report encoding, so that the console/default encoding is used
-->
</formatter>
<fileset dir="${pmd.home}/src/test/resources/ant/java">
<include name="EncodingTestClass.java" />