Menu

#202 test suite failes with java9: Transformer changed behaviour

v2.22
closed-fixed
nobody
None
5
2018-04-24
2018-04-24
niol
No

(forwarded from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=895899 )

Hi,

htmlcleaner's test suite fails with java9. The workaround is straightforward and pasted below altough I'm not sure if whitespace is important for htmlcleaner's output.

javax.xml.transform.Transformer changed behaviour with java9 in a way that makes its output indented with 4 spaces. This is not what the test suite expects. This patchs works around this problem.

--- a/src/test/java/org/htmlcleaner/AbstractHtmlCleanerTest.java
+++ b/src/test/java/org/htmlcleaner/AbstractHtmlCleanerTest.java
@@ -99,7 +99,7 @@ public abstract class AbstractHtmlCleanerTest {
Transformer transformer = tf.newTransformer();
transformer.transform(new DOMSource(document), new StreamResult(writer));
String actual = writer.getBuffer().toString();
- actual = actual.substring(actual.indexOf("\n")+7, actual.indexOf("\n"));
+ actual = actual.substring(actual.indexOf("\n")+7, actual.indexOf("")).trim();
assertEquals(expected, actual);
cleaner.getProperties().setOmitHtmlEnvelope(true);
}

Discussion

  • Scott Wilson

    Scott Wilson - 2018-04-24

    Thanks niol! I've commited this change to trunk so it'll be in the next release. (The change doesn't affect the actual output, just unit testing.)

     
  • Scott Wilson

    Scott Wilson - 2018-04-24
    • status: open --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB