pmd: add changelog and test for #1144

This commit is contained in:
Andreas Dangel 2013-10-29 19:25:02 +01:00
parent 678d3e8a1b
commit 973fd1c4d4
2 changed files with 28 additions and 0 deletions

View File

@ -1,3 +1,8 @@
????? - 5.0.6:
Fixed bug 1144: CPD encoding argument has no effect
August 11, 2013 - 5.0.5:
Fixed bug 991: AvoidSynchronizedAtMethodLevel for static methods

View File

@ -44,6 +44,29 @@ public class CPDCommandLineInterfaceTest {
Assert.assertTrue(out.contains("Found a 7 line (34 tokens) duplication"));
}
/**
* #1144 CPD encoding argument has no effect
*/
@Test
public void testEncodingOption() throws Exception {
String origEncoding = System.getProperty("file.encoding");
// set the default encoding under Windows
System.setProperty("file.encoding", "Cp1252");
runCPD("--minimum-tokens", "34", "--language", "java",
"--files", "src/test/resources/net/sourceforge/pmd/cpd/clitest/",
"--ignore-identifiers",
"--format", "xml",
// request UTF-8 for CPD
"--encoding", "UTF-8");
// reset default encoding
System.setProperty("file.encoding", origEncoding);
String out = buffer.toString("UTF-8");
Assert.assertTrue(out.startsWith("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
}
private void runCPD(String... args) {
CPD.dontExitForTests = true;
CPD.main(args);