assertEquals(HttpServletResponse.SC_NOT_MODIFIED, cachedWebResponse2.getStatusCode());
}
public void testReadNonCacheableResource() throws Exception {
WebRequest webRequest = new WebRequest(new URL(
"http://localhost/rfRes/org.richfaces.resource.NonCacheableResourceImpl.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("0", webResponse.getResponseHeaderValue("Expires"));
assertEquals("max-age=0, no-store, no-cache", webResponse.getResponseHeaderValue("Cache-Control"));
assertTrue(webResponse.getResponseHeaderValue("Content-Type").startsWith("text/plain"));
assertNull(webResponse.getResponseHeaderValue("ETag"));
assertEquals("no-cache", 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("pong", cachedWebResponse.getContentAsString("US-ASCII"));
webRequest.getAdditionalHeaders().put(IF_MODIFIED_SINCE, ResourceUtils.formatHttpDate(currentTime));
WebResponse cachedWebResponse2 = webClient.loadWebResponse(webRequest);
assertEquals(HttpServletResponse.SC_OK, cachedWebResponse2.getStatusCode());
}