• 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

83.33
/src/main/java/com/meterware/httpunit/UncheckedParameterHolder.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;
21

22
import com.meterware.httpunit.protocol.ParameterProcessor;
23
import com.meterware.httpunit.protocol.UploadFileSpec;
24

25
import java.io.IOException;
26
import java.util.Enumeration;
27
import java.util.Hashtable;
28

29
final class UncheckedParameterHolder extends ParameterHolder implements ParameterProcessor {
30

31
    private static final String[] NO_VALUES = {};
1✔
32
    private final String _characterSet;
33

34
    private Hashtable _parameters = new Hashtable<>();
1✔
35
    private boolean _submitAsMime;
36

37
    UncheckedParameterHolder() {
1✔
38
        _characterSet = HttpUnitOptions.getDefaultCharacterSet();
1✔
39
    }
1✔
40

41
    UncheckedParameterHolder(WebRequestSource source) {
1✔
42
        _characterSet = source.getCharacterSet();
1✔
43
        _submitAsMime = source.isSubmitAsMime();
1✔
44

45
        try {
46
            source.recordPredefinedParameters(this);
1✔
47
            source.recordParameters(this);
1✔
48
        } catch (IOException e) {
×
49
            throw new RuntimeException("This should never happen");
×
50
        }
1✔
51
    }
1✔
52

53
    // ----------------------------------- ParameterProcessor methods
54
    // -------------------------------------------------------
55

56
    @Override
57
    public void addParameter(String name, String value, String characterSet) throws IOException {
58
        Object[] values = (Object[]) _parameters.get(name);
1✔
59
        _parameters.put(name, HttpUnitUtils.withNewValue(values, value));
1✔
60
    }
1✔
61

62
    @Override
63
    public void addFile(String parameterName, UploadFileSpec fileSpec) throws IOException {
64
        Object[] values = (Object[]) _parameters.get(parameterName);
1✔
65
        _parameters.put(parameterName, HttpUnitUtils.withNewValue(values, fileSpec));
1✔
66
    }
1✔
67

68
    // ----------------------------------- ParameterHolder methods
69
    // ----------------------------------------------------------
70

71
    /**
72
     * Specifies the position at which an image button (if any) was clicked.
73
     **/
74
    @Override
75
    void selectImageButtonPosition(SubmitButton imageButton, int x, int y) {
76
        if (imageButton.isValidImageButton()) {
1!
77
            setParameter(imageButton.positionParameterName("x"), Integer.toString(x));
1✔
78
            setParameter(imageButton.positionParameterName("y"), Integer.toString(y));
1✔
79
        }
80
    }
1✔
81

82
    /**
83
     * Does nothing, since unchecked requests treat all parameters the same.
84
     **/
85
    @Override
86
    void recordPredefinedParameters(ParameterProcessor processor) throws IOException {
87
    }
1✔
88

89
    /**
90
     * Iterates through the parameters in this holder, recording them in the supplied parameter processor.
91
     **/
92
    @Override
93
    public void recordParameters(ParameterProcessor processor) throws IOException {
94
        Enumeration e = _parameters.keys();
1✔
95

96
        while (e.hasMoreElements()) {
1✔
97
            String name = (String) e.nextElement();
1✔
98
            Object[] values = (Object[]) _parameters.get(name);
1✔
99
            for (Object value : values) {
1✔
100
                if (value instanceof String || value == null) {
1✔
101
                    processor.addParameter(name, (String) value, _characterSet);
1✔
102
                } else if (value instanceof UploadFileSpec) {
1!
103
                    processor.addFile(name, (UploadFileSpec) value);
1✔
104
                }
105
            }
106
        }
1✔
107
    }
1✔
108

109
    @Override
110
    String[] getParameterNames() {
111
        return (String[]) _parameters.keySet().toArray(new String[_parameters.size()]);
×
112
    }
113

114
    String getParameterValue(String name) {
115
        String[] values = getParameterValues(name);
×
116
        return values.length == 0 ? null : values[0];
×
117
    }
118

119
    @Override
120
    String[] getParameterValues(String name) {
121
        Object[] values = (Object[]) _parameters.get(name);
1✔
122
        if (values == null) {
1!
123
            return NO_VALUES;
×
124
        }
125

126
        String[] result = new String[values.length];
1✔
127
        for (int i = 0; i < result.length; i++) {
1✔
128
            result[i] = values[i] instanceof UploadFileSpec ? ((UploadFileSpec) values[i]).getFileName()
1✔
129
                    : values[i].toString();
1✔
130
        }
131
        return result;
1✔
132
    }
133

134
    @Override
135
    void removeParameter(String name) {
136
        _parameters.remove(name);
×
137
    }
×
138

139
    @Override
140
    void setParameter(String name, String value) {
141
        _parameters.put(name, new Object[] { value });
1✔
142
    }
1✔
143

144
    @Override
145
    void setParameter(String name, String[] values) {
146
        _parameters.put(name, values);
1✔
147
    }
1✔
148

149
    @Override
150
    void setParameter(String name, UploadFileSpec[] files) {
151
        _parameters.put(name, files);
1✔
152
    }
1✔
153

154
    @Override
155
    boolean isFileParameter(String name) {
156
        return true;
1✔
157
    }
158

159
    @Override
160
    String getCharacterSet() {
161
        return _characterSet;
1✔
162
    }
163

164
    @Override
165
    boolean isSubmitAsMime() {
166
        return _submitAsMime;
1✔
167
    }
168
}
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