|
34 | 34 | import org.eclipse.jetty.util.component.LifeCycle;
|
35 | 35 | import org.junit.jupiter.api.Disabled;
|
36 | 36 | import org.junit.jupiter.api.Test;
|
| 37 | +import org.junit.jupiter.params.ParameterizedTest; |
| 38 | +import org.junit.jupiter.params.provider.ValueSource; |
37 | 39 | import org.slf4j.Logger;
|
38 | 40 | import org.slf4j.LoggerFactory;
|
39 | 41 |
|
@@ -145,8 +147,9 @@ public void testNormalGetRequest() throws Exception
|
145 | 147 | * Test an unread HTTP/1.1 POST, it has valid body content, the dispatched Handler on the server doesn't read the POST body content.
|
146 | 148 | * The RequestLog accidentally attempts to read the Request body content due to the use of Request.getParameterNames() API.
|
147 | 149 | */
|
148 |
| - @Test |
149 |
| - public void testNormalPostFormRequest() throws Exception |
| 150 | + @ParameterizedTest |
| 151 | + @ValueSource(strings = {"/hello", "/hello?a=b"}) |
| 152 | + public void testNormalPostFormRequest(String requestPath) throws Exception |
150 | 153 | {
|
151 | 154 | Server server = null;
|
152 | 155 | try
|
@@ -179,7 +182,7 @@ public void testNormalPostFormRequest() throws Exception
|
179 | 182 | byte[] bufForm = form.toString().getBytes(UTF_8);
|
180 | 183 |
|
181 | 184 | StringBuilder req = new StringBuilder();
|
182 |
| - req.append("POST /hello HTTP/1.1\r\n"); |
| 185 | + req.append("POST ").append(requestPath).append(" HTTP/1.1\r\n"); |
183 | 186 | req.append("Host: ").append(baseURI.getRawAuthority()).append("\r\n");
|
184 | 187 | req.append("Content-Type: ").append(MimeTypes.Type.FORM_ENCODED).append("\r\n");
|
185 | 188 | req.append("Content-Length: ").append(bufForm.length).append("\r\n");
|
@@ -213,7 +216,10 @@ public void testNormalPostFormRequest() throws Exception
|
213 | 216 | assertThat("Body Content", bodyContent, containsString("Got POST to /hello"));
|
214 | 217 |
|
215 | 218 | String reqlog = requestLogLines.poll(5, TimeUnit.SECONDS);
|
216 |
| - assertThat("RequestLog", reqlog, containsString("method:POST|uri:/hello|paramNames.size:0|status:200")); |
| 219 | + int querySize = 0; |
| 220 | + if (requestPath.contains("?")) |
| 221 | + querySize = 1; // assuming that parameterized version only has 1 query value |
| 222 | + assertThat("RequestLog", reqlog, containsString("method:POST|uri:/hello|paramNames.size:" + querySize + "|status:200")); |
217 | 223 | }
|
218 | 224 | }
|
219 | 225 | finally
|
|
0 commit comments