diff options
author | Emmanuel Bourg <ebourg@apache.org> | 2016-11-11 22:59:07 +0100 |
---|---|---|
committer | Emmanuel Bourg <ebourg@apache.org> | 2016-11-11 22:59:07 +0100 |
commit | 0591d269b8b2b33af090ace1ecbd408490618428 (patch) | |
tree | 2b9b277dd7cb0cd3bc6f66fb0a4c79a85293a04b /spring-web/src/test/java/org/springframework/web | |
parent | c3df6b7858afaef71fbe0b42cd62f7f12e595bf0 (diff) |
New upstream version 4.3.4
Diffstat (limited to 'spring-web/src/test/java/org/springframework/web')
3 files changed, 159 insertions, 98 deletions
diff --git a/spring-web/src/test/java/org/springframework/web/client/AbstractJettyServerTestCase.java b/spring-web/src/test/java/org/springframework/web/client/AbstractJettyServerTestCase.java index adf5449f..0b58c740 100644 --- a/spring-web/src/test/java/org/springframework/web/client/AbstractJettyServerTestCase.java +++ b/spring-web/src/test/java/org/springframework/web/client/AbstractJettyServerTestCase.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,13 +33,11 @@ import org.apache.commons.fileupload.FileItemFactory; import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet.ServletFileUpload; - import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.NetworkConnector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.jetty.servlet.ServletHolder; - import org.junit.AfterClass; import org.junit.BeforeClass; @@ -56,11 +54,12 @@ public class AbstractJettyServerTestCase { protected static final String helloWorld = "H\u00e9llo W\u00f6rld"; - protected static final MediaType textContentType = new MediaType("text", "plain", - Collections.singletonMap("charset", "UTF-8")); + protected static final MediaType textContentType = + new MediaType("text", "plain", Collections.singletonMap("charset", "UTF-8")); + + protected static final MediaType jsonContentType = + new MediaType("application", "json", Collections.singletonMap("charset", "UTF-8")); - protected static final MediaType jsonContentType = new MediaType("application", - "json", Collections.singletonMap("charset", "utf-8")); private static Server jettyServer; @@ -71,7 +70,6 @@ public class AbstractJettyServerTestCase { @BeforeClass public static void startJettyServer() throws Exception { - // Let server pick its own random, available port. jettyServer = new Server(0); @@ -114,39 +112,41 @@ public class AbstractJettyServerTestCase { } } + /** Servlet that sets the given status code. */ @SuppressWarnings("serial") private static class StatusCodeServlet extends GenericServlet { private final int sc; - private StatusCodeServlet(int sc) { + public StatusCodeServlet(int sc) { this.sc = sc; } @Override - public void service(ServletRequest request, ServletResponse response) throws - ServletException, IOException { + public void service(ServletRequest request, ServletResponse response) throws IOException { ((HttpServletResponse) response).setStatus(sc); } } + /** Servlet that returns an error message for a given status code. */ @SuppressWarnings("serial") private static class ErrorServlet extends GenericServlet { private final int sc; - private ErrorServlet(int sc) { + public ErrorServlet(int sc) { this.sc = sc; } @Override - public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException { + public void service(ServletRequest request, ServletResponse response) throws IOException { ((HttpServletResponse) response).sendError(sc); } } + @SuppressWarnings("serial") private static class GetServlet extends HttpServlet { @@ -154,14 +154,13 @@ public class AbstractJettyServerTestCase { private final MediaType contentType; - private GetServlet(byte[] buf, MediaType contentType) { + public GetServlet(byte[] buf, MediaType contentType) { this.buf = buf; this.contentType = contentType; } @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException { if (contentType != null) { response.setContentType(contentType.toString()); } @@ -170,10 +169,11 @@ public class AbstractJettyServerTestCase { } } + @SuppressWarnings("serial") private static class PostServlet extends HttpServlet { - private final String s; + private final String content; private final String location; @@ -181,20 +181,19 @@ public class AbstractJettyServerTestCase { private final MediaType contentType; - private PostServlet(String s, String location, byte[] buf, MediaType contentType) { - this.s = s; + public PostServlet(String content, String location, byte[] buf, MediaType contentType) { + this.content = content; this.location = location; this.buf = buf; this.contentType = contentType; } @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { assertTrue("Invalid request content-length", request.getContentLength() > 0); assertNotNull("No content-type", request.getContentType()); String body = FileCopyUtils.copyToString(request.getReader()); - assertEquals("Invalid request body", s, body); + assertEquals("Invalid request body", content, body); response.setStatus(HttpServletResponse.SC_CREATED); response.setHeader("Location", baseUrl + location); response.setContentLength(buf.length); @@ -203,6 +202,7 @@ public class AbstractJettyServerTestCase { } } + @SuppressWarnings("serial") private static class JsonPostServlet extends HttpServlet { @@ -210,14 +210,13 @@ public class AbstractJettyServerTestCase { private final MediaType contentType; - private JsonPostServlet(String location, MediaType contentType) { + public JsonPostServlet(String location, MediaType contentType) { this.location = location; this.contentType = contentType; } @Override - protected void doPost(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException { assertTrue("Invalid request content-length", request.getContentLength() > 0); assertNotNull("No content-type", request.getContentType()); String body = FileCopyUtils.copyToString(request.getReader()); @@ -230,18 +229,18 @@ public class AbstractJettyServerTestCase { } } + @SuppressWarnings("serial") private static class PutServlet extends HttpServlet { private final String s; - private PutServlet(String s, byte[] buf, MediaType contentType) { + public PutServlet(String s, byte[] buf, MediaType contentType) { this.s = s; } @Override - protected void doPut(HttpServletRequest request, HttpServletResponse response) - throws ServletException, IOException { + protected void doPut(HttpServletRequest request, HttpServletResponse response) throws IOException { assertTrue("Invalid request content-length", request.getContentLength() > 0); assertNotNull("No content-type", request.getContentType()); String body = FileCopyUtils.copyToString(request.getReader()); @@ -250,17 +249,19 @@ public class AbstractJettyServerTestCase { } } + @SuppressWarnings("serial") private static class UriServlet extends HttpServlet { @Override - protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.setContentType("text/plain"); resp.setCharacterEncoding("utf-8"); resp.getWriter().write(req.getRequestURI()); } } + @SuppressWarnings("serial") private static class MultipartServlet extends HttpServlet { @@ -300,13 +301,13 @@ public class AbstractJettyServerTestCase { } } + @SuppressWarnings("serial") private static class FormServlet extends HttpServlet { @Override - protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - assertEquals(MediaType.APPLICATION_FORM_URLENCODED_VALUE, - req.getContentType()); + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { + assertEquals(MediaType.APPLICATION_FORM_URLENCODED_VALUE, req.getContentType()); Map<String, String[]> parameters = req.getParameterMap(); assertEquals(2, parameters.size()); @@ -322,15 +323,14 @@ public class AbstractJettyServerTestCase { } } + @SuppressWarnings("serial") private static class DeleteServlet extends HttpServlet { @Override - protected void doDelete(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { + protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws IOException { resp.setStatus(200); } - } } diff --git a/spring-web/src/test/java/org/springframework/web/cors/CorsConfigurationTests.java b/spring-web/src/test/java/org/springframework/web/cors/CorsConfigurationTests.java index 32f68af3..a7c54566 100644 --- a/spring-web/src/test/java/org/springframework/web/cors/CorsConfigurationTests.java +++ b/spring-web/src/test/java/org/springframework/web/cors/CorsConfigurationTests.java @@ -34,10 +34,9 @@ import static org.junit.Assert.*; */ public class CorsConfigurationTests { - private CorsConfiguration config = new CorsConfiguration(); - @Test public void setNullValues() { + CorsConfiguration config = new CorsConfiguration(); config.setAllowedOrigins(null); assertNull(config.getAllowedOrigins()); config.setAllowedHeaders(null); @@ -54,6 +53,7 @@ public class CorsConfigurationTests { @Test public void setValues() { + CorsConfiguration config = new CorsConfiguration(); config.addAllowedOrigin("*"); assertEquals(Arrays.asList("*"), config.getAllowedOrigins()); config.addAllowedHeader("*"); @@ -71,16 +71,19 @@ public class CorsConfigurationTests { @Test(expected = IllegalArgumentException.class) public void asteriskWildCardOnAddExposedHeader() { + CorsConfiguration config = new CorsConfiguration(); config.addExposedHeader("*"); } @Test(expected = IllegalArgumentException.class) public void asteriskWildCardOnSetExposedHeaders() { + CorsConfiguration config = new CorsConfiguration(); config.setExposedHeaders(Arrays.asList("*")); } @Test public void combineWithNull() { + CorsConfiguration config = new CorsConfiguration(); config.setAllowedOrigins(Arrays.asList("*")); config.combine(null); assertEquals(Arrays.asList("*"), config.getAllowedOrigins()); @@ -88,6 +91,7 @@ public class CorsConfigurationTests { @Test public void combineWithNullProperties() { + CorsConfiguration config = new CorsConfiguration(); config.addAllowedOrigin("*"); config.addAllowedHeader("header1"); config.addExposedHeader("header3"); @@ -106,6 +110,7 @@ public class CorsConfigurationTests { @Test public void combineWithAsteriskWildCard() { + CorsConfiguration config = new CorsConfiguration(); config.addAllowedOrigin("*"); config.addAllowedHeader("*"); config.addAllowedMethod("*"); @@ -126,8 +131,32 @@ public class CorsConfigurationTests { assertEquals(Arrays.asList(HttpMethod.PUT.name()), combinedConfig.getAllowedMethods()); } + @Test // SPR-14792 + public void combineWithDuplicatedElements() { + CorsConfiguration config = new CorsConfiguration(); + config.addAllowedOrigin("http://domain1.com"); + config.addAllowedOrigin("http://domain2.com"); + config.addAllowedHeader("header1"); + config.addAllowedHeader("header2"); + config.addExposedHeader("header3"); + config.addExposedHeader("header4"); + config.addAllowedMethod(HttpMethod.GET.name()); + config.addAllowedMethod(HttpMethod.PUT.name()); + CorsConfiguration other = new CorsConfiguration(); + other.addAllowedOrigin("http://domain1.com"); + other.addAllowedHeader("header1"); + other.addExposedHeader("header3"); + other.addAllowedMethod(HttpMethod.GET.name()); + CorsConfiguration combinedConfig = config.combine(other); + assertEquals(Arrays.asList("http://domain1.com", "http://domain2.com"), combinedConfig.getAllowedOrigins()); + assertEquals(Arrays.asList("header1", "header2"), combinedConfig.getAllowedHeaders()); + assertEquals(Arrays.asList("header3", "header4"), combinedConfig.getExposedHeaders()); + assertEquals(Arrays.asList(HttpMethod.GET.name(), HttpMethod.PUT.name()), combinedConfig.getAllowedMethods()); + } + @Test public void combine() { + CorsConfiguration config = new CorsConfiguration(); config.addAllowedOrigin("http://domain1.com"); config.addAllowedHeader("header1"); config.addExposedHeader("header3"); @@ -152,6 +181,7 @@ public class CorsConfigurationTests { @Test public void checkOriginAllowed() { + CorsConfiguration config = new CorsConfiguration(); config.setAllowedOrigins(Arrays.asList("*")); assertEquals("*", config.checkOrigin("http://domain.com")); config.setAllowCredentials(true); @@ -164,6 +194,7 @@ public class CorsConfigurationTests { @Test public void checkOriginNotAllowed() { + CorsConfiguration config = new CorsConfiguration(); assertNull(config.checkOrigin(null)); assertNull(config.checkOrigin("http://domain.com")); config.addAllowedOrigin("*"); @@ -176,6 +207,7 @@ public class CorsConfigurationTests { @Test public void checkMethodAllowed() { + CorsConfiguration config = new CorsConfiguration(); assertEquals(Arrays.asList(HttpMethod.GET, HttpMethod.HEAD), config.checkHttpMethod(HttpMethod.GET)); config.addAllowedMethod("GET"); assertEquals(Arrays.asList(HttpMethod.GET), config.checkHttpMethod(HttpMethod.GET)); @@ -186,6 +218,7 @@ public class CorsConfigurationTests { @Test public void checkMethodNotAllowed() { + CorsConfiguration config = new CorsConfiguration(); assertNull(config.checkHttpMethod(null)); assertNull(config.checkHttpMethod(HttpMethod.DELETE)); config.setAllowedMethods(new ArrayList<>()); @@ -194,6 +227,7 @@ public class CorsConfigurationTests { @Test public void checkHeadersAllowed() { + CorsConfiguration config = new CorsConfiguration(); assertEquals(Collections.emptyList(), config.checkHeaders(Collections.emptyList())); config.addAllowedHeader("header1"); config.addAllowedHeader("header2"); @@ -204,13 +238,11 @@ public class CorsConfigurationTests { @Test public void checkHeadersNotAllowed() { + CorsConfiguration config = new CorsConfiguration(); assertNull(config.checkHeaders(null)); - assertNull(config.checkHeaders(Arrays.asList("header1"))); - config.setAllowedHeaders(Collections.emptyList()); assertNull(config.checkHeaders(Arrays.asList("header1"))); - config.addAllowedHeader("header2"); config.addAllowedHeader("header3"); assertNull(config.checkHeaders(Arrays.asList("header1"))); diff --git a/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java b/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java index 6b5e40e8..546496c2 100644 --- a/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java +++ b/spring-web/src/test/java/org/springframework/web/util/UriComponentsBuilderTests.java @@ -125,9 +125,7 @@ public class UriComponentsBuilderTests { assertEquals("Invalid result URI", uri, result.toUri()); } - // SPR-9317 - - @Test + @Test // SPR-9317 public void fromUriEncodedQuery() throws URISyntaxException { URI uri = new URI("http://www.example.org/?param=aGVsbG9Xb3JsZA%3D%3D"); String fromUri = UriComponentsBuilder.fromUri(uri).build().getQueryParams().get("param").get(0); @@ -182,9 +180,7 @@ public class UriComponentsBuilderTests { assertEquals("28", result.getFragment()); } - // SPR-9832 - - @Test + @Test // SPR-9832 public void fromUriStringQueryParamWithReservedCharInValue() throws URISyntaxException { String uri = "http://www.google.com/ig/calculator?q=1USD=?EUR"; UriComponents result = UriComponentsBuilder.fromUriString(uri).build(); @@ -193,41 +189,35 @@ public class UriComponentsBuilderTests { assertEquals("1USD=?EUR", result.getQueryParams().getFirst("q")); } - // SPR-10779 - - @Test + @Test // SPR-10779 public void fromHttpUrlStringCaseInsesitiveScheme() { assertEquals("http", UriComponentsBuilder.fromHttpUrl("HTTP://www.google.com").build().getScheme()); assertEquals("https", UriComponentsBuilder.fromHttpUrl("HTTPS://www.google.com").build().getScheme()); } - // SPR-10539 - @Test(expected = IllegalArgumentException.class) + + @Test(expected = IllegalArgumentException.class) // SPR-10539 public void fromHttpUrlStringInvalidIPv6Host() throws URISyntaxException { UriComponentsBuilder.fromHttpUrl("http://[1abc:2abc:3abc::5ABC:6abc:8080/resource").build().encode(); } - // SPR-10539 - - @Test + @Test // SPR-10539 public void fromUriStringIPv6Host() throws URISyntaxException { - UriComponents result = UriComponentsBuilder - .fromUriString("http://[1abc:2abc:3abc::5ABC:6abc]:8080/resource").build().encode(); - assertEquals("[1abc:2abc:3abc::5ABC:6abc]", result.getHost()); + UriComponents result = UriComponentsBuilder + .fromUriString("http://[1abc:2abc:3abc::5ABC:6abc]:8080/resource").build().encode(); + assertEquals("[1abc:2abc:3abc::5ABC:6abc]", result.getHost()); - UriComponents resultWithScopeId = UriComponentsBuilder - .fromUriString("http://[1abc:2abc:3abc::5ABC:6abc%eth0]:8080/resource").build().encode(); + UriComponents resultWithScopeId = UriComponentsBuilder + .fromUriString("http://[1abc:2abc:3abc::5ABC:6abc%eth0]:8080/resource").build().encode(); assertEquals("[1abc:2abc:3abc::5ABC:6abc%25eth0]", resultWithScopeId.getHost()); - UriComponents resultIPv4compatible = UriComponentsBuilder - .fromUriString("http://[::192.168.1.1]:8080/resource").build().encode(); + UriComponents resultIPv4compatible = UriComponentsBuilder + .fromUriString("http://[::192.168.1.1]:8080/resource").build().encode(); assertEquals("[::192.168.1.1]", resultIPv4compatible.getHost()); } - // SPR-11970 - - @Test + @Test // SPR-11970 public void fromUriStringNoPathWithReservedCharInQuery() { UriComponents result = UriComponentsBuilder.fromUriString("http://example.com?foo=bar@baz").build(); assertTrue(StringUtils.isEmpty(result.getUserInfo())); @@ -253,9 +243,7 @@ public class UriComponentsBuilderTests { assertEquals("a=1", result.getQuery()); } - // SPR-12771 - - @Test + @Test // SPR-12771 public void fromHttpRequestResetsPortBeforeSettingIt() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(); request.addHeader("X-Forwarded-Proto", "https"); @@ -275,6 +263,67 @@ public class UriComponentsBuilderTests { assertEquals("/rest/mobile/users/1", result.getPath()); } + @Test //SPR-14761 + public void fromHttpRequestWithForwardedIPv4Host() { + MockHttpServletRequest request = new MockHttpServletRequest(); + request.setScheme("http"); + request.setServerName("localhost"); + request.setServerPort(-1); + request.setRequestURI("/mvc-showcase"); + request.addHeader("Forwarded", "host=192.168.0.1"); + + HttpRequest httpRequest = new ServletServerHttpRequest(request); + UriComponents result = UriComponentsBuilder.fromHttpRequest(httpRequest).build(); + + assertEquals("http://192.168.0.1/mvc-showcase", result.toString()); + } + + @Test //SPR-14761 + public void fromHttpRequestWithForwardedIPv6() { + MockHttpServletRequest request = new MockHttpServletRequest(); + request.setScheme("http"); + request.setServerName("localhost"); + request.setServerPort(-1); + request.setRequestURI("/mvc-showcase"); + request.addHeader("Forwarded", "host=[1abc:2abc:3abc::5ABC:6abc]"); + + HttpRequest httpRequest = new ServletServerHttpRequest(request); + UriComponents result = UriComponentsBuilder.fromHttpRequest(httpRequest).build(); + + assertEquals("http://[1abc:2abc:3abc::5ABC:6abc]/mvc-showcase", result.toString()); + } + + @Test //SPR-14761 + public void fromHttpRequestWithForwardedIPv6Host() { + MockHttpServletRequest request = new MockHttpServletRequest(); + request.setScheme("http"); + request.setServerName("localhost"); + request.setServerPort(-1); + request.setRequestURI("/mvc-showcase"); + request.addHeader("X-Forwarded-Host", "[1abc:2abc:3abc::5ABC:6abc]"); + + HttpRequest httpRequest = new ServletServerHttpRequest(request); + UriComponents result = UriComponentsBuilder.fromHttpRequest(httpRequest).build(); + + assertEquals("http://[1abc:2abc:3abc::5ABC:6abc]/mvc-showcase", result.toString()); + } + + @Test //SPR-14761 + public void fromHttpRequestWithForwardedIPv6HostAndPort() { + MockHttpServletRequest request = new MockHttpServletRequest(); + request.setScheme("http"); + request.setServerName("localhost"); + request.setServerPort(-1); + request.setRequestURI("/mvc-showcase"); + request.addHeader("X-Forwarded-Host", "[1abc:2abc:3abc::5ABC:6abc]:8080"); + + HttpRequest httpRequest = new ServletServerHttpRequest(request); + UriComponents result = UriComponentsBuilder.fromHttpRequest(httpRequest).build(); + + assertEquals("http://[1abc:2abc:3abc::5ABC:6abc]:8080/mvc-showcase", result.toString()); + } + + @Test public void fromHttpRequestWithForwardedHost() { MockHttpServletRequest request = new MockHttpServletRequest(); @@ -290,9 +339,7 @@ public class UriComponentsBuilderTests { assertEquals("http://anotherHost/mvc-showcase", result.toString()); } - // SPR-10701 - - @Test + @Test // SPR-10701 public void fromHttpRequestWithForwardedHostIncludingPort() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setScheme("http"); @@ -308,9 +355,7 @@ public class UriComponentsBuilderTests { assertEquals(443, result.getPort()); } - // SPR-11140 - - @Test + @Test // SPR-11140 public void fromHttpRequestWithForwardedHostMultiValuedHeader() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setScheme("http"); @@ -325,9 +370,7 @@ public class UriComponentsBuilderTests { assertEquals(-1, result.getPort()); } - // SPR-11855 - - @Test + @Test // SPR-11855 public void fromHttpRequestWithForwardedHostAndPort() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setScheme("http"); @@ -343,9 +386,7 @@ public class UriComponentsBuilderTests { assertEquals(9090, result.getPort()); } - // SPR-11872 - - @Test + @Test // SPR-11872 public void fromHttpRequestWithForwardedHostWithDefaultPort() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setScheme("http"); @@ -378,9 +419,7 @@ public class UriComponentsBuilderTests { assertEquals(-1, result.getPort()); } - // SPR-12771 - - @Test + @Test // SPR-12771 public void fromHttpRequestWithForwardedProtoAndDefaultPort() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setScheme("http"); @@ -397,9 +436,7 @@ public class UriComponentsBuilderTests { assertEquals("https://84.198.58.199/mvc-showcase", result.toString()); } - // SPR-12813 - - @Test + @Test // SPR-12813 public void fromHttpRequestWithForwardedPortMultiValueHeader() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setScheme("http"); @@ -415,9 +452,7 @@ public class UriComponentsBuilderTests { assertEquals("http://a.example.org/mvc-showcase", result.toString()); } - // SPR-12816 - - @Test + @Test // SPR-12816 public void fromHttpRequestWithForwardedProtoMultiValueHeader() { MockHttpServletRequest request = new MockHttpServletRequest(); request.setScheme("http"); @@ -434,9 +469,7 @@ public class UriComponentsBuilderTests { assertEquals("https://a.example.org/mvc-showcase", result.toString()); } - // SPR-12742 - - @Test + @Test // SPR-12742 public void fromHttpRequestWithTrailingSlash() throws Exception { UriComponents before = UriComponentsBuilder.fromPath("/foo/").build(); UriComponents after = UriComponentsBuilder.newInstance().uriComponents(before).build(); @@ -506,9 +539,7 @@ public class UriComponentsBuilderTests { assertEquals(Arrays.asList("foo", "bar"), result.getPathSegments()); } - // SPR-12398 - - @Test + @Test // SPR-12398 public void pathWithDuplicateSlashes() throws URISyntaxException { UriComponents uriComponents = UriComponentsBuilder.fromPath("/foo/////////bar").build(); assertEquals("/foo/bar", uriComponents.getPath()); @@ -645,7 +676,7 @@ public class UriComponentsBuilderTests { @Test public void emptySegments() throws Exception { assertThat(UriComponentsBuilder.fromUriString("http://example.com/abc/").path("/x/y/z").build().toString(), equalTo("http://example.com/abc/x/y/z")); - assertThat(UriComponentsBuilder.fromUriString("http://example.com/abc/").pathSegment("x", "y", "z").build().toString(), equalTo("http://example.com/abc/x/y/z")); + assertThat(UriComponentsBuilder.fromUriString("http://example.com/abc/").pathSegment("x", "y", "z").build().toString(), equalTo("http://example.com/abc/x/y/z")); assertThat(UriComponentsBuilder.fromUriString("http://example.com/abc/").path("/x/").path("/y/z").build().toString(), equalTo("http://example.com/abc/x/y/z")); assertThat(UriComponentsBuilder.fromUriString("http://example.com/abc/").pathSegment("x").path("y").build().toString(), equalTo("http://example.com/abc/x/y")); } @@ -686,9 +717,7 @@ public class UriComponentsBuilderTests { assertEquals("f2", result2.getFragment()); } - // SPR-11856 - - @Test + @Test // SPR-11856 public void fromHttpRequestForwardedHeader() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(); request.addHeader("Forwarded", "proto=https; host=84.198.58.199"); |