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

hazendaz / httpunit / 656

06 Dec 2025 09:11PM UTC coverage: 80.452% (+0.02%) from 80.435%
656

push

github

hazendaz
[maven-release-plugin] prepare for next development iteration

3213 of 4105 branches covered (78.27%)

Branch coverage included in aggregate %.

8245 of 10137 relevant lines covered (81.34%)

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
     * @return the default properties
31
     */
32
    public static ClientProperties getDefaultProperties() {
33
        return _defaultProperties;
1✔
34
    }
35

36
    /**
37
     * Specifies the ID information for a client.
38
     *
39
     * @param applicationName
40
     *            the application name
41
     * @param applicationCodeName
42
     *            the application code name
43
     * @param applicationVersion
44
     *            the application version
45
     */
46
    public void setApplicationID(String applicationName, String applicationCodeName, String applicationVersion) {
47
        _applicationCodeName = applicationCodeName;
1✔
48
        _applicationName = applicationName;
1✔
49
        _applicationVersion = applicationVersion;
1✔
50
    }
1✔
51

52
    /**
53
     * Gets the application code name.
54
     *
55
     * @return the application code name
56
     */
57
    public String getApplicationCodeName() {
58
        return _applicationCodeName;
1✔
59
    }
60

61
    /**
62
     * Sets the application code name.
63
     *
64
     * @param applicationCodeName
65
     *            the new application code name
66
     */
67
    public void setApplicationCodeName(String applicationCodeName) {
68
        _applicationCodeName = applicationCodeName;
×
69
    }
×
70

71
    /**
72
     * Gets the application name.
73
     *
74
     * @return the application name
75
     */
76
    public String getApplicationName() {
77
        return _applicationName;
1✔
78
    }
79

80
    /**
81
     * Sets the application name.
82
     *
83
     * @param applicationName
84
     *            the new application name
85
     */
86
    public void setApplicationName(String applicationName) {
87
        _applicationName = applicationName;
×
88
    }
×
89

90
    /**
91
     * Gets the application version.
92
     *
93
     * @return the application version
94
     */
95
    public String getApplicationVersion() {
96
        return _applicationVersion;
1✔
97
    }
98

99
    /**
100
     * Sets the application version.
101
     *
102
     * @param applicationVersion
103
     *            the new application version
104
     */
105
    public void setApplicationVersion(String applicationVersion) {
106
        _applicationVersion = applicationVersion;
×
107
    }
×
108

109
    /**
110
     * Returns the user agent identification. Unless this has been set explicitly, it will default to the application
111
     * code name followed by a slash and the application version.
112
     *
113
     * @return the user agent
114
     */
115
    public String getUserAgent() {
116
        return _userAgent != null ? _userAgent : _applicationCodeName + '/' + _applicationVersion;
1✔
117
    }
118

119
    /**
120
     * Sets the user agent.
121
     *
122
     * @param userAgent
123
     *            the new user agent
124
     */
125
    public void setUserAgent(String userAgent) {
126
        _userAgent = userAgent;
1✔
127
    }
1✔
128

129
    /**
130
     * Gets the platform.
131
     *
132
     * @return the platform
133
     */
134
    public String getPlatform() {
135
        return _platform;
1✔
136
    }
137

138
    /**
139
     * Sets the platform.
140
     *
141
     * @param platform
142
     *            the new platform
143
     */
144
    public void setPlatform(String platform) {
145
        _platform = platform;
1✔
146
    }
1✔
147

148
    /**
149
     * A shortcut for setting both availableScreenWidth and availableScreenHeight at one time.
150
     *
151
     * @param width
152
     *            the width
153
     * @param height
154
     *            the height
155
     */
156
    public void setAvailableScreenSize(int width, int height) {
157
        _availWidth = width;
1✔
158
        _availHeight = height;
1✔
159
    }
1✔
160

161
    /**
162
     * Gets the available screen width.
163
     *
164
     * @return the available screen width
165
     */
166
    public int getAvailableScreenWidth() {
167
        return _availWidth;
1✔
168
    }
169

170
    /**
171
     * Sets the available screen width.
172
     *
173
     * @param availWidth
174
     *            the new available screen width
175
     */
176
    public void setAvailableScreenWidth(int availWidth) {
177
        _availWidth = availWidth;
×
178
    }
×
179

180
    /**
181
     * Gets the avail height.
182
     *
183
     * @return the avail height
184
     */
185
    public int getAvailHeight() {
186
        return _availHeight;
1✔
187
    }
188

189
    /**
190
     * Sets the avail height.
191
     *
192
     * @param availHeight
193
     *            the new avail height
194
     */
195
    public void setAvailHeight(int availHeight) {
196
        _availHeight = availHeight;
×
197
    }
×
198

199
    /**
200
     * Returns true if the client should accept and transmit cookies. The default is to accept them.
201
     *
202
     * @return true, if is accept cookies
203
     */
204
    public boolean isAcceptCookies() {
205
        return _acceptCookies;
1✔
206
    }
207

208
    /**
209
     * Specifies whether the client should accept and send cookies.
210
     *
211
     * @param acceptCookies
212
     *            the new accept cookies
213
     */
214
    public void setAcceptCookies(boolean acceptCookies) {
215
        _acceptCookies = acceptCookies;
1✔
216
    }
1✔
217

218
    /**
219
     * Returns true if the client will accept GZIP encoding of responses. The default is to accept GZIP encoding.
220
     *
221
     * @return true, if is accept gzip
222
     */
223
    public boolean isAcceptGzip() {
224
        return _acceptGzip;
1✔
225
    }
226

227
    /**
228
     * Specifies whether the client will accept GZIP encoded responses. The default is true.
229
     *
230
     * @param acceptGzip
231
     *            the new accept gzip
232
     */
233
    public void setAcceptGzip(boolean acceptGzip) {
234
        _acceptGzip = acceptGzip;
1✔
235
    }
1✔
236

237
    /**
238
     * get Maximum number of redirect requests.
239
     *
240
     * @return it
241
     */
242
    public int getMaxRedirects() {
243
        return _maxRedirects;
1✔
244
    }
245

246
    /**
247
     * set the maximum number of redirects.
248
     *
249
     * @param maxRedirects
250
     *            the new max redirects
251
     */
252
    public void setMaxRedirects(int maxRedirects) {
253
        _maxRedirects = maxRedirects;
1✔
254
    }
1✔
255

256
    /**
257
     * Returns true if the client should automatically follow page redirect requests (status 3xx). By default, this is
258
     * true.
259
     *
260
     * @return true, if is auto redirect
261
     */
262
    public boolean isAutoRedirect() {
263
        return _autoRedirect;
1✔
264
    }
265

266
    /**
267
     * Determines whether the client should automatically follow page redirect requests (status 3xx). By default, this
268
     * is true in order to simulate normal browser operation.
269
     *
270
     * @param autoRedirect
271
     *            the new auto redirect
272
     */
273
    public void setAutoRedirect(boolean autoRedirect) {
274
        _autoRedirect = autoRedirect;
1✔
275
    }
1✔
276

277
    /**
278
     * Returns true if the client should automatically follow page refresh requests. By default, this is false, so that
279
     * programs can verify the redirect page presented to users before the browser switches to the new page.
280
     *
281
     * @return true, if is auto refresh
282
     */
283
    public boolean isAutoRefresh() {
284
        return _autoRefresh;
1✔
285
    }
286

287
    /**
288
     * Specifies whether the client should automatically follow page refresh requests. By default, this is false, so
289
     * that programs can verify the redirect page presented to users before the browser switches to the new page.
290
     * Setting this to true can cause an infinite loop on pages that refresh themselves.
291
     *
292
     * @param autoRefresh
293
     *            the new auto refresh
294
     */
295
    public void setAutoRefresh(boolean autoRefresh) {
296
        _autoRefresh = autoRefresh;
1✔
297
    }
1✔
298

299
    /**
300
     * Checks if is iframe supported.
301
     *
302
     * @return true, if is iframe supported
303
     */
304
    public boolean isIframeSupported() {
305
        return _iframeSupported;
1✔
306
    }
307

308
    /**
309
     * Sets the iframe supported.
310
     *
311
     * @param iframeSupported
312
     *            the new iframe supported
313
     */
314
    public void setIframeSupported(boolean iframeSupported) {
315
        _iframeSupported = iframeSupported;
×
316
    }
×
317

318
    /**
319
     * Gets the override context type.
320
     *
321
     * @return the overriding content type
322
     *
323
     * @see getOverrideContentType
324
     *
325
     * @deprecated since 1.8 see BR 2595566 - name of getter is a typo
326
     */
327
    @Deprecated
328
    public String getOverrideContextType() {
329
        return getOverrideContentType();
×
330
    }
331

332
    /**
333
     * Sets the override context type.
334
     *
335
     * @param overrideContentType
336
     *            the content type
337
     *
338
     * @see setOverrideContentType
339
     *
340
     * @deprecated since 1.8 see BR 2595566 - name of setter is a typo
341
     */
342
    @Deprecated
343
    public void setOverrideContextType(String overrideContentType) {
344
        setOverrideContentType(overrideContentType);
1✔
345
    }
1✔
346

347
    /**
348
     * Returns the content type (if any) to use instead of the one specified by the server. Defaults to null.
349
     *
350
     * @return the overriding content type, or null if none is specified.
351
     */
352
    public String getOverrideContentType() {
353
        return _overrideContentType;
1✔
354
    }
355

356
    /**
357
     * All responses to this client will use the specified content type rather than the one specified by the server.
358
     * Setting this to "text/html" will force all reponses to be interpreted as HTML.
359
     *
360
     * @param overrideContentType
361
     *            the new override to apply to context types.
362
     */
363
    public void setOverrideContentType(String overrideContentType) {
364
        _overrideContentType = overrideContentType;
1✔
365
    }
1✔
366

367
    /**
368
     * Specifies a listener for DNS requests from the client.
369
     *
370
     * @param dnsListener
371
     *            the new listener.
372
     */
373
    public void setDnsListener(DNSListener dnsListener) {
374
        _dnsListener = dnsListener;
×
375
    }
×
376

377
    /**
378
     * Returns the listener for DNS requests to be used by the client.
379
     *
380
     * @return the currently specified DNS listener, or null if none is specified.
381
     */
382
    DNSListener getDnsListener() {
383
        return _dnsListener;
1✔
384
    }
385

386
    /**
387
     * Checks if is send referer.
388
     *
389
     * @return the whether Referer information should be stripped from the header
390
     */
391
    public boolean isSendReferer() {
392
        return _sendReferer;
1✔
393
    }
394

395
    /**
396
     * set whether Referer information should be stripped.
397
     *
398
     * @param referer
399
     *            the _sendReferer to set
400
     */
401
    public void setSendReferer(boolean referer) {
402
        _sendReferer = referer;
1✔
403
    }
1✔
404

405
    /**
406
     * Clone properties.
407
     *
408
     * @return the client properties
409
     */
410
    ClientProperties cloneProperties() {
411
        return new ClientProperties(this);
1✔
412
    }
413

414
    /** The application code name. */
415
    private String _applicationCodeName = "httpunit";
1✔
416

417
    /** The application name. */
418
    private String _applicationName = "HttpUnit";
1✔
419

420
    /** The application version. */
421
    private String _applicationVersion = "1.5";
1✔
422

423
    /** The user agent. */
424
    private String _userAgent;
425

426
    /** The platform. */
427
    private String _platform = "Java";
1✔
428

429
    /** The override content type. */
430
    private String _overrideContentType = null;
1✔
431

432
    /** The avail width. */
433
    private int _availWidth = 800;
1✔
434

435
    /** The avail height. */
436
    private int _availHeight = 600;
1✔
437

438
    /** The max redirects. */
439
    private int _maxRedirects = 5;
1✔
440

441
    /** The iframe supported. */
442
    private boolean _iframeSupported = true;
1✔
443

444
    /** The accept cookies. */
445
    private boolean _acceptCookies = true;
1✔
446

447
    /** The accept gzip. */
448
    private boolean _acceptGzip = true;
1✔
449

450
    /** The auto redirect. */
451
    private boolean _autoRedirect = true;
1✔
452

453
    /** The auto refresh. */
454
    private boolean _autoRefresh = false;
1✔
455

456
    /** The dns listener. */
457
    private DNSListener _dnsListener;
458

459
    /** The send referer. */
460
    private boolean _sendReferer;
461

462
    /** The default properties. */
463
    private static ClientProperties _defaultProperties = new ClientProperties();
1✔
464

465
    /**
466
     * default Constructor.
467
     */
468
    private ClientProperties() {
1✔
469
        _sendReferer = true;
1✔
470
    }
1✔
471

472
    /**
473
     * copy constructor.
474
     *
475
     * @param source
476
     *            - the ClientProperties to copy from
477
     */
478
    private ClientProperties(ClientProperties source) {
1✔
479
        _applicationCodeName = source._applicationCodeName;
1✔
480
        _applicationName = source._applicationName;
1✔
481
        _applicationVersion = source._applicationVersion;
1✔
482
        _userAgent = source._userAgent;
1✔
483
        _platform = source._platform;
1✔
484
        _overrideContentType = source._overrideContentType;
1✔
485
        _iframeSupported = source._iframeSupported;
1✔
486
        _acceptCookies = source._acceptCookies;
1✔
487
        _acceptGzip = source._acceptGzip;
1✔
488
        _autoRedirect = source._autoRedirect;
1✔
489
        _autoRefresh = source._autoRefresh;
1✔
490
        _sendReferer = source._sendReferer;
1✔
491
        _maxRedirects = source._maxRedirects;
1✔
492
    }
1✔
493

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