final GWC gwc = GWC.get();
gwc.getConfig().setDirectWMSIntegrationEnabled(true);
final String layerName = BASIC_POLYGONS.getPrefix() + ":" + BASIC_POLYGONS.getLocalPart();
final String path = buildGetMap(true, layerName, "EPSG:4326", null) + "&tiled=true";
final String qualifiedName = super.getLayerId(BASIC_POLYGONS);
final GeoServerTileLayer tileLayer = (GeoServerTileLayer) gwc.getTileLayerByName(qualifiedName);
tileLayer.getLayerInfo().getResource().getMetadata().put(ResourceInfo.CACHING_ENABLED, "true");
tileLayer.getLayerInfo().getResource().getMetadata().put(ResourceInfo.CACHE_AGE_MAX, 3456);
MockHttpServletResponse response = getAsServletResponse(path);
String cacheControl = response.getHeader("Cache-Control");
assertEquals("max-age=3456", cacheControl);
assertNotNull(response.getHeader("Last-Modified"));
tileLayer.getLayerInfo().getResource().getMetadata().put(ResourceInfo.CACHING_ENABLED, "false");
response = getAsServletResponse(path);
cacheControl = response.getHeader("Cache-Control");
assertEquals("no-cache", cacheControl);
// make sure a boolean is handled, too - see comment in CachingWebMapService
tileLayer.getLayerInfo().getResource().getMetadata().put(ResourceInfo.CACHING_ENABLED, Boolean.FALSE);
response = getAsServletResponse(path);
cacheControl = response.getHeader("Cache-Control");
assertEquals("no-cache", cacheControl);
}