From 0b8554f94a73b1620d8c34d1a68b3eb8e56d482a Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 6 Apr 2015 22:43:25 -0400 Subject: [PATCH] Leave query un-encoded in MockMvc request builder Issue: SPR-12880 --- .../web/servlet/request/MockHttpServletRequestBuilder.java | 3 +-- .../servlet/request/MockHttpServletRequestBuilderTests.java | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java index 22b8d0800c..0c803aef03 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java @@ -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> entry : this.uriComponents.getQueryParams().entrySet()) { diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java index 5bfd542168..719f2a223b 100644 --- a/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java +++ b/spring-test/src/test/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilderTests.java @@ -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 { 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")); }