mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-28 18:19:05 +00:00
Restore mixed use of uri() and queryParam()
for query parameters in AbstractMockHttpServletRequestBuilder. See gh-35329 Signed-off-by: Johnny Lim <izeye@naver.com>
This commit is contained in:
+1
-1
@@ -826,7 +826,7 @@ public abstract class AbstractMockHttpServletRequestBuilder<B extends AbstractMo
|
||||
addRequestParams(request, UriComponentsBuilder.fromUri(uri).build().getQueryParams());
|
||||
|
||||
this.parameters.forEach((name, values) ->
|
||||
request.setParameter(name, values.toArray(new String[0])));
|
||||
request.addParameter(name, values.toArray(new String[0])));
|
||||
|
||||
if (!this.formFields.isEmpty()) {
|
||||
if (this.content != null && this.content.length > 0) {
|
||||
|
||||
+9
@@ -273,6 +273,15 @@ class MockHttpServletRequestBuilderTests {
|
||||
assertThat(request.getParameterMap().get("foo")).containsExactly();
|
||||
}
|
||||
|
||||
@Test
|
||||
void queryParametersWithUriAndQueryParam() {
|
||||
this.builder = new MockHttpServletRequestBuilder(GET).uri("/path?param1=value1");
|
||||
this.builder.queryParam("param1", "value2");
|
||||
MockHttpServletRequest request = this.builder.buildRequest(this.servletContext);
|
||||
|
||||
assertThat(request.getParameterMap().get("param1")).containsExactly("value1", "value2");
|
||||
}
|
||||
|
||||
@Test
|
||||
void queryParameterMap() {
|
||||
this.builder = new MockHttpServletRequestBuilder(GET).uri("/");
|
||||
|
||||
Reference in New Issue
Block a user