Class DefaultNodeMatcher
- All Implemented Interfaces:
NodeMatcher
NodeMatcher
that matches control
and tests nodes for comparison with the help of DefaultNodeMatcher.NodeTypeMatcher
and ElementSelector
s.
There is an important difference between using ElementSelectors.or(org.xmlunit.diff.ElementSelector...)
to combine multiple ElementSelector
s
and using DefaultNodeMatcher
's constructor with multiple
ElementSelector
s:
Consider ElementSelector
s e1
and e2
and
two control and test nodes each. Assume e1
would match the
first control node to the second test node and vice versa if used
alone, while e2
would match the nodes in order (the first
control node to the first test and so on).
ElementSelectors.or(org.xmlunit.diff.ElementSelector...)
creates a combined ElementSelector
that is willing to match the first control node to
both of the test nodes - and the same for the second control node.
Since nodes are compared in order when possible the result will be
the same as running e2
alone.
DefaultNodeMatcher
with two ElementSelector
s
will consult the ElementSelector
s separately and only
invoke e2
if there are any nodes not matched by e1
at all. In this case the result will be the same as running
e1
alone.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
DefaultNodeMatcher.NodeTypeMatcher
that marks pairs of nodes of the same node type as well as pairs of CDATA sections and text nodes as eligible.static interface
Determines whether two Nodes are eligible for comparison based on their node type. -
Constructor Summary
ConstructorDescriptionCreates a matcher usingElementSelectors.Default
andDefaultNodeMatcher.DefaultNodeTypeMatcher
.Creates a matcher using the givenElementSelector
s andDefaultNodeMatcher.NodeTypeMatcher
.Creates a matcher using the givenElementSelector
s andDefaultNodeMatcher.DefaultNodeTypeMatcher
. -
Method Summary
-
Constructor Details
-
DefaultNodeMatcher
public DefaultNodeMatcher()Creates a matcher usingElementSelectors.Default
andDefaultNodeMatcher.DefaultNodeTypeMatcher
. -
DefaultNodeMatcher
Creates a matcher using the givenElementSelector
s andDefaultNodeMatcher.DefaultNodeTypeMatcher
.- Parameters:
es
- the ElementSelectors to use
-
DefaultNodeMatcher
Creates a matcher using the givenElementSelector
s andDefaultNodeMatcher.NodeTypeMatcher
.The
ElementSelector
s are consulted in order so that the secondElementSelector
only gets to match the nodes that the first one couldn't match to any test nodes ate all and so on.- Parameters:
ntm
- the NodeTypeMatcher to usees
- the ElementSelectors to use
-
-
Method Details
-
match
Description copied from interface:NodeMatcher
Matches control and test nodes against each other, returns the matching pairs.Nodes passed in as attributes but not returned as member of any pair will cause
ComparisonType.CHILD_LOOKUP
differences}.- Specified by:
match
in interfaceNodeMatcher
- Parameters:
controlNodes
- the control nodestestNodes
- the test nodes- Returns:
- a Map.Entry containing the pair for each matched pair of nodes
-