• 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

75.86
/src/main/java/com/meterware/pseudoserver/PseudoServlet.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.pseudoserver;
21

22
import java.io.IOException;
23
import java.io.Reader;
24

25
/**
26
 * A basic simulated servlet for testing the HttpUnit library.
27
 **/
28
public abstract class PseudoServlet {
1✔
29

30
    /** The Constant CONTENTS. */
31
    public static final String CONTENTS = "contents";
32

33
    /**
34
     * Returns a resource object as a result of a get request.
35
     *
36
     * @param methodType
37
     *            the method type
38
     *
39
     * @return the response
40
     *
41
     * @throws IOException
42
     *             Signals that an I/O exception has occurred.
43
     */
44
    public WebResource getResponse(String methodType) throws IOException {
45
        if (methodType.equalsIgnoreCase("GET")) {
1✔
46
            return getGetResponse();
1✔
47
        }
48
        if (methodType.equalsIgnoreCase("PUT")) {
1!
49
            return getPutResponse();
×
50
        }
51
        if (methodType.equalsIgnoreCase("POST")) {
1✔
52
            return getPostResponse();
1✔
53
        }
54
        if (methodType.equalsIgnoreCase("DELETE")) {
1✔
55
            return getDeleteResponse();
1✔
56
        }
57
        throw new UnknownMethodException(methodType);
1✔
58
    }
59

60
    /**
61
     * Returns a resource object as a result of a get request.
62
     *
63
     * @return the gets the response
64
     *
65
     * @throws IOException
66
     *             Signals that an I/O exception has occurred.
67
     */
68
    public WebResource getGetResponse() throws IOException {
69
        throw new UnknownMethodException("GET");
×
70
    }
71

72
    /**
73
     * Gets the post response.
74
     *
75
     * @return the post response
76
     *
77
     * @throws IOException
78
     *             Signals that an I/O exception has occurred.
79
     */
80
    /*
81
     * Returns a resource object as a result of a post request.
82
     **/
83
    public WebResource getPostResponse() throws IOException {
84
        throw new UnknownMethodException("POST");
×
85
    }
86

87
    /**
88
     * Gets the put response.
89
     *
90
     * @return the put response
91
     *
92
     * @throws IOException
93
     *             Signals that an I/O exception has occurred.
94
     */
95
    /*
96
     * Returns a resource object as a result of a put request.
97
     **/
98
    public WebResource getPutResponse() throws IOException {
99
        throw new UnknownMethodException("PUT");
×
100
    }
101

102
    /**
103
     * Gets the delete response.
104
     *
105
     * @return the delete response
106
     *
107
     * @throws IOException
108
     *             Signals that an I/O exception has occurred.
109
     */
110
    /*
111
     * Returns a resource object as a result of a delete request.
112
     **/
113
    public WebResource getDeleteResponse() throws IOException {
114
        throw new UnknownMethodException("DELETE");
×
115
    }
116

117
    /**
118
     * Inits the.
119
     *
120
     * @param requestStream
121
     *            the request stream
122
     */
123
    void init(HttpRequest requestStream) {
124
        _request = requestStream;
1✔
125
    }
1✔
126

127
    /**
128
     * Returns the header with the specified name. If no such header exists, will return null.
129
     *
130
     * @param name
131
     *            the name
132
     *
133
     * @return the header
134
     */
135
    protected String getHeader(String name) {
136
        return _request.getHeader(name);
1✔
137
    }
138

139
    /**
140
     * Returns the values for the parameter with the specified name. If no values exist will return null.
141
     *
142
     * @param name
143
     *            the name
144
     *
145
     * @return the parameter
146
     */
147
    protected String[] getParameter(String name) {
148
        return _request.getParameter(name);
1✔
149
    }
150

151
    /**
152
     * Returns a reader for the body of the request.
153
     *
154
     * @return the reader
155
     */
156
    protected Reader getReader() {
157
        return _request.getReader();
×
158
    }
159

160
    /**
161
     * Gets the body.
162
     *
163
     * @return the body
164
     */
165
    protected byte[] getBody() {
166
        return _request.getBody();
1✔
167
    }
168

169
    /**
170
     * Gets the request.
171
     *
172
     * @return the request
173
     */
174
    protected HttpRequest getRequest() {
175
        return _request;
1✔
176
    }
177

178
    /** The request. */
179
    private HttpRequest _request;
180

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