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

hazendaz / httpunit / 755

14 Feb 2026 07:14PM UTC coverage: 80.526%. Remained the same
755

push

github

hazendaz
[ci] Fix badge

3213 of 4105 branches covered (78.27%)

Branch coverage included in aggregate %.

8245 of 10124 relevant lines covered (81.44%)

0.81 hits per line

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

80.77
/src/main/java/com/meterware/servletunit/XMLUtils.java
1
/*
2
 * SPDX-License-Identifier: MIT
3
 * See LICENSE file for details.
4
 *
5
 * Copyright 2000-2026 Russell Gold
6
 * Copyright 2021-2000 hazendaz
7
 */
8
package com.meterware.servletunit;
9

10
import org.w3c.dom.Element;
11
import org.w3c.dom.Node;
12
import org.w3c.dom.NodeList;
13
import org.xml.sax.SAXException;
14

15
/**
16
 * The Class XMLUtils.
17
 */
18
abstract class XMLUtils {
×
19

20
    /**
21
     * Gets the child node value.
22
     *
23
     * @param root
24
     *            the root
25
     * @param childNodeName
26
     *            the child node name
27
     *
28
     * @return the child node value
29
     *
30
     * @throws SAXException
31
     *             the SAX exception
32
     */
33
    static String getChildNodeValue(Element root, String childNodeName) throws SAXException {
34
        return getChildNodeValue(root, childNodeName, null);
1✔
35
    }
36

37
    /**
38
     * Gets the child node value.
39
     *
40
     * @param root
41
     *            the root
42
     * @param childNodeName
43
     *            the child node name
44
     * @param defaultValue
45
     *            the default value
46
     *
47
     * @return the child node value
48
     *
49
     * @throws SAXException
50
     *             the SAX exception
51
     */
52
    static String getChildNodeValue(Element root, String childNodeName, String defaultValue) throws SAXException {
53
        NodeList nl = root.getElementsByTagName(childNodeName);
1✔
54
        if (nl.getLength() == 1) {
1✔
55
            return getTextValue(nl.item(0)).trim();
1✔
56
        }
57
        if (defaultValue == null) {
1!
58
            throw new SAXException("Node <" + root.getNodeName() + "> has no child named <" + childNodeName + ">");
×
59
        }
60
        return defaultValue;
1✔
61
    }
62

63
    /**
64
     * Gets the text value.
65
     *
66
     * @param node
67
     *            the node
68
     *
69
     * @return the text value
70
     *
71
     * @throws SAXException
72
     *             the SAX exception
73
     */
74
    static String getTextValue(Node node) throws SAXException {
75
        Node textNode = node.getFirstChild();
1✔
76
        if (textNode == null) {
1✔
77
            return "";
1✔
78
        }
79
        if (textNode.getNodeType() != Node.TEXT_NODE) {
1!
80
            throw new SAXException("No text value found for <" + node.getNodeName() + "> node");
×
81
        }
82
        return textNode.getNodeValue();
1✔
83
    }
84

85
    /**
86
     * Checks for child node.
87
     *
88
     * @param root
89
     *            the root
90
     * @param childNodeName
91
     *            the child node name
92
     *
93
     * @return true, if successful
94
     */
95
    static boolean hasChildNode(Element root, String childNodeName) {
96
        NodeList nl = root.getElementsByTagName(childNodeName);
1✔
97
        return nl.getLength() > 0;
1✔
98
    }
99

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