XmlFixture is the class that helps XML assertions in an easy way.

Download

http://sourceforge.net/project/showfiles.php?group_id=54719&package_id=156151

Creation

XmlFixture works using JDom, and it can be created from various type of sources using its static factory methods:

XPath Match

After a XmlFixture instance is created, it can be used for XPath matching by calling xpathMatch. This methods will create a XpathMatch object that contains the XPath match result, with the following method:

Please also note that for convenience, the commonly used methods on XpathMatch is also available on XmlFixture.

The following code block illustrates how a typical XML assertion looks like with XmlFixture:

XmlFixture xml = XmlFixture.fromText("<person><address type=\"test\">address value</address></person>");
assertEquals("address value", xml.xpath("/person/address[@type='test']"));
assertEquals(1, xml.xpathCount("/person/address"));

Exception Handling

XmlFixture wraps all the excepion into a RuntimeException so that you don't have to.

Dependency

The following are the jars that XmlFixture depends on: