org.springframework.web.servlet.resource.FixedVersionStrategy Java Examples
The following examples show how to use
org.springframework.web.servlet.resource.FixedVersionStrategy.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MvcNamespaceTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void testResourcesWithResolversTransformersCustom() throws Exception { loadBeanDefinitions("mvc-config-resources-chain-no-auto.xml"); SimpleUrlHandlerMapping mapping = appContext.getBean(SimpleUrlHandlerMapping.class); assertNotNull(mapping); assertNotNull(mapping.getUrlMap().get("/resources/**")); ResourceHttpRequestHandler handler = appContext.getBean((String) mapping.getUrlMap().get("/resources/**"), ResourceHttpRequestHandler.class); assertNotNull(handler); assertThat(handler.getCacheControl().getHeaderValue(), Matchers.equalTo(CacheControl.maxAge(1, TimeUnit.HOURS) .sMaxAge(30, TimeUnit.MINUTES).cachePublic().getHeaderValue())); List<ResourceResolver> resolvers = handler.getResourceResolvers(); assertThat(resolvers, Matchers.hasSize(3)); assertThat(resolvers.get(0), Matchers.instanceOf(VersionResourceResolver.class)); assertThat(resolvers.get(1), Matchers.instanceOf(EncodedResourceResolver.class)); assertThat(resolvers.get(2), Matchers.instanceOf(PathResourceResolver.class)); VersionResourceResolver versionResolver = (VersionResourceResolver) resolvers.get(0); assertThat(versionResolver.getStrategyMap().get("/**/*.js"), Matchers.instanceOf(FixedVersionStrategy.class)); assertThat(versionResolver.getStrategyMap().get("/**"), Matchers.instanceOf(ContentVersionStrategy.class)); List<ResourceTransformer> transformers = handler.getResourceTransformers(); assertThat(transformers, Matchers.hasSize(2)); assertThat(transformers.get(0), Matchers.instanceOf(CachingResourceTransformer.class)); assertThat(transformers.get(1), Matchers.instanceOf(AppCacheManifestTransformer.class)); }
Example #2
Source File: MvcNamespaceTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void testResourcesWithResolversTransformersCustom() throws Exception { loadBeanDefinitions("mvc-config-resources-chain-no-auto.xml"); SimpleUrlHandlerMapping mapping = appContext.getBean(SimpleUrlHandlerMapping.class); assertNotNull(mapping); assertNotNull(mapping.getUrlMap().get("/resources/**")); ResourceHttpRequestHandler handler = appContext.getBean((String) mapping.getUrlMap().get("/resources/**"), ResourceHttpRequestHandler.class); assertNotNull(handler); assertThat(handler.getCacheControl().getHeaderValue(), Matchers.equalTo(CacheControl.maxAge(1, TimeUnit.HOURS) .sMaxAge(30, TimeUnit.MINUTES).cachePublic().getHeaderValue())); List<ResourceResolver> resolvers = handler.getResourceResolvers(); assertThat(resolvers, Matchers.hasSize(3)); assertThat(resolvers.get(0), Matchers.instanceOf(VersionResourceResolver.class)); assertThat(resolvers.get(1), Matchers.instanceOf(EncodedResourceResolver.class)); assertThat(resolvers.get(2), Matchers.instanceOf(PathResourceResolver.class)); VersionResourceResolver versionResolver = (VersionResourceResolver) resolvers.get(0); assertThat(versionResolver.getStrategyMap().get("/**/*.js"), Matchers.instanceOf(FixedVersionStrategy.class)); assertThat(versionResolver.getStrategyMap().get("/**"), Matchers.instanceOf(ContentVersionStrategy.class)); List<ResourceTransformer> transformers = handler.getResourceTransformers(); assertThat(transformers, Matchers.hasSize(2)); assertThat(transformers.get(0), Matchers.instanceOf(CachingResourceTransformer.class)); assertThat(transformers.get(1), Matchers.instanceOf(AppCacheManifestTransformer.class)); }
Example #3
Source File: MvcNamespaceTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testResourcesWithResolversTransformers() throws Exception { loadBeanDefinitions("mvc-config-resources-chain.xml", 11); SimpleUrlHandlerMapping mapping = appContext.getBean(SimpleUrlHandlerMapping.class); assertNotNull(mapping); assertNotNull(mapping.getUrlMap().get("/resources/**")); ResourceHttpRequestHandler handler = appContext.getBean((String) mapping.getUrlMap().get("/resources/**"), ResourceHttpRequestHandler.class); assertNotNull(handler); List<ResourceResolver> resolvers = handler.getResourceResolvers(); assertThat(resolvers, Matchers.hasSize(4)); assertThat(resolvers.get(0), Matchers.instanceOf(CachingResourceResolver.class)); assertThat(resolvers.get(1), Matchers.instanceOf(VersionResourceResolver.class)); assertThat(resolvers.get(2), Matchers.instanceOf(WebJarsResourceResolver.class)); assertThat(resolvers.get(3), Matchers.instanceOf(PathResourceResolver.class)); CachingResourceResolver cachingResolver = (CachingResourceResolver) resolvers.get(0); assertThat(cachingResolver.getCache(), Matchers.instanceOf(ConcurrentMapCache.class)); assertEquals("test-resource-cache", cachingResolver.getCache().getName()); VersionResourceResolver versionResolver = (VersionResourceResolver) resolvers.get(1); assertThat(versionResolver.getStrategyMap().get("/**/*.js"), Matchers.instanceOf(FixedVersionStrategy.class)); assertThat(versionResolver.getStrategyMap().get("/**"), Matchers.instanceOf(ContentVersionStrategy.class)); List<ResourceTransformer> transformers = handler.getResourceTransformers(); assertThat(transformers, Matchers.hasSize(3)); assertThat(transformers.get(0), Matchers.instanceOf(CachingResourceTransformer.class)); assertThat(transformers.get(1), Matchers.instanceOf(CssLinkResourceTransformer.class)); assertThat(transformers.get(2), Matchers.instanceOf(AppCacheManifestTransformer.class)); CachingResourceTransformer cachingTransformer = (CachingResourceTransformer) transformers.get(0); assertThat(cachingTransformer.getCache(), Matchers.instanceOf(ConcurrentMapCache.class)); assertEquals("test-resource-cache", cachingTransformer.getCache().getName()); }
Example #4
Source File: MvcNamespaceTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void testResourcesWithResolversTransformersCustom() throws Exception { loadBeanDefinitions("mvc-config-resources-chain-no-auto.xml", 12); SimpleUrlHandlerMapping mapping = appContext.getBean(SimpleUrlHandlerMapping.class); assertNotNull(mapping); assertNotNull(mapping.getUrlMap().get("/resources/**")); ResourceHttpRequestHandler handler = appContext.getBean((String) mapping.getUrlMap().get("/resources/**"), ResourceHttpRequestHandler.class); assertNotNull(handler); assertThat(handler.getCacheControl().getHeaderValue(), Matchers.equalTo(CacheControl.maxAge(1, TimeUnit.HOURS) .sMaxAge(30, TimeUnit.MINUTES).cachePublic().getHeaderValue())); List<ResourceResolver> resolvers = handler.getResourceResolvers(); assertThat(resolvers, Matchers.hasSize(3)); assertThat(resolvers.get(0), Matchers.instanceOf(VersionResourceResolver.class)); assertThat(resolvers.get(1), Matchers.instanceOf(GzipResourceResolver.class)); assertThat(resolvers.get(2), Matchers.instanceOf(PathResourceResolver.class)); VersionResourceResolver versionResolver = (VersionResourceResolver) resolvers.get(0); assertThat(versionResolver.getStrategyMap().get("/**/*.js"), Matchers.instanceOf(FixedVersionStrategy.class)); assertThat(versionResolver.getStrategyMap().get("/**"), Matchers.instanceOf(ContentVersionStrategy.class)); List<ResourceTransformer> transformers = handler.getResourceTransformers(); assertThat(transformers, Matchers.hasSize(2)); assertThat(transformers.get(0), Matchers.instanceOf(CachingResourceTransformer.class)); assertThat(transformers.get(1), Matchers.instanceOf(AppCacheManifestTransformer.class)); }
Example #5
Source File: MvcNamespaceTests.java From spring-analysis-note with MIT License | 4 votes |
@Test public void testResourcesWithResolversTransformers() throws Exception { loadBeanDefinitions("mvc-config-resources-chain.xml"); SimpleUrlHandlerMapping mapping = appContext.getBean(SimpleUrlHandlerMapping.class); assertNotNull(mapping); assertNotNull(mapping.getUrlMap().get("/resources/**")); String beanName = (String) mapping.getUrlMap().get("/resources/**"); ResourceHttpRequestHandler handler = appContext.getBean(beanName, ResourceHttpRequestHandler.class); assertNotNull(handler); assertNotNull(handler.getUrlPathHelper()); List<ResourceResolver> resolvers = handler.getResourceResolvers(); assertThat(resolvers, Matchers.hasSize(4)); assertThat(resolvers.get(0), Matchers.instanceOf(CachingResourceResolver.class)); assertThat(resolvers.get(1), Matchers.instanceOf(VersionResourceResolver.class)); assertThat(resolvers.get(2), Matchers.instanceOf(WebJarsResourceResolver.class)); assertThat(resolvers.get(3), Matchers.instanceOf(PathResourceResolver.class)); CachingResourceResolver cachingResolver = (CachingResourceResolver) resolvers.get(0); assertThat(cachingResolver.getCache(), Matchers.instanceOf(ConcurrentMapCache.class)); assertEquals("test-resource-cache", cachingResolver.getCache().getName()); VersionResourceResolver versionResolver = (VersionResourceResolver) resolvers.get(1); assertThat(versionResolver.getStrategyMap().get("/**/*.js"), Matchers.instanceOf(FixedVersionStrategy.class)); assertThat(versionResolver.getStrategyMap().get("/**"), Matchers.instanceOf(ContentVersionStrategy.class)); PathResourceResolver pathResolver = (PathResourceResolver) resolvers.get(3); Map<Resource, Charset> locationCharsets = pathResolver.getLocationCharsets(); assertEquals(1, locationCharsets.size()); assertEquals(StandardCharsets.ISO_8859_1, locationCharsets.values().iterator().next()); List<ResourceTransformer> transformers = handler.getResourceTransformers(); assertThat(transformers, Matchers.hasSize(3)); assertThat(transformers.get(0), Matchers.instanceOf(CachingResourceTransformer.class)); assertThat(transformers.get(1), Matchers.instanceOf(CssLinkResourceTransformer.class)); assertThat(transformers.get(2), Matchers.instanceOf(AppCacheManifestTransformer.class)); CachingResourceTransformer cachingTransformer = (CachingResourceTransformer) transformers.get(0); assertThat(cachingTransformer.getCache(), Matchers.instanceOf(ConcurrentMapCache.class)); assertEquals("test-resource-cache", cachingTransformer.getCache().getName()); }
Example #6
Source File: MvcNamespaceTests.java From java-technology-stack with MIT License | 4 votes |
@Test public void testResourcesWithResolversTransformers() throws Exception { loadBeanDefinitions("mvc-config-resources-chain.xml"); SimpleUrlHandlerMapping mapping = appContext.getBean(SimpleUrlHandlerMapping.class); assertNotNull(mapping); assertNotNull(mapping.getUrlMap().get("/resources/**")); String beanName = (String) mapping.getUrlMap().get("/resources/**"); ResourceHttpRequestHandler handler = appContext.getBean(beanName, ResourceHttpRequestHandler.class); assertNotNull(handler); assertNotNull(handler.getUrlPathHelper()); List<ResourceResolver> resolvers = handler.getResourceResolvers(); assertThat(resolvers, Matchers.hasSize(4)); assertThat(resolvers.get(0), Matchers.instanceOf(CachingResourceResolver.class)); assertThat(resolvers.get(1), Matchers.instanceOf(VersionResourceResolver.class)); assertThat(resolvers.get(2), Matchers.instanceOf(WebJarsResourceResolver.class)); assertThat(resolvers.get(3), Matchers.instanceOf(PathResourceResolver.class)); CachingResourceResolver cachingResolver = (CachingResourceResolver) resolvers.get(0); assertThat(cachingResolver.getCache(), Matchers.instanceOf(ConcurrentMapCache.class)); assertEquals("test-resource-cache", cachingResolver.getCache().getName()); VersionResourceResolver versionResolver = (VersionResourceResolver) resolvers.get(1); assertThat(versionResolver.getStrategyMap().get("/**/*.js"), Matchers.instanceOf(FixedVersionStrategy.class)); assertThat(versionResolver.getStrategyMap().get("/**"), Matchers.instanceOf(ContentVersionStrategy.class)); PathResourceResolver pathResolver = (PathResourceResolver) resolvers.get(3); Map<Resource, Charset> locationCharsets = pathResolver.getLocationCharsets(); assertEquals(1, locationCharsets.size()); assertEquals(StandardCharsets.ISO_8859_1, locationCharsets.values().iterator().next()); List<ResourceTransformer> transformers = handler.getResourceTransformers(); assertThat(transformers, Matchers.hasSize(3)); assertThat(transformers.get(0), Matchers.instanceOf(CachingResourceTransformer.class)); assertThat(transformers.get(1), Matchers.instanceOf(CssLinkResourceTransformer.class)); assertThat(transformers.get(2), Matchers.instanceOf(AppCacheManifestTransformer.class)); CachingResourceTransformer cachingTransformer = (CachingResourceTransformer) transformers.get(0); assertThat(cachingTransformer.getCache(), Matchers.instanceOf(ConcurrentMapCache.class)); assertEquals("test-resource-cache", cachingTransformer.getCache().getName()); }