Streamlined WebContentGenerator API variants: checkRequest, prepareResponse, applyCacheControl, applyCacheSeconds

Issue: SPR-11792
This commit is contained in:
Juergen Hoeller
2015-07-21 20:33:03 +02:00
parent b277c081e7
commit 7c22d60fd8
10 changed files with 258 additions and 230 deletions

View File

@@ -392,8 +392,6 @@ public class MvcNamespaceTests {
ResourceHttpRequestHandler.class);
assertNotNull(handler);
assertEquals(3600, handler.getCacheSeconds());
assertThat(handler.getCacheControl().getHeaderValue(),
Matchers.equalTo(CacheControl.maxAge(1, TimeUnit.HOURS).getHeaderValue()));
}
@Test

View File

@@ -90,8 +90,6 @@ public class ResourceHandlerRegistryTests {
this.registration.setCachePeriod(0);
assertEquals(0, getHandler("/resources/**").getCacheSeconds());
assertThat(getHandler("/resources/**").getCacheControl().getHeaderValue(),
Matchers.equalTo(CacheControl.noStore().getHeaderValue()));
}
@Test

View File

@@ -137,6 +137,7 @@ public class WebContentInterceptorTests {
public void http10CachingConfigAndSpecificMapping() throws Exception {
WebContentInterceptor interceptor = new WebContentInterceptor();
interceptor.setCacheSeconds(0);
interceptor.setUseExpiresHeader(true);
interceptor.setAlwaysMustRevalidate(true);
Properties mappings = new Properties();
mappings.setProperty("**/*.cache.html", "10");

View File

@@ -110,7 +110,7 @@ public class ResourceHttpRequestHandlerTests {
@Test
@SuppressWarnings("deprecation")
public void getResourcePreviousBehaviorCache() throws Exception {
public void getResourceHttp10BehaviorCache() throws Exception {
this.request.setAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, "foo.css");
this.handler.setCacheSeconds(3600);
this.handler.setUseExpiresHeader(true);
@@ -126,15 +126,17 @@ public class ResourceHttpRequestHandlerTests {
@Test
@SuppressWarnings("deprecation")
public void getResourcePreviousBehaviorNoCache() throws Exception {
public void getResourceHttp10BehaviorNoCache() throws Exception {
this.request.setAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, "foo.css");
this.handler.setCacheSeconds(0);
this.handler.setUseCacheControlNoStore(true);
this.handler.setUseExpiresHeader(true);
this.handler.setUseCacheControlNoStore(false);
this.handler.setUseCacheControlHeader(true);
this.handler.handleRequest(this.request, this.response);
assertEquals("no-cache", this.response.getHeader("Pragma"));
assertThat(this.response.getHeaderValues("Cache-Control"), Matchers.contains("no-cache", "no-store"));
assertThat(this.response.getHeaderValues("Cache-Control"), Matchers.iterableWithSize(1));
assertEquals("no-cache", this.response.getHeader("Cache-Control"));
assertTrue(dateHeaderAsLong("Expires") <= System.currentTimeMillis());
assertTrue(this.response.containsHeader("Last-Modified"));
assertEquals(dateHeaderAsLong("Last-Modified") / 1000, resourceLastModified("test/foo.css") / 1000);