Testing XML
Please turn off all
Benefits of Test Driven Development are Well Known
More and More Applications Are Generating XML
XML is not Just a Text File
Different ways of representing the same syntax
Content can change but still be OK
Key Question
An XML document
An Alternate Representation of the Same document
A Representation of the Same Information in a Different Document
The XML Infoset
Element Information Items
The InfoSet Omits:
Infoset significant details that sometimes should ignored anyway
Direct Testing with DOM
DOM Example
Questions?
Canonical XML
A Canonicalized Document
JUnit Canonicalization (using XOM)
Document Subset Canonicalization
JUnit Document Subset Canonicalization (using XOM 1.1)
Exclusive XML Canonicalization
JUnit Exclusive Document Subset Canonicalization
Canonicalization tools and libraries
Questions?
Validity
DTDs
Validating via JUnit
Changing the DTD
Mock DOCTYPE
W3C Schemas
JUnit test for W3C Schemas
RELAX NG schema
JUnit test for RELAX NG Schemas
Questions?
XPath
Some XPath Tests for the plist
XPath in a JUnit test
Writing as XSLT
Combining XPath with Java
XPath+Java Test
Schematron
Schematron Syntax
Schematron schema for plists
Running Schematron
JUnit test for Schematron Schema
Questions?
XMLUnit
XMLUnit
A simple test case
But this is not just a String comparison!
Readers and Documents
Assertion messages
Concepts of Equality
Some documents that are equal but not identical
The Diff class
Testing for identity
XPath Based Tests
XPath Example
DifferenceListener
Comparing two documents with the custom DifferenceListener That Ignores Attributes
ElementQualifier
XMLUnit
To Learn More
Questions?
Entire Presentation as Single File
Start
|
Cafe con Leche
Copyright 2005-2007 Elliotte Rusty Harold
Last Modified December 19, 2006