use of org.springframework.web.servlet.resource.ResourceResolverChain in project spring-boot-admin by codecentric.
the class PreferMinifiedFilteringResourceResolverTest method test_resolveResource.
@Test
public void test_resolveResource() {
List<? extends Resource> resources = asList(new ClassPathResource("testResource.txt"), new ClassPathResource("application.properties"));
new PreferMinifiedFilteringResourceResolver(".min").resolveResource(null, null, resources, new ResourceResolverChain() {
@Override
public Resource resolveResource(HttpServletRequest request, String requestPath, List<? extends Resource> locations) {
assertThat(locations.size(), is(2));
assertThat(locations, contains((Resource) new ClassPathResource("testResource.min.txt"), (Resource) new ClassPathResource("application.properties")));
return null;
}
@Override
public String resolveUrlPath(String resourcePath, List<? extends Resource> locations) {
return null;
}
});
}
use of org.springframework.web.servlet.resource.ResourceResolverChain in project spring-boot-admin by codecentric.
the class ResourcePatternResolvingResourceResolverTest method test_resolveResource.
@Test
public void test_resolveResource() {
ResourceResolver resolver = new ResourcePatternResolvingResourceResolver(new PathMatchingResourcePatternResolver(), "classpath:/t*Resource.txt");
resolver.resolveResource(null, null, null, new ResourceResolverChain() {
@Override
public Resource resolveResource(HttpServletRequest request, String requestPath, List<? extends Resource> locations) {
assertThat(locations.size(), is(1));
assertThat(locations.get(0).getFilename(), is("testResource.txt"));
return null;
}
@Override
public String resolveUrlPath(String resourcePath, List<? extends Resource> locations) {
return null;
}
});
}
use of org.springframework.web.servlet.resource.ResourceResolverChain in project spring-boot-admin by codecentric.
the class ConcatenatingResourceResolverTest method test_resolveUrl.
@Test
public void test_resolveUrl() {
ResourceResolverChain chain = mock(ResourceResolverChain.class);
when(chain.resolveUrlPath(null, null)).thenReturn("/resources/resource.txt");
String url = new ConcatenatingResourceResolver(";".getBytes()).resolveUrlPath(null, null, chain);
assertThat(url, is("/resources/resource.txt"));
}
use of org.springframework.web.servlet.resource.ResourceResolverChain in project spring-boot-admin by codecentric.
the class PreferMinifiedFilteringResourceResolverTest method test_resolveUrl.
@Test
public void test_resolveUrl() {
ResourceResolverChain chain = mock(ResourceResolverChain.class);
when(chain.resolveUrlPath(null, null)).thenReturn("/resources/resource.txt");
String url = new PreferMinifiedFilteringResourceResolver("").resolveUrlPath(null, null, chain);
assertThat(url, is("/resources/resource.txt"));
}
use of org.springframework.web.servlet.resource.ResourceResolverChain in project spring-boot-admin by codecentric.
the class ResourcePatternResolvingResourceResolverTest method test_resolveUrl.
@Test
public void test_resolveUrl() {
ResourceResolverChain chain = mock(ResourceResolverChain.class);
when(chain.resolveUrlPath(null, null)).thenReturn("/resources/resource.txt");
String url = new ResourcePatternResolvingResourceResolver(null, null).resolveUrlPath(null, null, chain);
assertThat(url, is("/resources/resource.txt"));
}
Aggregations