Created
January 13, 2012 14:31
-
-
Save odrotbohm/1606493 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MockHttpServletRequest httpServletRequest = new MockHttpServletRequest("GET", "http://localhost:8080/foo/bar?foo=bar"); | |
String string = ServletUriComponentsBuilder.fromRequest(httpServletRequest).path("/something").build().toUriString(); | |
assertThat(string, is("http://localhost:8080/foo/bar/something?foo=bar")); | |
java.lang.AssertionError: | |
Expected: is "http://localhost:8080/foo/bar/something?foo=bar" | |
got: "http://localhost/http://localhost:8080/foo/bar?foo=bar/something" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo/bar");
request.setProtocol("http");
request.setServerName("localhost");
request.setServerPort(8080);
request.setQueryString("foo=bar");
String actual = ServletUriComponentsBuilder.fromRequest(request).path("/something").build().toUriString();
assertEquals("http://localhost:8080/foo/bar/something?foo=bar", actual);