• 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

62.86
/src/main/java/com/meterware/httpunit/AppletContextImpl.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 java.applet.Applet;
23
import java.applet.AppletContext;
24
import java.applet.AudioClip;
25
import java.awt.Image;
26
import java.io.IOException;
27
import java.io.InputStream;
28
import java.net.URL;
29
import java.util.Enumeration;
30
import java.util.Iterator;
31
import java.util.Vector;
32

33
class AppletContextImpl implements AppletContext {
34

35
    private WebApplet _webApplet;
36

37
    AppletContextImpl(WebApplet webApplet) {
1✔
38
        _webApplet = webApplet;
1✔
39
    }
1✔
40

41
    /**
42
     * Creates an audio clip.
43
     *
44
     * @param url
45
     *            an absolute URL giving the location of the audio clip.
46
     *
47
     * @return the audio clip at the specified URL.
48
     */
49
    @Override
50
    public AudioClip getAudioClip(URL url) {
51
        return null;
×
52
    }
53

54
    /**
55
     * Returns an <code>Image</code> object that can then be painted on the screen. The <code>url</code>
56
     * argument<code> </code>that is passed as an argument must specify an absolute URL.
57
     * <p>
58
     * This method always returns immediately, whether or not the image exists. When the applet attempts to draw the
59
     * image on the screen, the data will be loaded. The graphics primitives that draw the image will incrementally
60
     * paint on the screen.
61
     *
62
     * @param url
63
     *            an absolute URL giving the location of the image.
64
     *
65
     * @return the image at the specified URL.
66
     *
67
     * @see Image
68
     */
69
    @Override
70
    public Image getImage(URL url) {
71
        return null;
×
72
    }
73

74
    /**
75
     * Finds and returns the applet in the document represented by this applet context with the given name. The name can
76
     * be set in the HTML tag by setting the <code>name</code> attribute.
77
     *
78
     * @param name
79
     *            an applet name.
80
     *
81
     * @return the applet with the given name, or <code>null</code> if not found.
82
     */
83
    @Override
84
    public Applet getApplet(String name) {
85
        try {
86
            WebApplet[] webApplets = _webApplet.getAppletsInPage();
1✔
87
            for (WebApplet webApplet : webApplets) {
1!
88
                if (webApplet.getName().equals(name)) {
1✔
89
                    return webApplet.getApplet();
1✔
90
                }
91
            }
92
        } catch (Exception e) {
×
93
        }
×
94
        return null;
×
95
    }
96

97
    /**
98
     * Finds all the applets in the document represented by this applet context.
99
     *
100
     * @return an enumeration of all applets in the document represented by this applet context.
101
     */
102
    @Override
103
    public Enumeration getApplets() {
104
        WebApplet[] webApplets = _webApplet.getAppletsInPage();
1✔
105
        Vector v = new Vector<>();
1✔
106
        try {
107
            for (WebApplet webApplet : webApplets) {
1✔
108
                v.add(webApplet.getApplet());
1✔
109
            }
110
        } catch (Exception e) {
×
111
            e.printStackTrace();
×
112
            throw new RuntimeException(e.toString());
×
113
        }
1✔
114
        return v.elements();
1✔
115
    }
116

117
    /**
118
     * Replaces the Web page currently being viewed with the given URL. This method may be ignored by applet contexts
119
     * that are not browsers.
120
     *
121
     * @param url
122
     *            an absolute URL giving the location of the document.
123
     */
124
    @Override
125
    public void showDocument(URL url) {
126
        showDocument(url, _webApplet.getBaseTarget());
1✔
127
    }
1✔
128

129
    /**
130
     * Requests that the browser or applet viewer show the Web page indicated by the <code>url</code> argument. The
131
     * <code>target</code> argument indicates in which HTML frame the document is to be displayed. The target argument
132
     * is interpreted as follows:
133
     * <p>
134
     * <center>
135
     * <table border="3">
136
     * <tr>
137
     * <td><code>"_self"</code>
138
     * <td>Show in the window and frame that contain the applet.
139
     * </tr>
140
     * <tr>
141
     * <td><code>"_parent"</code>
142
     * <td>Show in the applet's parent frame. If the applet's frame has no parent frame, acts the same as "_self".
143
     * </tr>
144
     * <tr>
145
     * <td><code>"_top"</code>
146
     * <td>Show in the top-level frame of the applet's window. If the applet's frame is the top-level frame, acts the
147
     * same as "_self".
148
     * </tr>
149
     * <tr>
150
     * <td><code>"_blank"</code>
151
     * <td>Show in a new, unnamed top-level window.
152
     * </tr>
153
     * <tr>
154
     * <td><i>name</i>
155
     * <td>Show in the frame or window named <i>name</i>. If a target named <i>name</i> does not already exist, a new
156
     * top-level window with the specified name is created, and the document is shown there.
157
     * </tr>
158
     * </table>
159
     * </center>
160
     * <p>
161
     * An applet viewer or browser is free to ignore <code>showDocument</code>.
162
     *
163
     * @param url
164
     *            an absolute URL giving the location of the document.
165
     * @param target
166
     *            a <code>String</code> indicating where to display the page.
167
     */
168
    @Override
169
    public void showDocument(URL url, String target) {
170
        _webApplet.sendRequest(url, target);
1✔
171
    }
1✔
172

173
    /**
174
     * Requests that the argument string be displayed in the "status window". Many browsers and applet viewers provide
175
     * such a window, where the application can inform users of its current state.
176
     *
177
     * @param status
178
     *            a string to display in the status window.
179
     */
180
    @Override
181
    public void showStatus(String status) {
182
    }
×
183

184
    /**
185
     * Returns the stream to which specified key is associated within this applet context. Returns <tt>null</tt> if the
186
     * applet context contains no stream for this key.
187
     * <p>
188
     * For security reasons, mapping of streams and keys exists for each codebase. In other words, applet from one
189
     * codebase cannot access the streams created by an applet from a different codebase
190
     * <p>
191
     *
192
     * @return the stream to which this applet context maps the key
193
     *
194
     * @param key
195
     *            key whose associated stream is to be returned.
196
     */
197
    @Override
198
    public InputStream getStream(String key) {
199
        return null;
×
200
    }
201

202
    /**
203
     * Finds all the keys of the streams in this applet context.
204
     * <p>
205
     * For security reasons, mapping of streams and keys exists for each codebase. In other words, applet from one
206
     * codebase cannot access the streams created by an applet from a different codebase
207
     * <p>
208
     *
209
     * @return an Iterator of all the names of the streams in this applet context.
210
     */
211
    @Override
212
    public Iterator getStreamKeys() {
213
        return null;
×
214
    }
215

216
    /**
217
     * Associates the specified stream with the specified key in this applet context. If the applet context previously
218
     * contained a mapping for this key, the old value is replaced.
219
     * <p>
220
     * For security reasons, mapping of streams and keys exists for each codebase. In other words, applet from one
221
     * codebase cannot access the streams created by an applet from a different codebase
222
     * <p>
223
     *
224
     * @param key
225
     *            key with which the specified value is to be associated.
226
     * @param stream
227
     *            stream to be associated with the specified key. If this parameter is
228
     *            <code>null<code>, the specified key is removed
229
     *               in this applet context.
230
     * @throws <code>IOException</code>
231
     *            if the stream size exceeds a certain size limit. Size limit is decided by the implementor of this
232
     *            interface.
233
     */
234
    @Override
235
    public void setStream(String key, InputStream stream) throws IOException {
236
    }
×
237
}
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