use of org.springframework.web.util.UrlPathHelper in project spring-framework by spring-projects.
the class PathResourceResolverTests method relativePathEncodedForUrlResource.
@Test
public void relativePathEncodedForUrlResource() throws Exception {
TestUrlResource location = new TestUrlResource("file:///tmp");
List<TestUrlResource> locations = Collections.singletonList(location);
// ISO-8859-1
this.resolver.setUrlPathHelper(new UrlPathHelper());
this.resolver.setLocationCharsets(Collections.singletonMap(location, StandardCharsets.ISO_8859_1));
this.resolver.resolveResource(new MockHttpServletRequest(), "/Ä ;ä.txt", locations, null);
assertThat(location.getSavedRelativePath()).isEqualTo("%C4%20%3B%E4.txt");
// UTF-8
this.resolver.setLocationCharsets(Collections.singletonMap(location, StandardCharsets.UTF_8));
this.resolver.resolveResource(new MockHttpServletRequest(), "/Ä ;ä.txt", locations, null);
assertThat(location.getSavedRelativePath()).isEqualTo("%C3%84%20%3B%C3%A4.txt");
// UTF-8 by default
this.resolver.setLocationCharsets(Collections.emptyMap());
this.resolver.resolveResource(new MockHttpServletRequest(), "/Ä ;ä.txt", locations, null);
assertThat(location.getSavedRelativePath()).isEqualTo("%C3%84%20%3B%C3%A4.txt");
}
use of org.springframework.web.util.UrlPathHelper in project spring-security by spring-projects.
the class AntPathRequestMatcherTests method matchesWhenUrlPathHelperThenMatchesOnRequestUri.
@Test
public void matchesWhenUrlPathHelperThenMatchesOnRequestUri() {
AntPathRequestMatcher matcher = new AntPathRequestMatcher("/foo/bar", null, true, new UrlPathHelper());
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo/bar");
assertThat(matcher.matches(request)).isTrue();
}
Aggregations