• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

xmlunit / xmlunit / 3f7651ec-f6b5-44df-b60a-ba2dbc5d7339

21 Jun 2025 01:18PM UTC coverage: 91.769%. Remained the same
3f7651ec-f6b5-44df-b60a-ba2dbc5d7339

push

circleci

web-flow
Merge pull request #305 from xmlunit/extend-compat-test-range

add additional compatibility tests

4014 of 4722 branches covered (85.01%)

11774 of 12830 relevant lines covered (91.77%)

2.35 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

18.18
/xmlunit-legacy/src/main/java/org/custommonkey/xmlunit/ElementNameQualifier.java
1
/*
2
******************************************************************
3
Copyright (c) 2001-2007,2015,2022 Jeff Martin, Tim Bacon
4
All rights reserved.
5

6
Redistribution and use in source and binary forms, with or without
7
modification, are permitted provided that the following conditions
8
are met:
9

10
        * Redistributions of source code must retain the above copyright
11
          notice, this list of conditions and the following disclaimer.
12
        * Redistributions in binary form must reproduce the above
13
          copyright notice, this list of conditions and the following
14
          disclaimer in the documentation and/or other materials provided
15
          with the distribution.
16
        * Neither the name of the XMLUnit nor the names
17
          of its contributors may be used to endorse or promote products
18
          derived from this software without specific prior written
19
          permission.
20

21
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
POSSIBILITY OF SUCH DAMAGE.
33

34
******************************************************************
35
*/
36

37
package org.custommonkey.xmlunit;
38

39
import org.xmlunit.diff.ElementSelectors;
40
import org.w3c.dom.Element;
41
import org.w3c.dom.Node;
42

43
/**
44
 * Simple interface implementation that tests two elements for name
45
 * comparability. This class provides the default behaviour within a
46
 * DifferenceEngine (for backwards compatibility)
47
 * @see DifferenceEngine#compareNodeList(java.util.List, java.util.List, int, DifferenceListener, ElementQualifier)
48
 * @see Diff#overrideElementQualifier(ElementQualifier)
49
 */
50
public class ElementNameQualifier implements ElementQualifier {
1✔
51
    /**
52
     * Determine whether two elements qualify for further Difference comparison.
53
     * @return true if the two elements qualify for further comparison based on
54
     *  their  similar namespace URI and non-namespaced tag name,
55
     *  false otherwise
56
     */
57
    @Override
58
    public boolean qualifyForComparison(Element control, Element test) {
59
        return ElementSelectors.byName.canBeCompared(control, test);
1✔
60
    }
61

62
    /**
63
     * Determine whether two nodes are defined by the same namespace URI
64
     * @param control control node
65
     * @param test test node
66
     * @return true if the two nodes are both defined by the same namespace URI
67
     *  (including the default - empty - namespace), false otherwise
68
     */
69
    protected boolean equalsNamespace(Node control, Node test) {
70
        String controlNS = control.getNamespaceURI();
×
71
        String testNS = test.getNamespaceURI();
×
72
        if (controlNS == null) {
×
73
            return testNS == null;
×
74
        }
75
        return controlNS.equals(testNS);
×
76
    }
77

78
    /**
79
     * Strip any namespace information off a node name
80
     * @param node node
81
     * @return the localName if the node is namespaced, or the name otherwise
82
     */
83
    protected String getNonNamespacedNodeName(Node node) {
84
        String name = node.getLocalName();
×
85
        if (name == null) {
×
86
            return node.getNodeName();
×
87
        }
88
        return name;
×
89
    }
90

91
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc