XMLUnit 1.1's main focus was to add two features that have been asked for repeatedly:
In addition some JAXP features that have been added after the release of XMLUnit 1.0 are now supported - most notably XPath support - and all reported bugs and feature requests have been addressed.
XMLTestCaseis now abstract. You probably have never created instances of this class without subclassing it, but if you did, your code will now break. You will most likely want to look at the
All methods that have been deprecated in XMLUnit 1.0 have been removed.
All methods that had been declared to throw
ParserConfigurationException now no
longer declare it. Exceptions of these types cannot be
recovered from anyway, so XMLUnit will now wrap them in a
which is an unchecked exception.
This change doesn't have a big impact on your tests, but if you tried to catch these exceptions they will now bypass your catch blocks.
A new type of
CHILD_NODE_NOT_FOUND_ID) has been
added. It will be raised for the excess children if the
control element has more child nodes than the test element
- or vice versa.
Prior to XMLUnit 1.1 a
NODE_TYPE_ID would have been raised if
the control element had more children. The excess
children were compared to the very first child node of the
test element. Excess children of the test element were
not reported at all.
noNamespaceSchemaLocation attributes of
the XMLSchema-Instance Namespace are now treated in a
different way from "normal" attributes. They will be
flagged as new kinds of
This means that two pieces of XML that were different in XMLUnit 1.0 because they differed in one of the two attributes will be similar in XMLUnit 1.1.
When comparing two elements that differ on attributes the comparison is now symmetric.
In XMLUnit 1.0 if an attribute was present on the
test but not the control element this wasn't flagged as a
Difference; in XMLUnit 1.1 it
In most practical cases this doesn't cause any
problems since the two elements either have a different
number of attributes or there are attributes in the
control element that are missing in the test element - so
the pieces of XML have been flagged as different before as
well. If you are using
this change may lead to more detected
javax.xml.xpathif it is available (which also helps to avoid the buggy XSLTC version that is the default transformer engine in Java 5) and supports XML namespaces.
org.xml.sax.EntityResolverfor control and test parsers.
org.xml.sax.InputSourceto be used as a "piece of XML" in many classes.
Validatorwill now use the custom
EntityResolverconfigured for the "control" parser as a fallback.
A new package
been added that showcases some of XMLUnit's abilities.
It currently contains two classes:
MultiLevelElementNameAndTextQualifiersee Section 3.4.5, “
org.custommonkey.xmlunit.examples.MultiLevelElementNameAndTextQualifier” for a description.
XPathRegexAssertthat provides a JUnit 3.x like
assertXPathMatchesmethod to verify that the string-ified value of an XPath match matches a given regular expression (requires JDK 1.4 or above).
ElementNameAndAttributeQualifierwould throw an
NullPointerExceptionif the control piece of XML contained attributes that were missing in the test piece of XML. Issue 952920.
XMLTestCase.assertXMLNotEqual(String, Reader, Reader)delegated to
assertXMLNotEqualinternally, negating the assertion's logic. Issue 956372.
XMLTestCase.assertXMLIdentical(Diff, boolean)delegated to
assertXMLEqual, weakening the assertion.
TolerantSaxParser's logic in
characterswas broken and could cause
StringIndexOutOfBoundsExceptions. Issue 1150234.