org.baselinetest.comparator
Class XMLComparator

java.lang.Object
  extended by org.baselinetest.comparator.XMLComparator
All Implemented Interfaces:
TestComparator

public class XMLComparator
extends java.lang.Object
implements TestComparator

A class for comparing XML files for differences. The XMLComparator will pretty-print the expected and actual test output, and do a textual comparison of the pretty-printed output. It does not attempt to determine any type of logical equivalency.

Author:
jwan

Field Summary
protected static boolean DEFAULT_CANONICAL
          Default canonical output (false).
protected static boolean DEFAULT_DYNAMIC_VALIDATION
          Default dynamic validation support (false).
protected static boolean DEFAULT_GENERATE_SYNTHETIC_ANNOTATIONS
          Default generate synthetic schema annotations (false).
protected static boolean DEFAULT_LOAD_EXTERNAL_DTD
          Default load external DTD (true).
protected static boolean DEFAULT_NAMESPACE_PREFIXES
          Default namespace prefixes (false).
protected static boolean DEFAULT_NAMESPACES
          Default namespaces support (true).
protected static java.lang.String DEFAULT_PARSER_NAME
          Default parser name.
protected static boolean DEFAULT_SCHEMA_FULL_CHECKING
          Default Schema full checking support (false).
protected static boolean DEFAULT_SCHEMA_VALIDATION
          Default Schema validation support (false).
protected static boolean DEFAULT_VALIDATE_ANNOTATIONS
          Default validate schema annotations (false).
protected static boolean DEFAULT_VALIDATION
          Default validation support (false).
protected static boolean DEFAULT_XINCLUDE
          Default XInclude processing support (false).
protected static boolean DEFAULT_XINCLUDE_FIXUP_BASE_URIS
          Default XInclude fixup base URIs support (true).
protected static boolean DEFAULT_XINCLUDE_FIXUP_LANGUAGE
          Default XInclude fixup language support (true).
protected static java.lang.String DYNAMIC_VALIDATION_FEATURE_ID
          Dynamic validation feature id (http://apache.org/xml/features/validation/dynamic).
protected static java.lang.String GENERATE_SYNTHETIC_ANNOTATIONS_ID
          Generate synthetic schema annotations feature id (http://apache.org/xml/features/generate-synthetic-annotations).
protected static java.lang.String LEXICAL_HANDLER_PROPERTY_ID
          Lexical handler property id (http://xml.org/sax/properties/lexical-handler).
protected static java.lang.String LOAD_EXTERNAL_DTD_FEATURE_ID
          Load external DTD feature id (http://apache.org/xml/features/nonvalidating/load-external-dtd).
protected static java.lang.String NAMESPACE_PREFIXES_FEATURE_ID
          Namespace prefixes feature id (http://xml.org/sax/features/namespace-prefixes).
protected static java.lang.String NAMESPACES_FEATURE_ID
          Namespaces feature id (http://xml.org/sax/features/namespaces).
protected static java.lang.String SCHEMA_FULL_CHECKING_FEATURE_ID
          Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking).
protected static java.lang.String SCHEMA_VALIDATION_FEATURE_ID
          Schema validation feature id (http://apache.org/xml/features/validation/schema).
protected static java.lang.String VALIDATE_ANNOTATIONS_ID
          Validate schema annotations feature id (http://apache.org/xml/features/validate-annotations)
protected static java.lang.String VALIDATION_FEATURE_ID
          Validation feature id (http://xml.org/sax/features/validation).
protected static java.lang.String XINCLUDE_FEATURE_ID
          XInclude feature id (http://apache.org/xml/features/xinclude).
protected static java.lang.String XINCLUDE_FIXUP_BASE_URIS_FEATURE_ID
          XInclude fixup base URIs feature id (http://apache.org/xml/features/xinclude/fixup-base-uris).
protected static java.lang.String XINCLUDE_FIXUP_LANGUAGE_FEATURE_ID
          XInclude fixup language feature id (http://apache.org/xml/features/xinclude/fixup-language).
 
Constructor Summary
XMLComparator()
           
 
Method Summary
 boolean compare(java.io.File expectedOutputFile, java.io.File actualOutputFile)
          Perform a comparison of two XML files.
 void createPrettyPrintedFile(java.io.File inputFile, java.io.File outputFile)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAMESPACES_FEATURE_ID

protected static final java.lang.String NAMESPACES_FEATURE_ID
Namespaces feature id (http://xml.org/sax/features/namespaces).

See Also:
Constant Field Values

NAMESPACE_PREFIXES_FEATURE_ID

protected static final java.lang.String NAMESPACE_PREFIXES_FEATURE_ID
Namespace prefixes feature id (http://xml.org/sax/features/namespace-prefixes).

See Also:
Constant Field Values

VALIDATION_FEATURE_ID

protected static final java.lang.String VALIDATION_FEATURE_ID
Validation feature id (http://xml.org/sax/features/validation).

See Also:
Constant Field Values

SCHEMA_VALIDATION_FEATURE_ID

protected static final java.lang.String SCHEMA_VALIDATION_FEATURE_ID
Schema validation feature id (http://apache.org/xml/features/validation/schema).

See Also:
Constant Field Values

SCHEMA_FULL_CHECKING_FEATURE_ID

protected static final java.lang.String SCHEMA_FULL_CHECKING_FEATURE_ID
Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking).

See Also:
Constant Field Values

VALIDATE_ANNOTATIONS_ID

protected static final java.lang.String VALIDATE_ANNOTATIONS_ID
Validate schema annotations feature id (http://apache.org/xml/features/validate-annotations)

See Also:
Constant Field Values

GENERATE_SYNTHETIC_ANNOTATIONS_ID

protected static final java.lang.String GENERATE_SYNTHETIC_ANNOTATIONS_ID
Generate synthetic schema annotations feature id (http://apache.org/xml/features/generate-synthetic-annotations).

See Also:
Constant Field Values

DYNAMIC_VALIDATION_FEATURE_ID

protected static final java.lang.String DYNAMIC_VALIDATION_FEATURE_ID
Dynamic validation feature id (http://apache.org/xml/features/validation/dynamic).

See Also:
Constant Field Values

LOAD_EXTERNAL_DTD_FEATURE_ID

protected static final java.lang.String LOAD_EXTERNAL_DTD_FEATURE_ID
Load external DTD feature id (http://apache.org/xml/features/nonvalidating/load-external-dtd).

See Also:
Constant Field Values

XINCLUDE_FEATURE_ID

protected static final java.lang.String XINCLUDE_FEATURE_ID
XInclude feature id (http://apache.org/xml/features/xinclude).

See Also:
Constant Field Values

XINCLUDE_FIXUP_BASE_URIS_FEATURE_ID

protected static final java.lang.String XINCLUDE_FIXUP_BASE_URIS_FEATURE_ID
XInclude fixup base URIs feature id (http://apache.org/xml/features/xinclude/fixup-base-uris).

See Also:
Constant Field Values

XINCLUDE_FIXUP_LANGUAGE_FEATURE_ID

protected static final java.lang.String XINCLUDE_FIXUP_LANGUAGE_FEATURE_ID
XInclude fixup language feature id (http://apache.org/xml/features/xinclude/fixup-language).

See Also:
Constant Field Values

LEXICAL_HANDLER_PROPERTY_ID

protected static final java.lang.String LEXICAL_HANDLER_PROPERTY_ID
Lexical handler property id (http://xml.org/sax/properties/lexical-handler).

See Also:
Constant Field Values

DEFAULT_PARSER_NAME

protected static final java.lang.String DEFAULT_PARSER_NAME
Default parser name.

See Also:
Constant Field Values

DEFAULT_NAMESPACES

protected static final boolean DEFAULT_NAMESPACES
Default namespaces support (true).

See Also:
Constant Field Values

DEFAULT_NAMESPACE_PREFIXES

protected static final boolean DEFAULT_NAMESPACE_PREFIXES
Default namespace prefixes (false).

See Also:
Constant Field Values

DEFAULT_VALIDATION

protected static final boolean DEFAULT_VALIDATION
Default validation support (false).

See Also:
Constant Field Values

DEFAULT_LOAD_EXTERNAL_DTD

protected static final boolean DEFAULT_LOAD_EXTERNAL_DTD
Default load external DTD (true).

See Also:
Constant Field Values

DEFAULT_SCHEMA_VALIDATION

protected static final boolean DEFAULT_SCHEMA_VALIDATION
Default Schema validation support (false).

See Also:
Constant Field Values

DEFAULT_SCHEMA_FULL_CHECKING

protected static final boolean DEFAULT_SCHEMA_FULL_CHECKING
Default Schema full checking support (false).

See Also:
Constant Field Values

DEFAULT_VALIDATE_ANNOTATIONS

protected static final boolean DEFAULT_VALIDATE_ANNOTATIONS
Default validate schema annotations (false).

See Also:
Constant Field Values

DEFAULT_GENERATE_SYNTHETIC_ANNOTATIONS

protected static final boolean DEFAULT_GENERATE_SYNTHETIC_ANNOTATIONS
Default generate synthetic schema annotations (false).

See Also:
Constant Field Values

DEFAULT_DYNAMIC_VALIDATION

protected static final boolean DEFAULT_DYNAMIC_VALIDATION
Default dynamic validation support (false).

See Also:
Constant Field Values

DEFAULT_XINCLUDE

protected static final boolean DEFAULT_XINCLUDE
Default XInclude processing support (false).

See Also:
Constant Field Values

DEFAULT_XINCLUDE_FIXUP_BASE_URIS

protected static final boolean DEFAULT_XINCLUDE_FIXUP_BASE_URIS
Default XInclude fixup base URIs support (true).

See Also:
Constant Field Values

DEFAULT_XINCLUDE_FIXUP_LANGUAGE

protected static final boolean DEFAULT_XINCLUDE_FIXUP_LANGUAGE
Default XInclude fixup language support (true).

See Also:
Constant Field Values

DEFAULT_CANONICAL

protected static final boolean DEFAULT_CANONICAL
Default canonical output (false).

See Also:
Constant Field Values
Constructor Detail

XMLComparator

public XMLComparator()
Method Detail

compare

public boolean compare(java.io.File expectedOutputFile,
                       java.io.File actualOutputFile)
Perform a comparison of two XML files.

Specified by:
compare in interface TestComparator
Parameters:
expectedOutputFile - the expected test output.
actualOutputFile - the test output.
Returns:
true if the files represent equivalent XML data structures.

createPrettyPrintedFile

public void createPrettyPrintedFile(java.io.File inputFile,
                                    java.io.File outputFile)
                             throws java.io.IOException,
                                    org.xml.sax.SAXException
Throws:
java.io.IOException
org.xml.sax.SAXException


Copyright © 2005-2009 Baseline Test. All Rights Reserved.