Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Aug 22, 2021
1 parent 97a89d6 commit cecd2ee
Showing 1 changed file with 43 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @author Juergen Hoeller
* @author Costin Leau
*/
public class UrlPathHelperTests {
class UrlPathHelperTests {

private static final String WEBSPHERE_URI_ATTRIBUTE = "com.ibm.websphere.servlet.uri_non_decoded";

Expand All @@ -43,31 +43,31 @@ public class UrlPathHelperTests {


@Test
public void getPathWithinApplication() {
void getPathWithinApplication() {
request.setContextPath("/petclinic");
request.setRequestURI("/petclinic/welcome.html");

assertThat(helper.getPathWithinApplication(request)).as("Incorrect path returned").isEqualTo("/welcome.html");
}

@Test
public void getPathWithinApplicationForRootWithNoLeadingSlash() {
void getPathWithinApplicationForRootWithNoLeadingSlash() {
request.setContextPath("/petclinic");
request.setRequestURI("/petclinic");

assertThat(helper.getPathWithinApplication(request)).as("Incorrect root path returned").isEqualTo("/");
}

@Test
public void getPathWithinApplicationForSlashContextPath() {
void getPathWithinApplicationForSlashContextPath() {
request.setContextPath("/");
request.setRequestURI("/welcome.html");

assertThat(helper.getPathWithinApplication(request)).as("Incorrect path returned").isEqualTo("/welcome.html");
}

@Test
public void getPathWithinServlet() {
void getPathWithinServlet() {
request.setContextPath("/petclinic");
request.setServletPath("/main");
request.setRequestURI("/petclinic/main/welcome.html");
Expand All @@ -76,7 +76,7 @@ public void getPathWithinServlet() {
}

@Test
public void alwaysUseFullPath() {
void alwaysUseFullPath() {
helper.setAlwaysUseFullPath(true);
request.setContextPath("/petclinic");
request.setServletPath("/main");
Expand All @@ -88,7 +88,7 @@ public void alwaysUseFullPath() {
// SPR-11101

@Test
public void getPathWithinServletWithoutUrlDecoding() {
void getPathWithinServletWithoutUrlDecoding() {
request.setContextPath("/SPR-11101");
request.setServletPath("/test_url_decoding/a/b");
request.setRequestURI("/test_url_decoding/a%2Fb");
Expand All @@ -100,7 +100,7 @@ public void getPathWithinServletWithoutUrlDecoding() {
}

@Test
public void getRequestUri() {
void getRequestUri() {
request.setRequestURI("/welcome.html");
assertThat(helper.getRequestUri(request)).as("Incorrect path returned").isEqualTo("/welcome.html");

Expand All @@ -112,7 +112,7 @@ public void getRequestUri() {
}

@Test
public void getRequestRemoveSemicolonContent() throws UnsupportedEncodingException {
void getRequestRemoveSemicolonContent() throws UnsupportedEncodingException {
helper.setRemoveSemicolonContent(true);

request.setRequestURI("/foo;f=F;o=O;o=O/bar;b=B;a=A;r=R");
Expand All @@ -127,7 +127,7 @@ public void getRequestRemoveSemicolonContent() throws UnsupportedEncodingExcepti
}

@Test
public void getRequestKeepSemicolonContent() {
void getRequestKeepSemicolonContent() {
helper.setRemoveSemicolonContent(false);

testKeepSemicolonContent("/foo;a=b;c=d", "/foo;a=b;c=d");
Expand All @@ -146,7 +146,7 @@ private void testKeepSemicolonContent(String requestUri, String expectedPath) {
}

@Test
public void getLookupPathWithSemicolonContent() {
void getLookupPathWithSemicolonContent() {
helper.setRemoveSemicolonContent(false);

request.setContextPath("/petclinic");
Expand All @@ -157,7 +157,7 @@ public void getLookupPathWithSemicolonContent() {
}

@Test
public void getLookupPathWithSemicolonContentAndNullPathInfo() {
void getLookupPathWithSemicolonContentAndNullPathInfo() {
helper.setRemoveSemicolonContent(false);

request.setContextPath("/petclinic");
Expand All @@ -168,7 +168,7 @@ public void getLookupPathWithSemicolonContentAndNullPathInfo() {
}

@Test // gh-27303
public void defaultInstanceReadOnlyBehavior() {
void defaultInstanceReadOnlyBehavior() {
UrlPathHelper helper = UrlPathHelper.defaultInstance;

assertThatIllegalArgumentException()
Expand Down Expand Up @@ -200,7 +200,7 @@ public void defaultInstanceReadOnlyBehavior() {
//

@Test
public void tomcatDefaultServletRoot() throws Exception {
void tomcatDefaultServletRoot() throws Exception {
request.setContextPath("/test");
request.setPathInfo(null);
request.setServletPath("/");
Expand All @@ -209,7 +209,7 @@ public void tomcatDefaultServletRoot() throws Exception {
}

@Test
public void tomcatDefaultServletFile() throws Exception {
void tomcatDefaultServletFile() throws Exception {
request.setContextPath("/test");
request.setPathInfo(null);
request.setServletPath("/foo");
Expand All @@ -219,7 +219,7 @@ public void tomcatDefaultServletFile() throws Exception {
}

@Test
public void tomcatDefaultServletFolder() throws Exception {
void tomcatDefaultServletFolder() throws Exception {
request.setContextPath("/test");
request.setPathInfo(null);
request.setServletPath("/foo/");
Expand All @@ -230,7 +230,7 @@ public void tomcatDefaultServletFolder() throws Exception {

//SPR-12372 & SPR-13455
@Test
public void removeDuplicateSlashesInPath() throws Exception {
void removeDuplicateSlashesInPath() throws Exception {
request.setContextPath("/SPR-12372");
request.setPathInfo(null);
request.setServletPath("/foo/bar/");
Expand All @@ -251,7 +251,7 @@ public void removeDuplicateSlashesInPath() throws Exception {
}

@Test
public void wasDefaultServletRoot() throws Exception {
void wasDefaultServletRoot() throws Exception {
request.setContextPath("/test");
request.setPathInfo("/");
request.setServletPath("");
Expand All @@ -262,13 +262,13 @@ public void wasDefaultServletRoot() throws Exception {
}

@Test
public void wasDefaultServletRootWithCompliantSetting() throws Exception {
void wasDefaultServletRootWithCompliantSetting() throws Exception {
request.setAttribute(WEBSPHERE_URI_ATTRIBUTE, "/test/");
tomcatDefaultServletRoot();
}

@Test
public void wasDefaultServletFile() throws Exception {
void wasDefaultServletFile() throws Exception {
request.setContextPath("/test");
request.setPathInfo("/foo");
request.setServletPath("");
Expand All @@ -279,13 +279,13 @@ public void wasDefaultServletFile() throws Exception {
}

@Test
public void wasDefaultServletFileWithCompliantSetting() throws Exception {
void wasDefaultServletFileWithCompliantSetting() throws Exception {
request.setAttribute(WEBSPHERE_URI_ATTRIBUTE, "/test/foo");
tomcatDefaultServletFile();
}

@Test
public void wasDefaultServletFolder() throws Exception {
void wasDefaultServletFolder() throws Exception {
request.setContextPath("/test");
request.setPathInfo("/foo/");
request.setServletPath("");
Expand All @@ -296,7 +296,7 @@ public void wasDefaultServletFolder() throws Exception {
}

@Test
public void wasDefaultServletFolderWithCompliantSetting() throws Exception {
void wasDefaultServletFolderWithCompliantSetting() throws Exception {
UrlPathHelper.websphereComplianceFlag = true;
try {
request.setAttribute(WEBSPHERE_URI_ATTRIBUTE, "/test/foo/");
Expand All @@ -313,7 +313,7 @@ public void wasDefaultServletFolderWithCompliantSetting() throws Exception {
//

@Test
public void tomcatCasualServletRoot() throws Exception {
void tomcatCasualServletRoot() throws Exception {
request.setContextPath("/test");
request.setPathInfo("/");
request.setServletPath("/foo");
Expand All @@ -323,9 +323,9 @@ public void tomcatCasualServletRoot() throws Exception {
}

@Disabled
// test the root mapping for /foo/* w/o a trailing slash - <host>/<context>/foo
@Test
public void tomcatCasualServletRootWithMissingSlash() throws Exception {
// test the root mapping for /foo/* w/o a trailing slash - <host>/<context>/foo
void tomcatCasualServletRootWithMissingSlash() throws Exception {
request.setContextPath("/test");
request.setPathInfo(null);
request.setServletPath("/foo");
Expand All @@ -335,7 +335,7 @@ public void tomcatCasualServletRootWithMissingSlash() throws Exception {
}

@Test
public void tomcatCasualServletFile() throws Exception {
void tomcatCasualServletFile() throws Exception {
request.setContextPath("/test");
request.setPathInfo("/foo");
request.setServletPath("/foo");
Expand All @@ -345,7 +345,7 @@ public void tomcatCasualServletFile() throws Exception {
}

@Test
public void tomcatCasualServletFolder() throws Exception {
void tomcatCasualServletFolder() throws Exception {
request.setContextPath("/test");
request.setPathInfo("/foo/");
request.setServletPath("/foo");
Expand All @@ -355,7 +355,7 @@ public void tomcatCasualServletFolder() throws Exception {
}

@Test
public void wasCasualServletRoot() throws Exception {
void wasCasualServletRoot() throws Exception {
request.setContextPath("/test");
request.setPathInfo(null);
request.setServletPath("/foo/");
Expand All @@ -366,15 +366,15 @@ public void wasCasualServletRoot() throws Exception {
}

@Test
public void wasCasualServletRootWithCompliantSetting() throws Exception {
void wasCasualServletRootWithCompliantSetting() throws Exception {
request.setAttribute(WEBSPHERE_URI_ATTRIBUTE, "/test/foo/");
tomcatCasualServletRoot();
}

@Disabled
// test the root mapping for /foo/* w/o a trailing slash - <host>/<context>/foo
@Test
public void wasCasualServletRootWithMissingSlash() throws Exception {
// test the root mapping for /foo/* w/o a trailing slash - <host>/<context>/foo
void wasCasualServletRootWithMissingSlash() throws Exception {
request.setContextPath("/test");
request.setPathInfo(null);
request.setServletPath("/foo");
Expand All @@ -386,13 +386,13 @@ public void wasCasualServletRootWithMissingSlash() throws Exception {

@Disabled
@Test
public void wasCasualServletRootWithMissingSlashWithCompliantSetting() throws Exception {
void wasCasualServletRootWithMissingSlashWithCompliantSetting() throws Exception {
request.setAttribute(WEBSPHERE_URI_ATTRIBUTE, "/test/foo");
tomcatCasualServletRootWithMissingSlash();
}

@Test
public void wasCasualServletFile() throws Exception {
void wasCasualServletFile() throws Exception {
request.setContextPath("/test");
request.setPathInfo("/foo");
request.setServletPath("/foo");
Expand All @@ -403,13 +403,13 @@ public void wasCasualServletFile() throws Exception {
}

@Test
public void wasCasualServletFileWithCompliantSetting() throws Exception {
void wasCasualServletFileWithCompliantSetting() throws Exception {
request.setAttribute(WEBSPHERE_URI_ATTRIBUTE, "/test/foo/foo");
tomcatCasualServletFile();
}

@Test
public void wasCasualServletFolder() throws Exception {
void wasCasualServletFolder() throws Exception {
request.setContextPath("/test");
request.setPathInfo("/foo/");
request.setServletPath("/foo");
Expand All @@ -420,47 +420,47 @@ public void wasCasualServletFolder() throws Exception {
}

@Test
public void wasCasualServletFolderWithCompliantSetting() throws Exception {
void wasCasualServletFolderWithCompliantSetting() throws Exception {
request.setAttribute(WEBSPHERE_URI_ATTRIBUTE, "/test/foo/foo/");
tomcatCasualServletFolder();
}

@Test
public void getOriginatingRequestUri() {
void getOriginatingRequestUri() {
request.setAttribute(WebUtils.FORWARD_REQUEST_URI_ATTRIBUTE, "/path");
request.setRequestURI("/forwarded");
assertThat(helper.getOriginatingRequestUri(request)).isEqualTo("/path");
}

@Test
public void getOriginatingRequestUriWebsphere() {
void getOriginatingRequestUriWebsphere() {
request.setAttribute(WEBSPHERE_URI_ATTRIBUTE, "/path");
request.setRequestURI("/forwarded");
assertThat(helper.getOriginatingRequestUri(request)).isEqualTo("/path");
}

@Test
public void getOriginatingRequestUriDefault() {
void getOriginatingRequestUriDefault() {
request.setRequestURI("/forwarded");
assertThat(helper.getOriginatingRequestUri(request)).isEqualTo("/forwarded");
}

@Test
public void getOriginatingQueryString() {
void getOriginatingQueryString() {
request.setQueryString("forward=on");
request.setAttribute(WebUtils.FORWARD_REQUEST_URI_ATTRIBUTE, "/path");
request.setAttribute(WebUtils.FORWARD_QUERY_STRING_ATTRIBUTE, "original=on");
assertThat(this.helper.getOriginatingQueryString(request)).isEqualTo("original=on");
}

@Test
public void getOriginatingQueryStringNotPresent() {
void getOriginatingQueryStringNotPresent() {
request.setQueryString("forward=true");
assertThat(this.helper.getOriginatingQueryString(request)).isEqualTo("forward=true");
}

@Test
public void getOriginatingQueryStringIsNull() {
void getOriginatingQueryStringIsNull() {
request.setQueryString("forward=true");
request.setAttribute(WebUtils.FORWARD_REQUEST_URI_ATTRIBUTE, "/path");
assertThat(this.helper.getOriginatingQueryString(request)).isNull();
Expand Down

0 comments on commit cecd2ee

Please sign in to comment.