public final class DifferenceEvaluators
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static DifferenceEvaluator |
Accept
Difference evaluator that just echos the result passed in.
|
private static java.lang.Short |
CDATA |
static DifferenceEvaluator |
Default
The "standard" difference evaluator which decides which
differences make two XML documents really different and which
still leave them similar.
|
private static java.lang.Short |
TEXT |
Modifier | Constructor and Description |
---|---|
private |
DifferenceEvaluators() |
Modifier and Type | Method and Description |
---|---|
private static boolean |
belongsToProlog(Comparison comparison,
boolean ignoreDoctypeDeclarationAsWell) |
private static boolean |
belongsToProlog(org.w3c.dom.Node n,
boolean ignoreDoctypeDeclarationAsWell) |
static DifferenceEvaluator |
chain(DifferenceEvaluator... evaluators)
Combines multiple DifferenceEvaluators so that the result of the
first Evaluator will be passed to the next Evaluator.
|
static DifferenceEvaluator |
downgradeDifferencesToEqual(ComparisonType... types)
Creates a DifferenceEvaluator that returns a EQUAL result for
differences found in one of the given ComparisonTypes.
|
static DifferenceEvaluator |
downgradeDifferencesToSimilar(ComparisonType... types)
Creates a DifferenceEvaluator that returns a SIMILAR result for
differences (Comparisons that are not EQUAL) found in one of
the given ComparisonTypes.
|
static DifferenceEvaluator |
first(DifferenceEvaluator... evaluators)
Combines multiple DifferenceEvaluators so that the first one
that changes the outcome wins.
|
static DifferenceEvaluator |
ignorePrologDifferences()
Ignore any differences that are part of the XML
prolog.
|
static DifferenceEvaluator |
ignorePrologDifferencesExceptDoctype()
Ignore any differences except differences inside the doctype
declaration that are part of the XML
prolog.
|
private static boolean |
isSequenceOfRootElement(Comparison comparison) |
private static DifferenceEvaluator |
recordDifferencesAs(ComparisonResult outcome,
ComparisonType... types) |
static DifferenceEvaluator |
upgradeDifferencesToDifferent(ComparisonType... types)
Creates a DifferenceEvaluator that returns a DIFFERENT result
for differences (Comparisons that are not EQUAL) found in one
of the given ComparisonTypes.
|
private static final java.lang.Short CDATA
private static final java.lang.Short TEXT
public static final DifferenceEvaluator Accept
public static final DifferenceEvaluator Default
public static DifferenceEvaluator first(DifferenceEvaluator... evaluators)
public static DifferenceEvaluator chain(DifferenceEvaluator... evaluators)
public static DifferenceEvaluator downgradeDifferencesToEqual(ComparisonType... types)
public static DifferenceEvaluator downgradeDifferencesToSimilar(ComparisonType... types)
public static DifferenceEvaluator upgradeDifferencesToDifferent(ComparisonType... types)
public static DifferenceEvaluator ignorePrologDifferences()
Here "ignore" means return ComparisonResult.EQUAL
.
public static DifferenceEvaluator ignorePrologDifferencesExceptDoctype()
Here "ignore" means return ComparisonResult.EQUAL
.
This is one of the building blocks for mimicing the behavior of XMLUnit for Java 1.x. In order to get the same behavior you need:
chain(Default, // so CDATA and Text are the same ignorePrologDifferencesExceptDoctype()) // so most of the prolog is ignored
In general different doctype declarations will be ignored
because of NodeFilters.Default
, so if you want to
detect these differences you need to pick a different NodeFilter
.
private static DifferenceEvaluator recordDifferencesAs(ComparisonResult outcome, ComparisonType... types)
private static boolean belongsToProlog(Comparison comparison, boolean ignoreDoctypeDeclarationAsWell)
private static boolean belongsToProlog(org.w3c.dom.Node n, boolean ignoreDoctypeDeclarationAsWell)
private static boolean isSequenceOfRootElement(Comparison comparison)