Browse Source

Leave query un-encoded in MockMvc request builder

Issue: SPR-12880
pull/770/merge
Rossen Stoyanchev 10 years ago
parent
commit
0b8554f94a
  1. 3
      spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java
  2. 4
      spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java

3
spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java

@ -581,8 +581,7 @@ public class MockHttpServletRequestBuilder @@ -581,8 +581,7 @@ public class MockHttpServletRequestBuilder
try {
if (this.uriComponents.getQuery() != null) {
String query = UriUtils.decode(this.uriComponents.getQuery(), "UTF-8");
request.setQueryString(query);
request.setQueryString(this.uriComponents.getQuery());
}
for (Entry<String, List<String>> entry : this.uriComponents.getQueryParams().entrySet()) {

4
spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java

@ -210,7 +210,7 @@ public class MockHttpServletRequestBuilderTests { @@ -210,7 +210,7 @@ public class MockHttpServletRequestBuilderTests {
MockHttpServletRequest request = this.builder.buildRequest(this.servletContext);
assertEquals("foo[0]=bar&foo[1]=baz", request.getQueryString());
assertEquals("foo%5B0%5D=bar&foo%5B1%5D=baz", request.getQueryString());
assertEquals("bar", request.getParameter("foo[0]"));
assertEquals("baz", request.getParameter("foo[1]"));
}
@ -221,7 +221,7 @@ public class MockHttpServletRequestBuilderTests { @@ -221,7 +221,7 @@ public class MockHttpServletRequestBuilderTests {
MockHttpServletRequest request = this.builder.buildRequest(this.servletContext);
assertEquals("foo=bar=baz", request.getQueryString());
assertEquals("foo=bar%3Dbaz", request.getQueryString());
assertEquals("bar=baz", request.getParameter("foo"));
}

Loading…
Cancel
Save