Document acceptance test (implementation already passes):

"If a new cacheable...response is received from a resource while any
existing responses for the same resource are cached, the cache SHOULD
use the new response to reply to the current request."

http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.12


git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1058232 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Moore 2011-01-12 16:57:14 +00:00
parent 759fe0a755
commit 7b141fd52d
1 changed files with 37 additions and 0 deletions

View File

@ -1231,4 +1231,41 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
assertTrue(HttpTestUtils.semanticallyTransparent(resp5, result5));
}
/*
* "If a new cacheable response is received from a resource while any
* existing responses for the same resource are cached, the cache
* SHOULD use the new response to reply to the current request."
*
* http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html#sec13.12
*/
@Test
public void cacheShouldUpdateWithNewCacheableResponse()
throws Exception {
HttpRequest req1 = HttpTestUtils.makeDefaultRequest();
HttpResponse resp1 = HttpTestUtils.make200Response();
resp1.setHeader("Date", formatDate(tenSecondsAgo));
resp1.setHeader("Cache-Control", "max-age=3600");
resp1.setHeader("ETag", "\"etag1\"");
backendExpectsAnyRequest().andReturn(resp1);
HttpRequest req2 = HttpTestUtils.makeDefaultRequest();
req2.setHeader("Cache-Control", "max-age=0");
HttpResponse resp2 = HttpTestUtils.make200Response();
resp2.setHeader("Date", formatDate(now));
resp2.setHeader("Cache-Control", "max-age=3600");
resp2.setHeader("ETag", "\"etag2\"");
backendExpectsAnyRequest().andReturn(resp2);
HttpRequest req3 = HttpTestUtils.makeDefaultRequest();
replayMocks();
impl.execute(host, req1);
impl.execute(host, req2);
HttpResponse result = impl.execute(host, req3);
verifyMocks();
assertTrue(HttpTestUtils.semanticallyTransparent(resp2, result));
}
}