|
|
|
@ -38,12 +38,6 @@ public class WebMvcTagsTests {
|
|
|
|
|
|
|
|
|
|
private final MockHttpServletResponse response = new MockHttpServletResponse();
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void uriTrailingSlashesAreSuppressed() {
|
|
|
|
|
this.request.setPathInfo("//spring/");
|
|
|
|
|
assertThat(WebMvcTags.uri(this.request, null).getValue()).isEqualTo("/spring");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void uriTagValueIsBestMatchingPatternWhenAvailable() {
|
|
|
|
|
this.request.setAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE,
|
|
|
|
@ -53,6 +47,23 @@ public class WebMvcTagsTests {
|
|
|
|
|
assertThat(tag.getValue()).isEqualTo("/spring");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void uriTagValueIsRootWhenRequestHasNoPatternOrPathInfo() {
|
|
|
|
|
assertThat(WebMvcTags.uri(this.request, null).getValue()).isEqualTo("root");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void uriTagValueIsRootWhenRequestHasNoPatternAndSlashPathInfo() {
|
|
|
|
|
this.request.setPathInfo("/");
|
|
|
|
|
assertThat(WebMvcTags.uri(this.request, null).getValue()).isEqualTo("root");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void uriTagValueIsUnknownWhenRequestHasNoPatternAndNonRootPathInfo() {
|
|
|
|
|
this.request.setPathInfo("/example");
|
|
|
|
|
assertThat(WebMvcTags.uri(this.request, null).getValue()).isEqualTo("UNKNOWN");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
public void uriTagValueIsRedirectionWhenResponseStatusIs3xx() {
|
|
|
|
|
this.response.setStatus(301);
|
|
|
|
|