• 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

79.03
/src/main/java/com/meterware/httpunit/dom/HTMLAnchorElementImpl.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.net.MalformedURLException;
23
import java.net.URL;
24

25
import org.w3c.dom.html.HTMLAnchorElement;
26

27
/**
28
 * The Class HTMLAnchorElementImpl.
29
 */
30
public class HTMLAnchorElementImpl extends HTMLElementImpl implements HTMLAnchorElement {
1✔
31

32
    /** The Constant serialVersionUID. */
33
    private static final long serialVersionUID = 1L;
34

35
    @Override
36
    ElementImpl create() {
37
        return new HTMLAnchorElementImpl();
1✔
38
    }
39

40
    /**
41
     * Gets the charset.
42
     *
43
     * @return the charset
44
     */
45
    @Override
46
    public String getCharset() {
47
        return getAttributeWithNoDefault("charset");
1✔
48
    }
49

50
    /**
51
     * Gets the href.
52
     *
53
     * @return the href
54
     */
55
    @Override
56
    public String getHref() {
57
        String relativeLocation = getAttributeWithNoDefault("href");
1✔
58
        if (relativeLocation.indexOf(':') > 0 || relativeLocation.equals("#")) {
1✔
59
            return relativeLocation;
1✔
60
        }
61
        try {
62
            return new URL(((HTMLDocumentImpl) getOwnerDocument()).getBaseUrl(), relativeLocation).toExternalForm();
1✔
63
        } catch (MalformedURLException e) {
×
64
            return e.toString();
×
65
        }
66
    }
67

68
    /**
69
     * Gets the hreflang.
70
     *
71
     * @return the hreflang
72
     */
73
    @Override
74
    public String getHreflang() {
75
        return getAttributeWithNoDefault("hreflang");
1✔
76
    }
77

78
    /**
79
     * Gets the rel.
80
     *
81
     * @return the rel
82
     */
83
    @Override
84
    public String getRel() {
85
        return getAttributeWithNoDefault("rel");
1✔
86
    }
87

88
    /**
89
     * Gets the rev.
90
     *
91
     * @return the rev
92
     */
93
    @Override
94
    public String getRev() {
95
        return getAttributeWithNoDefault("rev");
1✔
96
    }
97

98
    /**
99
     * Gets the target.
100
     *
101
     * @return the target
102
     */
103
    @Override
104
    public String getTarget() {
105
        return getAttributeWithNoDefault("target");
1✔
106
    }
107

108
    /**
109
     * Gets the type.
110
     *
111
     * @return the type
112
     */
113
    @Override
114
    public String getType() {
115
        return getAttributeWithNoDefault("type");
1✔
116
    }
117

118
    /**
119
     * Sets the charset.
120
     *
121
     * @param charset
122
     *            the new charset
123
     */
124
    @Override
125
    public void setCharset(String charset) {
126
        setAttribute("charset", charset);
1✔
127
    }
1✔
128

129
    /**
130
     * Sets the href.
131
     *
132
     * @param href
133
     *            the new href
134
     */
135
    @Override
136
    public void setHref(String href) {
137
        setAttribute("href", href);
1✔
138
    }
1✔
139

140
    /**
141
     * Sets the hreflang.
142
     *
143
     * @param hreflang
144
     *            the new hreflang
145
     */
146
    @Override
147
    public void setHreflang(String hreflang) {
148
        setAttribute("hreflang", hreflang);
1✔
149
    }
1✔
150

151
    /**
152
     * Sets the rel.
153
     *
154
     * @param rel
155
     *            the new rel
156
     */
157
    @Override
158
    public void setRel(String rel) {
159
        setAttribute("rel", rel);
1✔
160
    }
1✔
161

162
    /**
163
     * Sets the rev.
164
     *
165
     * @param rev
166
     *            the new rev
167
     */
168
    @Override
169
    public void setRev(String rev) {
170
        setAttribute("rev", rev);
1✔
171
    }
1✔
172

173
    /**
174
     * Sets the target.
175
     *
176
     * @param target
177
     *            the new target
178
     */
179
    @Override
180
    public void setTarget(String target) {
181
        setAttribute("target", target);
1✔
182
    }
1✔
183

184
    /**
185
     * Sets the type.
186
     *
187
     * @param type
188
     *            the new type
189
     */
190
    @Override
191
    public void setType(String type) {
192
        setAttribute("type", type);
1✔
193
    }
1✔
194

195
    /**
196
     * simulate blur.
197
     */
198
    @Override
199
    public void blur() {
200
        handleEvent("onblur");
×
201
    }
×
202

203
    /**
204
     * simulate focus;.
205
     */
206
    @Override
207
    public void focus() {
208
        handleEvent("onfocus");
×
209
    }
×
210

211
    /**
212
     * Gets the access key.
213
     *
214
     * @return the access key
215
     */
216
    @Override
217
    public String getAccessKey() {
218
        return getAttributeWithNoDefault("accesskey");
1✔
219
    }
220

221
    /**
222
     * Gets the coords.
223
     *
224
     * @return the coords
225
     */
226
    @Override
227
    public String getCoords() {
228
        return getAttributeWithNoDefault("coords");
×
229
    }
230

231
    /**
232
     * Gets the name.
233
     *
234
     * @return the name
235
     */
236
    @Override
237
    public String getName() {
238
        return getAttributeWithNoDefault("name");
1✔
239
    }
240

241
    /**
242
     * Gets the shape.
243
     *
244
     * @return the shape
245
     */
246
    @Override
247
    public String getShape() {
248
        return getAttributeWithNoDefault("shape");
×
249
    }
250

251
    /**
252
     * Gets the tab index.
253
     *
254
     * @return the tab index
255
     */
256
    @Override
257
    public int getTabIndex() {
258
        return getIntegerAttribute("tabindex");
1✔
259
    }
260

261
    /**
262
     * Sets the access key.
263
     *
264
     * @param accessKey
265
     *            the new access key
266
     */
267
    @Override
268
    public void setAccessKey(String accessKey) {
269
        setAttribute("accesskey", accessKey);
1✔
270
    }
1✔
271

272
    /**
273
     * Sets the coords.
274
     *
275
     * @param coords
276
     *            the new coords
277
     */
278
    @Override
279
    public void setCoords(String coords) {
280
        setAttribute("coords", coords);
×
281
    }
×
282

283
    /**
284
     * Sets the name.
285
     *
286
     * @param name
287
     *            the new name
288
     */
289
    @Override
290
    public void setName(String name) {
291
        setAttribute("name", name);
1✔
292
    }
1✔
293

294
    /**
295
     * Sets the shape.
296
     *
297
     * @param shape
298
     *            the new shape
299
     */
300
    @Override
301
    public void setShape(String shape) {
302
        setAttribute("shape", shape);
×
303
    }
×
304

305
    /**
306
     * Sets the tab index.
307
     *
308
     * @param tabIndex
309
     *            the new tab index
310
     */
311
    @Override
312
    public void setTabIndex(int tabIndex) {
313
        setAttribute("tabindex", tabIndex);
1✔
314
    }
1✔
315

316
    @Override
317
    public void doClickAction() {
318
        if (null == getHref() || getHref().startsWith("#")) {
1!
319
            return;
1✔
320
        }
321
        try {
322
            ((HTMLDocumentImpl) getOwnerDocument()).getWindow().submitRequest(this, "GET", getHref(), getTarget(),
1✔
323
                    new byte[0]);
324
        } catch (Exception e) {
1✔
325
            throw new RuntimeException("Error clicking link: " + e);
1✔
326
        }
1✔
327
    }
1✔
328
}
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