• 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

84.04
/src/main/java/com/meterware/httpunit/ClientProperties.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
/**
23
 * A class which represents the properties of a web client.
24
 **/
25
public class ClientProperties {
26

27
    /**
28
     * Returns the current defaults for newly created web clients.
29
     */
30
    public static ClientProperties getDefaultProperties() {
31
        return _defaultProperties;
1✔
32
    }
33

34
    /**
35
     * Specifies the ID information for a client.
36
     */
37
    public void setApplicationID(String applicationName, String applicationCodeName, String applicationVersion) {
38
        _applicationCodeName = applicationCodeName;
1✔
39
        _applicationName = applicationName;
1✔
40
        _applicationVersion = applicationVersion;
1✔
41
    }
1✔
42

43
    public String getApplicationCodeName() {
44
        return _applicationCodeName;
1✔
45
    }
46

47
    public void setApplicationCodeName(String applicationCodeName) {
48
        _applicationCodeName = applicationCodeName;
×
49
    }
×
50

51
    public String getApplicationName() {
52
        return _applicationName;
1✔
53
    }
54

55
    public void setApplicationName(String applicationName) {
56
        _applicationName = applicationName;
×
57
    }
×
58

59
    public String getApplicationVersion() {
60
        return _applicationVersion;
1✔
61
    }
62

63
    public void setApplicationVersion(String applicationVersion) {
64
        _applicationVersion = applicationVersion;
×
65
    }
×
66

67
    /**
68
     * Returns the user agent identification. Unless this has been set explicitly, it will default to the application
69
     * code name followed by a slash and the application version.
70
     */
71
    public String getUserAgent() {
72
        return _userAgent != null ? _userAgent : _applicationCodeName + '/' + _applicationVersion;
1✔
73
    }
74

75
    public void setUserAgent(String userAgent) {
76
        _userAgent = userAgent;
1✔
77
    }
1✔
78

79
    public String getPlatform() {
80
        return _platform;
1✔
81
    }
82

83
    public void setPlatform(String platform) {
84
        _platform = platform;
1✔
85
    }
1✔
86

87
    /**
88
     * A shortcut for setting both availableScreenWidth and availableScreenHeight at one time.
89
     */
90
    public void setAvailableScreenSize(int width, int height) {
91
        _availWidth = width;
1✔
92
        _availHeight = height;
1✔
93
    }
1✔
94

95
    public int getAvailableScreenWidth() {
96
        return _availWidth;
1✔
97
    }
98

99
    public void setAvailableScreenWidth(int availWidth) {
100
        _availWidth = availWidth;
×
101
    }
×
102

103
    public int getAvailHeight() {
104
        return _availHeight;
1✔
105
    }
106

107
    public void setAvailHeight(int availHeight) {
108
        _availHeight = availHeight;
×
109
    }
×
110

111
    /**
112
     * Returns true if the client should accept and transmit cookies. The default is to accept them.
113
     */
114
    public boolean isAcceptCookies() {
115
        return _acceptCookies;
1✔
116
    }
117

118
    /**
119
     * Specifies whether the client should accept and send cookies.
120
     */
121
    public void setAcceptCookies(boolean acceptCookies) {
122
        _acceptCookies = acceptCookies;
1✔
123
    }
1✔
124

125
    /**
126
     * Returns true if the client will accept GZIP encoding of responses. The default is to accept GZIP encoding.
127
     **/
128
    public boolean isAcceptGzip() {
129
        return _acceptGzip;
1✔
130
    }
131

132
    /**
133
     * Specifies whether the client will accept GZIP encoded responses. The default is true.
134
     */
135
    public void setAcceptGzip(boolean acceptGzip) {
136
        _acceptGzip = acceptGzip;
1✔
137
    }
1✔
138

139
    /**
140
     * get Maximum number of redirect requests
141
     *
142
     * @return it
143
     */
144
    public int getMaxRedirects() {
145
        return _maxRedirects;
1✔
146
    }
147

148
    /**
149
     * set the maximum number of redirects
150
     *
151
     * @param maxRedirects
152
     */
153
    public void setMaxRedirects(int maxRedirects) {
154
        _maxRedirects = maxRedirects;
1✔
155
    }
1✔
156

157
    /**
158
     * Returns true if the client should automatically follow page redirect requests (status 3xx). By default, this is
159
     * true.
160
     **/
161
    public boolean isAutoRedirect() {
162
        return _autoRedirect;
1✔
163
    }
164

165
    /**
166
     * Determines whether the client should automatically follow page redirect requests (status 3xx). By default, this
167
     * is true in order to simulate normal browser operation.
168
     **/
169
    public void setAutoRedirect(boolean autoRedirect) {
170
        _autoRedirect = autoRedirect;
1✔
171
    }
1✔
172

173
    /**
174
     * Returns true if the client should automatically follow page refresh requests. By default, this is false, so that
175
     * programs can verify the redirect page presented to users before the browser switches to the new page.
176
     **/
177
    public boolean isAutoRefresh() {
178
        return _autoRefresh;
1✔
179
    }
180

181
    /**
182
     * Specifies whether the client should automatically follow page refresh requests. By default, this is false, so
183
     * that programs can verify the redirect page presented to users before the browser switches to the new page.
184
     * Setting this to true can cause an infinite loop on pages that refresh themselves.
185
     **/
186
    public void setAutoRefresh(boolean autoRefresh) {
187
        _autoRefresh = autoRefresh;
1✔
188
    }
1✔
189

190
    public boolean isIframeSupported() {
191
        return _iframeSupported;
1✔
192
    }
193

194
    public void setIframeSupported(boolean iframeSupported) {
195
        _iframeSupported = iframeSupported;
×
196
    }
×
197

198
    /**
199
     * @deprecated since 1.8 see BR 2595566 - name of getter is a typo
200
     *
201
     * @see getOverrideContentType
202
     *
203
     * @return the overriding content type
204
     */
205
    @Deprecated
206
    public String getOverrideContextType() {
207
        return getOverrideContentType();
×
208
    }
209

210
    /**
211
     * @deprecated since 1.8 see BR 2595566 - name of setter is a typo
212
     *
213
     * @param overrideContentType
214
     *            the content type
215
     *
216
     * @see setOverrideContentType
217
     */
218
    @Deprecated
219
    public void setOverrideContextType(String overrideContentType) {
220
        setOverrideContentType(overrideContentType);
1✔
221
    }
1✔
222

223
    /**
224
     * Returns the content type (if any) to use instead of the one specified by the server. Defaults to null.
225
     *
226
     * @return the overriding content type, or null if none is specified.
227
     */
228
    public String getOverrideContentType() {
229
        return _overrideContentType;
1✔
230
    }
231

232
    /**
233
     * All responses to this client will use the specified content type rather than the one specified by the server.
234
     * Setting this to "text/html" will force all reponses to be interpreted as HTML.
235
     *
236
     * @param overrideContentType
237
     *            the new override to apply to context types.
238
     */
239
    public void setOverrideContentType(String overrideContentType) {
240
        _overrideContentType = overrideContentType;
1✔
241
    }
1✔
242

243
    /**
244
     * Specifies a listener for DNS requests from the client.
245
     *
246
     * @param dnsListener
247
     *            the new listener.
248
     */
249
    public void setDnsListener(DNSListener dnsListener) {
250
        _dnsListener = dnsListener;
×
251
    }
×
252

253
    /**
254
     * Returns the listener for DNS requests to be used by the client.
255
     *
256
     * @return the currently specified DNS listener, or null if none is specified.
257
     */
258
    DNSListener getDnsListener() {
259
        return _dnsListener;
1✔
260
    }
261

262
    /**
263
     * @return the whether Referer information should be stripped from the header
264
     */
265
    public boolean isSendReferer() {
266
        return _sendReferer;
1✔
267
    }
268

269
    /**
270
     * set whether Referer information should be stripped
271
     *
272
     * @param referer
273
     *            the _sendReferer to set
274
     */
275
    public void setSendReferer(boolean referer) {
276
        _sendReferer = referer;
1✔
277
    }
1✔
278

279
    ClientProperties cloneProperties() {
280
        return new ClientProperties(this);
1✔
281
    }
282

283
    private String _applicationCodeName = "httpunit";
1✔
284
    private String _applicationName = "HttpUnit";
1✔
285
    private String _applicationVersion = "1.5";
1✔
286
    private String _userAgent;
287
    private String _platform = "Java";
1✔
288
    private String _overrideContentType = null;
1✔
289
    private int _availWidth = 800;
1✔
290
    private int _availHeight = 600;
1✔
291
    private int _maxRedirects = 5;
1✔
292

293
    private boolean _iframeSupported = true;
1✔
294
    private boolean _acceptCookies = true;
1✔
295
    private boolean _acceptGzip = true;
1✔
296
    private boolean _autoRedirect = true;
1✔
297
    private boolean _autoRefresh = false;
1✔
298

299
    private DNSListener _dnsListener;
300
    private boolean _sendReferer;
301

302
    private static ClientProperties _defaultProperties = new ClientProperties();
1✔
303

304
    /**
305
     * default Constructor
306
     */
307
    private ClientProperties() {
1✔
308
        _sendReferer = true;
1✔
309
    }
1✔
310

311
    /**
312
     * copy constructor
313
     *
314
     * @param source
315
     *            - the ClientProperties to copy from
316
     */
317
    private ClientProperties(ClientProperties source) {
1✔
318
        _applicationCodeName = source._applicationCodeName;
1✔
319
        _applicationName = source._applicationName;
1✔
320
        _applicationVersion = source._applicationVersion;
1✔
321
        _userAgent = source._userAgent;
1✔
322
        _platform = source._platform;
1✔
323
        _overrideContentType = source._overrideContentType;
1✔
324
        _iframeSupported = source._iframeSupported;
1✔
325
        _acceptCookies = source._acceptCookies;
1✔
326
        _acceptGzip = source._acceptGzip;
1✔
327
        _autoRedirect = source._autoRedirect;
1✔
328
        _autoRefresh = source._autoRefresh;
1✔
329
        _sendReferer = source._sendReferer;
1✔
330
        _maxRedirects = source._maxRedirects;
1✔
331
    }
1✔
332

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