10.2 Architecture

     

XMLUnit is implemented as a number of classes built upon the foundation provided by JUnit (or NUnit.) Tests are implemented by inheritance from a base class, XMLTestCase , which is derived from TestCase . The tests may use XML-specific test assert methods from the class XMLAssert .

Java can process XML using any classes compliant with the Java API for XML Processing (JAXP) specification. System properties can be set to name the parser classes to use, as shown here:

 System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"); System.setProperty("javax.xml.parsers.SAXParserFactory", "org.apache.xerces.jaxp.SAXParserFactoryImpl"); 

These calls tell Java to use the Xerces XML parser and document builder.

For XPath and XSL operations, Java can use any XML transformation class that is compliant with the Transformation API for XML (TrAX). Another system property names the transformation class to use:

 System.setProperty("javax.xml.transform.TransformerFactory", "org.apache.xalan.processor.TransformerFactoryImpl"); 

This call causes the Xalan transformation engine to be used for XML transformations.

If these properties are not set, the default JAXP parser settings are used. The Apache Crimson XML parser currently ships with Java. Crimson implements neither the World Wide Web Consortium (W3C) DocumentTraversal interface nor the JAXP javax.xml.transform hierarchy. So, it's necessary to use alternative XML tools such as Xerces and Xalan to write XMLUnit tests that do XML transformations or XML tree-walking using DocumentTraversal .



Unit Test Frameworks
Unit Test Frameworks
ISBN: 0596006896
EAN: 2147483647
Year: 2006
Pages: 146
Authors: Paul Hamill

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net