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

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

21 Jun 2025 01:18PM CUT 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

30.43
/xmlunit-legacy/src/main/java/org/custommonkey/xmlunit/AbstractNodeTester.java
1
/*
2
******************************************************************
3
Copyright (c) 2001,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.w3c.dom.Attr;
40
import org.w3c.dom.CDATASection;
41
import org.w3c.dom.Comment;
42
import org.w3c.dom.DocumentType;
43
import org.w3c.dom.Element;
44
import org.w3c.dom.Entity;
45
import org.w3c.dom.EntityReference;
46
import org.w3c.dom.Node;
47
import org.w3c.dom.Notation;
48
import org.w3c.dom.ProcessingInstruction;
49
import org.w3c.dom.Text;
50

51
/**
52
 * Helper class.
53
 * Abstract interface implementation that performs Node-type checks and
54
 * delegates testNode() processing to subclass.
55
 * @see NodeTest
56
 */
57
public abstract class AbstractNodeTester implements NodeTester {
1✔
58
    /**
59
     * Validate a single Node by delegating to node type specific methods.
60
     * @see #testAttribute(Attr)
61
     * @see #testCDATASection(CDATASection)
62
     * @see #testComment(Comment)
63
     * @see #testDocumentType(DocumentType)
64
     * @see #testElement(Element)
65
     * @see #testEntity(Entity)
66
     * @see #testEntityReference(EntityReference)
67
     * @see #testNotation(Notation)
68
     * @see #testProcessingInstruction(ProcessingInstruction)
69
     * @see #testText(Text)
70
     */
71
    @Override
72
    public void testNode(Node aNode, NodeTest forTest) throws NodeTestException {
73
        switch (aNode.getNodeType()) {
1!
74
        case Node.ATTRIBUTE_NODE:
75
            // should not happen as attributes are not exposed by DOM traversal
76
            testAttribute((Attr)aNode);
×
77
            break;
×
78
        case Node.CDATA_SECTION_NODE:
79
            testCDATASection((CDATASection)aNode);
1✔
80
            break;
1✔
81
        case Node.COMMENT_NODE:
82
            testComment((Comment)aNode);
1✔
83
            break;
1✔
84
        case Node.DOCUMENT_TYPE_NODE:
85
            testDocumentType((DocumentType)aNode);
×
86
            break;
×
87
        case Node.ELEMENT_NODE:
88
            testElement((Element)aNode);
1✔
89
            break;
1✔
90
        case Node.ENTITY_NODE:
91
            testEntity((Entity)aNode);
×
92
            break;
×
93
        case Node.ENTITY_REFERENCE_NODE:
94
            testEntityReference((EntityReference)aNode);
×
95
            break;
×
96
        case Node.NOTATION_NODE:
97
            testNotation((Notation)aNode);
×
98
            break;
×
99
        case Node.PROCESSING_INSTRUCTION_NODE:
100
            testProcessingInstruction(
1✔
101
                                      (ProcessingInstruction) aNode);
102
            break;
1✔
103
        case Node.TEXT_NODE:
104
            testText((Text)aNode);
1✔
105
            break;
1✔
106
        default:
107
            throw new NodeTestException("No delegate method for Node type",
×
108
                                        aNode);
109
        }
110
    }
1✔
111

112
    /**
113
     * Template delegator for testNode() method. OVERRIDE to add custom logic
114
     * @param attribute the attribute to test
115
     * @exception NodeTestException always: override if required in subclass
116
     */
117
    public void testAttribute(Attr attribute) throws NodeTestException {
118
        unhandled(attribute);
×
119
    }
×
120
    /**
121
     * Template delegator for testNode() method. OVERRIDE to add custom logic
122
     * @param cdata the CDATA section to test
123
     * @exception NodeTestException always: override if required in subclass
124
     */
125
    public void testCDATASection(CDATASection cdata) throws NodeTestException {
126
        unhandled(cdata);
×
127
    }
×
128
    /**
129
     * Template delegator for testNode() method. OVERRIDE to add custom logic
130
     * @param comment the comment to test
131
     * @exception NodeTestException always: override if required in subclass
132
     */
133
    public void testComment(Comment comment) throws NodeTestException {
134
        unhandled(comment);
×
135
    }
×
136
    /**
137
     * Template delegator for testNode() method. OVERRIDE to add custom logic
138
     * @param doctype the cofument type to test
139
     * @exception NodeTestException always: override if required in subclass
140
     */
141
    public void testDocumentType(DocumentType doctype) throws NodeTestException {
142
        unhandled(doctype);
×
143
    }
×
144
    /**
145
     * Template delegator for testNode() method. OVERRIDE to add custom logic
146
     * @param element the element to test
147
     * @exception NodeTestException always: override if required in subclass
148
     */
149
    public void testElement(Element element) throws NodeTestException {
150
        unhandled(element);
×
151
    }
×
152
    /**
153
     * Template delegator for testNode() method. OVERRIDE to add custom logic
154
     * @param entity the entity to test
155
     * @exception NodeTestException always: override if required in subclass
156
     */
157
    public void testEntity(Entity entity) throws NodeTestException {
158
        unhandled(entity);
×
159
    }
×
160
    /**
161
     * Template delegator for testNode() method. OVERRIDE to add custom logic
162
     * @param reference the reference to test
163
     * @exception NodeTestException always: override if required in subclass
164
     */
165
    public void testEntityReference(EntityReference reference) throws NodeTestException {
166
        unhandled(reference);
×
167
    }
×
168
    /**
169
     * Template delegator for testNode() method. OVERRIDE to add custom logic
170
     * @param notation the notation to test
171
     * @exception NodeTestException always: override if required in subclass
172
     */
173
    public void testNotation(Notation notation) throws NodeTestException {
174
        unhandled(notation);
×
175
    }
×
176
    /**
177
     * Template delegator for testNode() method. OVERRIDE to add custom logic
178
     * @param instr the processing instruction to test
179
     * @exception NodeTestException always: override if required in subclass
180
     */
181
    public void testProcessingInstruction(ProcessingInstruction instr) throws NodeTestException  {
182
        unhandled(instr);
×
183
    }
×
184
    /**
185
     * Template delegator for testNode() method. OVERRIDE to add custom logic
186
     * @param text the text to test
187
     * @exception NodeTestException always: override if required in subclass
188
     */
189
    public void testText(Text text) throws NodeTestException {
190
        unhandled(text);
×
191
    }
×
192

193
    private void unhandled(Node aNode) throws NodeTestException {
194
        throw new NodeTestException("Test fails by default in AbstractNodeTester" + aNode, aNode);
1✔
195
    }
196

197
    /**
198
     * Validate that the Nodes validated one-by-one in the <code>isValid</code>
199
     * method were all the Nodes expected. By default do nothing:
200
     * can override to add custom logic
201
     * @exception NodeTestException if mode Nodes were expected
202
     */
203
    @Override
204
    public void noMoreNodes(NodeTest forTest) throws NodeTestException {
205
        //by default do nothing
206
    }
×
207
}
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