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

hazendaz / httpunit / 636

05 Dec 2025 03:27AM UTC coverage: 80.509%. Remained the same
636

push

github

hazendaz
Cleanup more old since tags

you guessed it, at this point going to jautodoc the rest so the warnings on builds go away ;)

3213 of 4105 branches covered (78.27%)

Branch coverage included in aggregate %.

8249 of 10132 relevant lines covered (81.42%)

0.81 hits per line

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

70.11
/src/main/java/com/meterware/httpunit/dom/DocumentImpl.java
1
/*
2
 * MIT License
3
 *
4
 * Copyright 2011-2025 Russell Gold
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
7
 * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
8
 * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
9
 * to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
 *
11
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions
12
 * of the Software.
13
 *
14
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
15
 * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
17
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18
 * DEALINGS IN THE SOFTWARE.
19
 */
20
package com.meterware.httpunit.dom;
21

22
import java.util.Iterator;
23

24
import org.w3c.dom.Attr;
25
import org.w3c.dom.CDATASection;
26
import org.w3c.dom.Comment;
27
import org.w3c.dom.DOMConfiguration;
28
import org.w3c.dom.DOMException;
29
import org.w3c.dom.DOMImplementation;
30
import org.w3c.dom.Document;
31
import org.w3c.dom.DocumentFragment;
32
import org.w3c.dom.DocumentType;
33
import org.w3c.dom.Element;
34
import org.w3c.dom.EntityReference;
35
import org.w3c.dom.Node;
36
import org.w3c.dom.NodeList;
37
import org.w3c.dom.ProcessingInstruction;
38
import org.w3c.dom.Text;
39
import org.w3c.dom.html.HTMLElement;
40

41
public class DocumentImpl extends NodeImpl implements Document {
1✔
42

43
    private static final long serialVersionUID = 1L;
44
    protected Element _documentElement;
45

46
    static DocumentImpl createDocument() {
47
        DocumentImpl document = new DocumentImpl();
1✔
48
        document.initialize();
1✔
49
        return document;
1✔
50
    }
51

52
    protected void initialize() {
53
    }
1✔
54

55
    @Override
56
    public String getNodeName() {
57
        return "#document";
1✔
58
    }
59

60
    @Override
61
    public String getNodeValue() throws DOMException {
62
        return null;
1✔
63
    }
64

65
    @Override
66
    public void setNodeValue(String nodeValue) throws DOMException {
67
    }
1✔
68

69
    @Override
70
    public short getNodeType() {
71
        return DOCUMENT_NODE;
1✔
72
    }
73

74
    @Override
75
    public Document getOwnerDocument() {
76
        return this;
1✔
77
    }
78

79
    @Override
80
    public DocumentType getDoctype() {
81
        return null;
×
82
    }
83

84
    @Override
85
    public DOMImplementation getImplementation() {
86
        return null;
×
87
    }
88

89
    @Override
90
    public Element getDocumentElement() {
91
        return _documentElement;
1✔
92
    }
93

94
    void setDocumentElement(Element documentElement) {
95
        if (_documentElement != null) {
1✔
96
            throw new IllegalStateException("A document may have only one root");
1✔
97
        }
98
        _documentElement = documentElement;
1✔
99
        appendChild(documentElement);
1✔
100
    }
1✔
101

102
    @Override
103
    public Element createElement(String tagName) throws DOMException {
104
        return ElementImpl.createElement(this, tagName);
1✔
105
    }
106

107
    @Override
108
    public DocumentFragment createDocumentFragment() {
109
        throw new UnsupportedOperationException("DocumentFragment creation not supported ");
×
110
    }
111

112
    @Override
113
    public Text createTextNode(String data) {
114
        return TextImpl.createText(this, data);
1✔
115
    }
116

117
    @Override
118
    public Comment createComment(String data) {
119
        return CommentImpl.createComment(this, data);
1✔
120
    }
121

122
    @Override
123
    public CDATASection createCDATASection(String data) throws DOMException {
124
        return CDATASectionImpl.createCDATASection(this, data);
1✔
125
    }
126

127
    @Override
128
    public ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException {
129
        return ProcessingInstructionImpl.createProcessingImpl(this, target, data);
1✔
130
    }
131

132
    @Override
133
    public Attr createAttribute(String name) throws DOMException {
134
        return AttrImpl.createAttribute(this, name);
1✔
135
    }
136

137
    @Override
138
    public EntityReference createEntityReference(String name) throws DOMException {
139
        throw new UnsupportedOperationException("EntityReference creation not supported ");
×
140
    }
141

142
    @Override
143
    public Node importNode(Node importedNode, boolean deep) throws DOMException {
144
        switch (importedNode.getNodeType()) {
1!
145
            case Node.ATTRIBUTE_NODE:
146
                return AttrImpl.importNode(this, (Attr) importedNode);
1✔
147
            case Node.CDATA_SECTION_NODE:
148
                return CDATASectionImpl.importNode(this, (CDATASection) importedNode);
1✔
149
            case Node.COMMENT_NODE:
150
                return CommentImpl.importNode(this, (Comment) importedNode);
1✔
151
            case Node.ELEMENT_NODE:
152
                return ElementImpl.importNode(this, (Element) importedNode, deep);
1✔
153
            case Node.PROCESSING_INSTRUCTION_NODE:
154
                return ProcessingInstructionImpl.importNode(this, (ProcessingInstruction) importedNode);
1✔
155
            case Node.TEXT_NODE:
156
                return TextImpl.importNode(this, (Text) importedNode);
1✔
157
            default:
158
                throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
×
159
                        "Cannot import node type " + importedNode.getNodeType());
×
160
        }
161
    }
162

163
    @Override
164
    public Element getElementById(String elementId) {
165
        for (Iterator each = preOrderIterator(); each.hasNext();) {
1✔
166
            Node node = (Node) each.next();
1✔
167
            if (!(node instanceof HTMLElement)) {
1✔
168
                continue;
1✔
169
            }
170
            HTMLElement element = (HTMLElement) node;
1✔
171
            if (elementId.equals(element.getId())) {
1✔
172
                return element;
1✔
173
            }
174
        }
1✔
175
        return null;
1✔
176
    }
177

178
    @Override
179
    public Element createElementNS(String namespaceURI, String qualifiedName) throws DOMException {
180
        return ElementImpl.createElement(this, namespaceURI, qualifiedName);
1✔
181
    }
182

183
    @Override
184
    public Attr createAttributeNS(String namespaceURI, String qualifiedName) throws DOMException {
185
        return AttrImpl.createAttribute(this, namespaceURI, qualifiedName);
1✔
186
    }
187

188
    @Override
189
    public NodeList getElementsByTagNameNS(String namespaceURI, String localName) {
190
        if (namespaceURI != null) {
×
191
            throw new UnsupportedOperationException("Namespaces are not supported");
×
192
        }
193
        return getElementsByTagName(localName);
×
194
    }
195

196
    /**
197
     * import the children
198
     *
199
     * @param original
200
     * @param copy
201
     */
202
    void importChildren(Node original, Node copy) {
203
        NodeList children = original.getChildNodes();
1✔
204
        for (int i = 0; i < children.getLength(); i++) {
1✔
205
            Node childCopy = importNode(children.item(i), /* deep */ true);
1✔
206
            copy.appendChild(childCopy);
1✔
207
        }
208
    }
1✔
209

210
    // ------------------------------------- DOM level 3 methods
211
    // ------------------------------------------------------------
212

213
    @Override
214
    public String getInputEncoding() {
215
        return null;
×
216
    }
217

218
    @Override
219
    public String getXmlEncoding() {
220
        return null;
×
221
    }
222

223
    @Override
224
    public Node renameNode(Node n, String namespaceURI, String qualifiedName) throws DOMException {
225
        return null;
×
226
    }
227

228
    @Override
229
    public boolean getXmlStandalone() {
230
        return false;
×
231
    }
232

233
    @Override
234
    public void setXmlStandalone(boolean xmlStandalone) throws DOMException {
235
    }
×
236

237
    @Override
238
    public String getXmlVersion() {
239
        return null;
×
240
    }
241

242
    @Override
243
    public void setXmlVersion(String xmlVersion) throws DOMException {
244
    }
×
245

246
    @Override
247
    public boolean getStrictErrorChecking() {
248
        return false;
×
249
    }
250

251
    @Override
252
    public void setStrictErrorChecking(boolean strictErrorChecking) {
253
    }
×
254

255
    @Override
256
    public String getDocumentURI() {
257
        return null;
×
258
    }
259

260
    @Override
261
    public void setDocumentURI(String documentURI) {
262
    }
×
263

264
    @Override
265
    public Node adoptNode(Node source) throws DOMException {
266
        return null;
×
267
    }
268

269
    @Override
270
    public DOMConfiguration getDomConfig() {
271
        return null;
×
272
    }
273

274
    @Override
275
    public void normalizeDocument() {
276
    }
×
277

278
}
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

© 2026 Coveralls, Inc