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

hazendaz / httpunit / 755

14 Feb 2026 07:14PM UTC coverage: 80.526%. Remained the same
755

push

github

hazendaz
[ci] Fix badge

3213 of 4105 branches covered (78.27%)

Branch coverage included in aggregate %.

8245 of 10124 relevant lines covered (81.44%)

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
 * SPDX-License-Identifier: MIT
3
 * See LICENSE file for details.
4
 *
5
 * Copyright 2000-2026 Russell Gold
6
 * Copyright 2021-2000 hazendaz
7
 */
8
package com.meterware.pseudoserver;
9

10
import java.io.IOException;
11
import java.io.Reader;
12

13
/**
14
 * A basic simulated servlet for testing the HttpUnit library.
15
 **/
16
public abstract class PseudoServlet {
1✔
17

18
    /** The Constant CONTENTS. */
19
    public static final String CONTENTS = "contents";
20

21
    /**
22
     * Returns a resource object as a result of a get request.
23
     *
24
     * @param methodType
25
     *            the method type
26
     *
27
     * @return the response
28
     *
29
     * @throws IOException
30
     *             Signals that an I/O exception has occurred.
31
     */
32
    public WebResource getResponse(String methodType) throws IOException {
33
        if (methodType.equalsIgnoreCase("GET")) {
1✔
34
            return getGetResponse();
1✔
35
        }
36
        if (methodType.equalsIgnoreCase("PUT")) {
1!
37
            return getPutResponse();
×
38
        }
39
        if (methodType.equalsIgnoreCase("POST")) {
1✔
40
            return getPostResponse();
1✔
41
        }
42
        if (methodType.equalsIgnoreCase("DELETE")) {
1✔
43
            return getDeleteResponse();
1✔
44
        }
45
        throw new UnknownMethodException(methodType);
1✔
46
    }
47

48
    /**
49
     * Returns a resource object as a result of a get request.
50
     *
51
     * @return the gets the response
52
     *
53
     * @throws IOException
54
     *             Signals that an I/O exception has occurred.
55
     */
56
    public WebResource getGetResponse() throws IOException {
57
        throw new UnknownMethodException("GET");
×
58
    }
59

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

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

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

105
    /**
106
     * Inits the.
107
     *
108
     * @param requestStream
109
     *            the request stream
110
     */
111
    void init(HttpRequest requestStream) {
112
        _request = requestStream;
1✔
113
    }
1✔
114

115
    /**
116
     * Returns the header with the specified name. If no such header exists, will return null.
117
     *
118
     * @param name
119
     *            the name
120
     *
121
     * @return the header
122
     */
123
    protected String getHeader(String name) {
124
        return _request.getHeader(name);
1✔
125
    }
126

127
    /**
128
     * Returns the values for the parameter with the specified name. If no values exist will return null.
129
     *
130
     * @param name
131
     *            the name
132
     *
133
     * @return the parameter
134
     */
135
    protected String[] getParameter(String name) {
136
        return _request.getParameter(name);
1✔
137
    }
138

139
    /**
140
     * Returns a reader for the body of the request.
141
     *
142
     * @return the reader
143
     */
144
    protected Reader getReader() {
145
        return _request.getReader();
×
146
    }
147

148
    /**
149
     * Gets the body.
150
     *
151
     * @return the body
152
     */
153
    protected byte[] getBody() {
154
        return _request.getBody();
1✔
155
    }
156

157
    /**
158
     * Gets the request.
159
     *
160
     * @return the request
161
     */
162
    protected HttpRequest getRequest() {
163
        return _request;
1✔
164
    }
165

166
    /** The request. */
167
    private HttpRequest _request;
168

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