MockMvc request builder preserves double slashes
The MockHttpServletRequestBuilder now uses java.net.URI internally rather than UriComponents. This means that for the MockMvcRequestBuilders method variants that accept a java.net.URI we can use it as is. The difference is almost none but it does mean that you can create a URI with double slashes (for testing purposes) and have it remain that way. Issue: SPR-13435
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
package org.springframework.test.web.servlet.request;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.security.Principal;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -91,6 +93,16 @@ public class MockHttpServletRequestBuilderTests {
|
||||
assertEquals("/foo%20bar", request.getRequestURI());
|
||||
}
|
||||
|
||||
// SPR-13435
|
||||
|
||||
@Test
|
||||
public void requestUriWithDoubleSlashes() throws URISyntaxException {
|
||||
this.builder = new MockHttpServletRequestBuilder(HttpMethod.GET, new URI("/test//currentlyValid/0"));
|
||||
MockHttpServletRequest request = this.builder.buildRequest(this.servletContext);
|
||||
|
||||
assertEquals("/test//currentlyValid/0", request.getRequestURI());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void contextPathEmpty() {
|
||||
this.builder = new MockHttpServletRequestBuilder(HttpMethod.GET, "/foo");
|
||||
|
||||
Reference in New Issue
Block a user