public class DefaultNodeMatcher extends Object implements 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.
Modifier and Type | Class and Description |
---|---|
static class |
DefaultNodeMatcher.DefaultNodeTypeMatcher
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 |
DefaultNodeMatcher.NodeTypeMatcher
Determines whether two Nodes are eligible for comparison based
on their node type.
|
Constructor and Description |
---|
DefaultNodeMatcher()
Creates a matcher using
ElementSelectors.Default and
DefaultNodeMatcher.DefaultNodeTypeMatcher . |
DefaultNodeMatcher(DefaultNodeMatcher.NodeTypeMatcher ntm,
ElementSelector... es)
Creates a matcher using the given
ElementSelector s and
DefaultNodeMatcher.NodeTypeMatcher . |
DefaultNodeMatcher(ElementSelector... es)
Creates a matcher using the given
ElementSelector s and
DefaultNodeMatcher.DefaultNodeTypeMatcher . |
public DefaultNodeMatcher()
ElementSelectors.Default
and
DefaultNodeMatcher.DefaultNodeTypeMatcher
.public DefaultNodeMatcher(ElementSelector... es)
ElementSelector
s and
DefaultNodeMatcher.DefaultNodeTypeMatcher
.public DefaultNodeMatcher(DefaultNodeMatcher.NodeTypeMatcher ntm, ElementSelector... es)
ElementSelector
s and
DefaultNodeMatcher.NodeTypeMatcher
.
The ElementSelector
s are consulted in order so that
the second ElementSelector
only gets to match the nodes
that the first one couldn't match to any test nodes ate all and
so on.
public Iterable<Map.Entry<Node,Node>> match(Iterable<Node> controlNodes, Iterable<Node> testNodes)
NodeMatcher
Nodes passed in as attributes but not returned as member of
any pair will cause ComparisonType.CHILD_LOOKUP
differences}.
match
in interface NodeMatcher
Copyright © 2001–2017 XMLUnit. All rights reserved.