Skip to content

Commit

Permalink
Fix exception mock request builder
Browse files Browse the repository at this point in the history
Issue: SPR-11043
  • Loading branch information
rstoyanchev committed Nov 5, 2013
1 parent 7387cb9 commit 4b38dc8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -581,9 +581,8 @@ public final MockHttpServletRequest buildRequest(ServletContext servletContext)

for (Entry<String, List<String>> entry : this.uriComponents.getQueryParams().entrySet()) {
for (String value : entry.getValue()) {
request.addParameter(
UriUtils.decode(entry.getKey(), "UTF-8"),
UriUtils.decode(value, "UTF-8"));
value = (value != null) ? UriUtils.decode(value, "UTF-8") : null;
request.addParameter(UriUtils.decode(entry.getKey(), "UTF-8"), value);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,19 @@ public void requestParameterFromQueryWithEncoding() throws Exception {
assertEquals("bar=baz", request.getParameter("foo"));
}

// SPR-11043

@Test
public void requestParameterFromQueryNull() throws Exception {
this.builder = new MockHttpServletRequestBuilder(HttpMethod.GET, "/?foo");

MockHttpServletRequest request = this.builder.buildRequest(this.servletContext);
Map<String, String[]> parameterMap = request.getParameterMap();

assertArrayEquals(new String[]{null}, parameterMap.get("foo"));
assertEquals("foo", request.getQueryString());
}

@Test
public void acceptHeader() throws Exception {
this.builder.accept(MediaType.TEXT_HTML, MediaType.APPLICATION_XML);
Expand Down

0 comments on commit 4b38dc8

Please sign in to comment.