WebRequest webRequest = new WebRequest(new URL(
"http://localhost/rfRes/org.richfaces.resource.CacheableResourceImpl.jsf"));
webRequest.getAdditionalHeaders().put(ECHO_HEADER, "ping?");
WebResponse webResponse = webClient.loadWebResponse(webRequest);
assertEquals(HttpServletResponse.SC_OK, webResponse.getStatusCode());
assertEquals(ResourceUtils.formatHttpDate(lastModified.getTime()), webResponse.getResponseHeaderValue("Last-Modified"));
assertEquals(ResourceUtils.formatHttpDate(currentTime.getTime()), webResponse.getResponseHeaderValue("Date"));
assertEquals(ResourceUtils.formatHttpDate(expires.getTime()), webResponse.getResponseHeaderValue("Expires"));
assertEquals("max-age=1209600", webResponse.getResponseHeaderValue("Cache-Control"));
assertTrue(webResponse.getResponseHeaderValue("Content-Type").startsWith("text/plain"));
assertEquals("W/\"" + "ping?".length() + "-" + lastModified.getTime() + "\"",
webResponse.getResponseHeaderValue("ETag"));
assertNull(webResponse.getResponseHeaderValue("Pragma"));
assertEquals("ping?", webResponse.getContentAsString("US-ASCII"));
webRequest.getAdditionalHeaders().put(ECHO_HEADER, "pong");
WebResponse cachedWebResponse = webClient.loadWebResponse(webRequest);
assertEquals(HttpServletResponse.SC_OK, cachedWebResponse.getStatusCode());
assertEquals("ping?", cachedWebResponse.getContentAsString("US-ASCII"));
webRequest.getAdditionalHeaders().put(IF_MODIFIED_SINCE, ResourceUtils.formatHttpDate(currentTime));
WebResponse cachedWebResponse2 = webClient.loadWebResponse(webRequest);
assertEquals(HttpServletResponse.SC_NOT_MODIFIED, cachedWebResponse2.getStatusCode());
}