• 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

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.ArrayList;
30
import java.util.Collections;
31
import java.util.Enumeration;
32
import java.util.Iterator;
33
import java.util.List;
34

35
/**
36
 * The Class AppletContextImpl.
37
 */
38
class AppletContextImpl implements AppletContext {
39

40
    /** The web applet. */
41
    private WebApplet _webApplet;
42

43
    /**
44
     * Instantiates a new applet context impl.
45
     *
46
     * @param webApplet
47
     *            the web applet
48
     */
49
    AppletContextImpl(WebApplet webApplet) {
1✔
50
        _webApplet = webApplet;
1✔
51
    }
1✔
52

53
    /**
54
     * Creates an audio clip.
55
     *
56
     * @param url
57
     *            an absolute URL giving the location of the audio clip.
58
     *
59
     * @return the audio clip at the specified URL.
60
     */
61
    @Override
62
    public AudioClip getAudioClip(URL url) {
63
        return null;
×
64
    }
65

66
    /**
67
     * Returns an <code>Image</code> object that can then be painted on the screen. The <code>url</code>
68
     * argument<code> </code>that is passed as an argument must specify an absolute URL.
69
     * <p>
70
     * This method always returns immediately, whether or not the image exists. When the applet attempts to draw the
71
     * image on the screen, the data will be loaded. The graphics primitives that draw the image will incrementally
72
     * paint on the screen.
73
     *
74
     * @param url
75
     *            an absolute URL giving the location of the image.
76
     *
77
     * @return the image at the specified URL.
78
     *
79
     * @see Image
80
     */
81
    @Override
82
    public Image getImage(URL url) {
83
        return null;
×
84
    }
85

86
    /**
87
     * Finds and returns the applet in the document represented by this applet context with the given name. The name can
88
     * be set in the HTML tag by setting the <code>name</code> attribute.
89
     *
90
     * @param name
91
     *            an applet name.
92
     *
93
     * @return the applet with the given name, or <code>null</code> if not found.
94
     */
95
    @Override
96
    public Applet getApplet(String name) {
97
        try {
98
            WebApplet[] webApplets = _webApplet.getAppletsInPage();
1✔
99
            for (WebApplet webApplet : webApplets) {
1!
100
                if (webApplet.getName().equals(name)) {
1✔
101
                    return webApplet.getApplet();
1✔
102
                }
103
            }
104
        } catch (Exception e) {
×
105
        }
×
106
        return null;
×
107
    }
108

109
    /**
110
     * Finds all the applets in the document represented by this applet context.
111
     *
112
     * @return an enumeration of all applets in the document represented by this applet context.
113
     */
114
    @Override
115
    public Enumeration getApplets() {
116
        WebApplet[] webApplets = _webApplet.getAppletsInPage();
1✔
117
        List v = new ArrayList<>();
1✔
118
        try {
119
            for (WebApplet webApplet : webApplets) {
1✔
120
                v.add(webApplet.getApplet());
1✔
121
            }
122
        } catch (Exception e) {
×
123
            e.printStackTrace();
×
124
            throw new RuntimeException(e.toString());
×
125
        }
1✔
126
        return Collections.enumeration(v);
1✔
127
    }
128

129
    /**
130
     * Replaces the Web page currently being viewed with the given URL. This method may be ignored by applet contexts
131
     * that are not browsers.
132
     *
133
     * @param url
134
     *            an absolute URL giving the location of the document.
135
     */
136
    @Override
137
    public void showDocument(URL url) {
138
        showDocument(url, _webApplet.getBaseTarget());
1✔
139
    }
1✔
140

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

185
    /**
186
     * Requests that the argument string be displayed in the "status window". Many browsers and applet viewers provide
187
     * such a window, where the application can inform users of its current state.
188
     *
189
     * @param status
190
     *            a string to display in the status window.
191
     */
192
    @Override
193
    public void showStatus(String status) {
194
    }
×
195

196
    /**
197
     * Returns the stream to which specified key is associated within this applet context. Returns <tt>null</tt> if the
198
     * applet context contains no stream for this key.
199
     * <p>
200
     * For security reasons, mapping of streams and keys exists for each codebase. In other words, applet from one
201
     * codebase cannot access the streams created by an applet from a different codebase
202
     * <p>
203
     *
204
     * @return the stream to which this applet context maps the key
205
     *
206
     * @param key
207
     *            key whose associated stream is to be returned.
208
     */
209
    @Override
210
    public InputStream getStream(String key) {
211
        return null;
×
212
    }
213

214
    /**
215
     * Finds all the keys of the streams in this applet context.
216
     * <p>
217
     * For security reasons, mapping of streams and keys exists for each codebase. In other words, applet from one
218
     * codebase cannot access the streams created by an applet from a different codebase
219
     * <p>
220
     *
221
     * @return an Iterator of all the names of the streams in this applet context.
222
     */
223
    @Override
224
    public Iterator getStreamKeys() {
225
        return null;
×
226
    }
227

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