This test fails, though I expect it would succeed. I filed a bug on this.
public void testIgnoreWhitespace2() throws Exception {
String control =
"<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
"\r\n <env:Header/>" +
"\r\n </env:Envelope>";
String test =
"<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
"<env:Header/>" +
"</env:Envelope>";
XMLUnit.setIgnoreWhitespace(true);
try {
Diff diff = XMLUnit.compareXML(control, test);
System.out.println(test);
System.out.println(control);
System.out.println(new DetailedDiff(diff));
assertEquals("Should be identical", true,
new Diff(control, test).identical());
} finally {
XMLUnit.setIgnoreWhitespace(false);
}
}
Output:
<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:Header/></env:Envelope>
<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
<env:Header/>
</env:Envelope>
org.custommonkey.xmlunit.DetailedDiff
[different] Expected number of child nodes '3' but was '1' - comparing <env:Envelope...> at /Envelope[1] to <env:Envelope...> at /Envelope[1]
[different] Expected presence of child node '#text' but was 'null' - comparing <env:Envelope ...>
</env:Envelope> at /Envelope[1] to at /Envelope[1]/Header[1]
[not identical] Expected sequence of child nodes '1' but was '0' - comparing <env:Header...> at /Envelope[1]/Header[1] to <env:Header...> at /Envelope[1]/Header[1]
[different] Expected presence of child node '#text' but was 'null' - comparing <env:Envelope ...>
</env:Envelope> at /Envelope[1]/Header[1] to at /Envelope[1]/Header[1]
Feel free to use my test as your unit test.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry ... tried the test you checked in and it too fails.
I reopened the bug, because it fails on two different versions of JDK 1.5. Perhaps it's because I'm on Linux as well, I'm not sure. It does pass on JDK 1.6. I can probably come up with a patch for you if you'd like.
Since you didn't have any open issues I wasn't sure if the bug DB or the forum was the correct place. :-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Let's keep the discussion in one place - and I suggest to use the bugreport since people are more likely to search the bug database than the forums (my guess).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This test fails, though I expect it would succeed. I filed a bug on this.
public void testIgnoreWhitespace2() throws Exception {
String control =
"<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
"\r\n <env:Header/>" +
"\r\n </env:Envelope>";
String test =
"<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
"<env:Header/>" +
"</env:Envelope>";
XMLUnit.setIgnoreWhitespace(true);
try {
Diff diff = XMLUnit.compareXML(control, test);
System.out.println(test);
System.out.println(control);
System.out.println(new DetailedDiff(diff));
assertEquals("Should be identical", true,
new Diff(control, test).identical());
} finally {
XMLUnit.setIgnoreWhitespace(false);
}
}
Output:
<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:Header/></env:Envelope>
<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>
<env:Header/>
</env:Envelope>
org.custommonkey.xmlunit.DetailedDiff
[different] Expected number of child nodes '3' but was '1' - comparing <env:Envelope...> at /Envelope[1] to <env:Envelope...> at /Envelope[1]
[different] Expected presence of child node '#text' but was 'null' - comparing <env:Envelope ...>
</env:Envelope> at /Envelope[1] to at /Envelope[1]/Header[1]
[not identical] Expected sequence of child nodes '1' but was '0' - comparing <env:Header...> at /Envelope[1]/Header[1] to <env:Header...> at /Envelope[1]/Header[1]
[different] Expected presence of child node '#text' but was 'null' - comparing <env:Envelope ...>
</env:Envelope> at /Envelope[1]/Header[1] to at /Envelope[1]/Header[1]
Feel free to use my test as your unit test.
It's a bit hard to decide whether I should follow up here or in the bug report 8-)
Anyway, I've added your test http://xmlunit.svn.sourceforge.net/viewvc/xmlunit?view=rev&revision=230 and it passes for me.
Sorry ... tried the test you checked in and it too fails.
I reopened the bug, because it fails on two different versions of JDK 1.5. Perhaps it's because I'm on Linux as well, I'm not sure. It does pass on JDK 1.6. I can probably come up with a patch for you if you'd like.
Since you didn't have any open issues I wasn't sure if the bug DB or the forum was the correct place. :-)
The problem seems to be due to this:
http://issues.apache.org/jira/browse/XALANJ-2230
and
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6413803
I suppose I could upgrade my JDK 1.5 to release 12 from 11 but I don't think it would work. Is it possible for you to create some sort of work-around?
Yep, I think this is the culprit.
Let's keep the discussion in one place - and I suggest to use the bugreport since people are more likely to search the bug database than the forums (my guess).