use of org.springframework.web.servlet.resource.VersionResourceResolver in project spring-boot by spring-projects.
the class WebMvcAutoConfigurationTests method resourceHandlerContentStrategyEnabled.
@Test
public void resourceHandlerContentStrategyEnabled() throws Exception {
load("spring.resources.chain.strategy.content.enabled:true", "spring.resources.chain.strategy.content.paths:/**,/*.png");
assertThat(getResourceResolvers("/webjars/**")).hasSize(3);
assertThat(getResourceTransformers("/webjars/**")).hasSize(2);
assertThat(getResourceResolvers("/**")).extractingResultOf("getClass").containsOnly(CachingResourceResolver.class, VersionResourceResolver.class, PathResourceResolver.class);
assertThat(getResourceTransformers("/**")).extractingResultOf("getClass").containsOnly(CachingResourceTransformer.class, CssLinkResourceTransformer.class);
VersionResourceResolver resolver = (VersionResourceResolver) getResourceResolvers("/**").get(1);
assertThat(resolver.getStrategyMap().get("/*.png")).isInstanceOf(ContentVersionStrategy.class);
}
use of org.springframework.web.servlet.resource.VersionResourceResolver in project spring-boot by spring-projects.
the class WebMvcAutoConfigurationTests method resourceHandlerChainCustomized.
@Test
public void resourceHandlerChainCustomized() throws Exception {
load("spring.resources.chain.enabled:true", "spring.resources.chain.cache:false", "spring.resources.chain.strategy.content.enabled:true", "spring.resources.chain.strategy.content.paths:/**,/*.png", "spring.resources.chain.strategy.fixed.enabled:true", "spring.resources.chain.strategy.fixed.version:test", "spring.resources.chain.strategy.fixed.paths:/**/*.js", "spring.resources.chain.html-application-cache:true", "spring.resources.chain.gzipped:true");
assertThat(getResourceResolvers("/webjars/**")).hasSize(3);
assertThat(getResourceTransformers("/webjars/**")).hasSize(2);
assertThat(getResourceResolvers("/**")).extractingResultOf("getClass").containsOnly(VersionResourceResolver.class, GzipResourceResolver.class, PathResourceResolver.class);
assertThat(getResourceTransformers("/**")).extractingResultOf("getClass").containsOnly(CssLinkResourceTransformer.class, AppCacheManifestTransformer.class);
VersionResourceResolver resolver = (VersionResourceResolver) getResourceResolvers("/**").get(0);
assertThat(resolver.getStrategyMap().get("/*.png")).isInstanceOf(ContentVersionStrategy.class);
assertThat(resolver.getStrategyMap().get("/**/*.js")).isInstanceOf(FixedVersionStrategy.class);
}
Aggregations