From 553cafff6eac3ae267afb1ea1511309abb1e65c0 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 2 Jul 2016 16:48:46 +0200 Subject: [PATCH] Fixes #1499 [core] CPD test break PMD 5.5.1 build on Windows --- .../src/main/java/net/sourceforge/pmd/cpd/XMLRenderer.java | 2 +- .../net/sourceforge/pmd/cpd/CPDCommandLineInterfaceTest.java | 5 +++-- src/site/markdown/overview/changelog.md | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/XMLRenderer.java b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/XMLRenderer.java index f426bdce2a..c82eb5f44b 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/cpd/XMLRenderer.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/cpd/XMLRenderer.java @@ -77,7 +77,7 @@ public final class XMLRenderer implements Renderer { transformer.setOutputProperty(OutputKeys.CDATA_SECTION_ELEMENTS, "codefragment"); StringWriter writer = new StringWriter(); transformer.transform(new DOMSource(doc), new StreamResult(writer)); - return writer.getBuffer().toString(); + return writer.toString(); } catch (TransformerException e) { throw new IllegalStateException(e); } diff --git a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDCommandLineInterfaceTest.java b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDCommandLineInterfaceTest.java index 513cf8c1ea..cf282a92da 100644 --- a/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDCommandLineInterfaceTest.java +++ b/pmd-core/src/test/java/net/sourceforge/pmd/cpd/CPDCommandLineInterfaceTest.java @@ -12,6 +12,8 @@ import org.junit.contrib.java.lang.system.RestoreSystemProperties; import org.junit.contrib.java.lang.system.StandardOutputStreamLog; import org.junit.rules.TestRule; +import net.sourceforge.pmd.PMD; + public class CPDCommandLineInterfaceTest { @Rule public final TestRule restoreSystemProperties = new RestoreSystemProperties(); @@ -27,7 +29,6 @@ public class CPDCommandLineInterfaceTest { "--files", "src/test/resources/net/sourceforge/pmd/cpd/files/", "--format", "xml" }); - Assert.assertEquals("\n\n", log.getLog()); + Assert.assertEquals("" + "\n" + "" + PMD.EOL, log.getLog()); } - } diff --git a/src/site/markdown/overview/changelog.md b/src/site/markdown/overview/changelog.md index f8068df3e9..946a0eac61 100644 --- a/src/site/markdown/overview/changelog.md +++ b/src/site/markdown/overview/changelog.md @@ -24,6 +24,7 @@ * [#1480](https://sourceforge.net/p/pmd/bugs/1480/): false positive on public modifier used with inner interface in enum * General * [#1481](https://sourceforge.net/p/pmd/bugs/1481/): no problems found results in blank file instead of empty xml + * [#1499](https://sourceforge.net/p/pmd/bugs/1499/): \[core] CPD test break PMD 5.5.1 build on Windows **API Changes:**