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.
XMLTestCase
is 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
XMLAssert
class.
All methods that have been deprecated in XMLUnit 1.0 have been removed.
All methods that had been declared to throw
TransformerConfigurationException
or
ParserConfigurationException
now no
longer declare it. Exceptions of these types cannot be
recovered from anyway, so XMLUnit will now wrap them in a
org.custommonkey.xmlunit.exceptions.ConfigurationException
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 Difference
(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 Difference
of either ELEMENT_TAG_NAME_ID
or
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.
The schemaLocation
and
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 Difference
that
is recoverable.
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
is.
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 DetailedDiff
this change may lead to more detected
Difference
s, though.
javax.xml.xpath
if
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.EntityResolver
for control
and test parsers.javax.xml.transform.URIResolver
for
transformations.org.xml.sax.InputSource
to be used as a
"piece of XML" in many classes.Validator
will now use the
custom EntityResolver
configured for the "control"
parser as a fallback.A new package
org.custommonkey.xmlunit.examples
has
been added that showcases some of XMLUnit's abilities.
It currently contains two classes:
MultiLevelElementNameAndTextQualifier
see Section 3.4.5, “org.custommonkey.xmlunit.examples.MultiLevelElementNameAndTextQualifier
” for
a description.XPathRegexAssert
that
provides a JUnit 3.x like
assertXPathMatches
method to verify
that the string-ified value of an XPath match matches a
given regular expression (requires JDK 1.4 or
above).ElementNameAndAttributeQualifier
would throw an NullPointerException
if
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
assertXMLEqual
instead of
assertXMLNotEqual
internally, negating
the assertion's logic. Issue
956372.XMLTestCase.assertXMLIdentical(Diff,
boolean)
delegated to
assertXMLEqual
, weakening the
assertion.TolerantSaxParser
's logic in
characters
was broken and could cause
StringIndexOutOfBoundsException
s.
Issue 1150234.