|
33 | 33 | import org.junit.jupiter.api.Test; |
34 | 34 |
|
35 | 35 | import org.junit.jupiter.params.ParameterizedTest; |
| 36 | +import org.junit.jupiter.params.provider.ValueSource; |
36 | 37 | import org.springframework.http.HttpHeaders; |
37 | 38 | import org.springframework.http.HttpMethod; |
38 | 39 | import org.springframework.http.MediaType; |
|
54 | 55 | import static org.assertj.core.api.Assertions.entry; |
55 | 56 | import static org.springframework.http.HttpMethod.GET; |
56 | 57 | import static org.springframework.http.HttpMethod.POST; |
57 | | -import static org.springframework.http.HttpMethod.QUERY; |
58 | 58 |
|
59 | 59 | /** |
60 | 60 | * Tests for building a {@link MockHttpServletRequest} with |
@@ -420,21 +420,21 @@ void requestParameterFromMultiValueMap() { |
420 | 420 | assertThat(request.getParameterMap().get("foo")).containsExactly("bar", "baz"); |
421 | 421 | } |
422 | 422 |
|
423 | | - @Test |
| 423 | + @ValueSource(strings = {"POST", "QUERY"}) |
424 | 424 | @ParameterizedTest() |
425 | | - void requestParameterFromRequestBodyFormData() { |
| 425 | + void requestParameterFromRequestBodyFormData(String methodName) { |
426 | 426 | String contentType = "application/x-www-form-urlencoded;charset=UTF-8"; |
427 | 427 | String body = "name+1=value+1&name+2=value+A&name+2=value+B&name+3"; |
428 | 428 |
|
429 | | - for (HttpMethod method : List.of(POST, QUERY)) { |
430 | | - MockHttpServletRequest request = new MockHttpServletRequestBuilder(method).uri("/foo") |
431 | | - .contentType(contentType).content(body.getBytes(UTF_8)) |
432 | | - .buildRequest(this.servletContext); |
| 429 | + HttpMethod method = HttpMethod.valueOf(methodName); |
| 430 | + MockHttpServletRequest request = new MockHttpServletRequestBuilder(method).uri("/foo") |
| 431 | + .contentType(contentType).content(body.getBytes(UTF_8)) |
| 432 | + .buildRequest(this.servletContext); |
| 433 | + |
| 434 | + assertThat(request.getParameterMap().get("name 1")).containsExactly("value 1"); |
| 435 | + assertThat(request.getParameterMap().get("name 2")).containsExactly("value A", "value B"); |
| 436 | + assertThat(request.getParameterMap().get("name 3")).containsExactly((String) null); |
433 | 437 |
|
434 | | - assertThat(request.getParameterMap().get("name 1")).containsExactly("value 1"); |
435 | | - assertThat(request.getParameterMap().get("name 2")).containsExactly("value A", "value B"); |
436 | | - assertThat(request.getParameterMap().get("name 3")).containsExactly((String) null); |
437 | | - } |
438 | 438 | } |
439 | 439 |
|
440 | 440 | @Test |
|
0 commit comments