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