Skip to content

Commit 96bfe7d

Browse files
committed
Polish
Group all contextPath tests together
1 parent 1f289b7 commit 96bfe7d

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

spring-web/src/test/java/org/springframework/web/filter/ForwardedHeaderFilterTests.java

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,35 @@ public void contextPathWithTrailingSlashes() throws Exception {
8585
assertEquals("/foo/bar/baz", filterAndGetContextPath());
8686
}
8787

88+
@Test
89+
public void contextPathWithForwardedPrefix() throws Exception {
90+
this.request.addHeader(X_FORWARDED_PREFIX, "/prefix");
91+
this.request.setContextPath("/mvc-showcase");
92+
93+
String actual = filterAndGetContextPath();
94+
assertEquals("/prefix", actual);
95+
}
96+
97+
@Test
98+
public void contextPathWithForwardedPrefixTrailingSlash() throws Exception {
99+
this.request.addHeader(X_FORWARDED_PREFIX, "/prefix/");
100+
this.request.setContextPath("/mvc-showcase");
101+
102+
String actual = filterAndGetContextPath();
103+
assertEquals("/prefix", actual);
104+
}
105+
106+
@Test
107+
public void contextPathPreserveEncoding() throws Exception {
108+
this.request.setContextPath("/app%20");
109+
this.request.setRequestURI("/app%20/path/");
110+
HttpServletRequest actual = filterAndGetWrappedRequest();
111+
112+
assertEquals("/app%20", actual.getContextPath());
113+
assertEquals("/app%20/path/", actual.getRequestURI());
114+
assertEquals("http://localhost/app%20/path/", actual.getRequestURL().toString());
115+
}
116+
88117
@Test
89118
public void requestUri() throws Exception {
90119
this.request.addHeader(X_FORWARDED_PREFIX, "/");
@@ -227,35 +256,6 @@ public void requestURLNewStringBuffer() throws Exception {
227256
assertEquals("http://localhost/prefix/mvc-showcase", actual.getRequestURL().toString());
228257
}
229258

230-
@Test
231-
public void contextPathWithForwardedPrefix() throws Exception {
232-
this.request.addHeader(X_FORWARDED_PREFIX, "/prefix");
233-
this.request.setContextPath("/mvc-showcase");
234-
235-
String actual = filterAndGetContextPath();
236-
assertEquals("/prefix", actual);
237-
}
238-
239-
@Test
240-
public void contextPathWithForwardedPrefixTrailingSlash() throws Exception {
241-
this.request.addHeader(X_FORWARDED_PREFIX, "/prefix/");
242-
this.request.setContextPath("/mvc-showcase");
243-
244-
String actual = filterAndGetContextPath();
245-
assertEquals("/prefix", actual);
246-
}
247-
248-
@Test
249-
public void contextPathPreserveEncoding() throws Exception {
250-
this.request.setContextPath("/app%20");
251-
this.request.setRequestURI("/app%20/path/");
252-
HttpServletRequest actual = filterAndGetWrappedRequest();
253-
254-
assertEquals("/app%20", actual.getContextPath());
255-
assertEquals("/app%20/path/", actual.getRequestURI());
256-
assertEquals("http://localhost/app%20/path/", actual.getRequestURL().toString());
257-
}
258-
259259
@Test
260260
public void sendRedirectWithAbsolutePath() throws Exception {
261261
this.request.addHeader(X_FORWARDED_PROTO, "https");

0 commit comments

Comments
 (0)