TABS -> SPACES
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1044639 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f1add71205
commit
ef148fc522
|
@ -816,53 +816,53 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testSendsAllVariantEtagsInConditionalRequest()
|
public void testSendsAllVariantEtagsInConditionalRequest()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
HttpRequest req1 = new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1);
|
HttpRequest req1 = new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1);
|
||||||
req1.setHeader("User-Agent","agent1");
|
req1.setHeader("User-Agent","agent1");
|
||||||
HttpResponse resp1 = HttpTestUtils.make200Response();
|
HttpResponse resp1 = HttpTestUtils.make200Response();
|
||||||
resp1.setHeader("Cache-Control","max-age=3600");
|
resp1.setHeader("Cache-Control","max-age=3600");
|
||||||
resp1.setHeader("Vary","User-Agent");
|
resp1.setHeader("Vary","User-Agent");
|
||||||
resp1.setHeader("Etag","\"etag1\"");
|
resp1.setHeader("Etag","\"etag1\"");
|
||||||
|
|
||||||
backendExpectsAnyRequest().andReturn(resp1);
|
backendExpectsAnyRequest().andReturn(resp1);
|
||||||
|
|
||||||
HttpRequest req2 = new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1);
|
HttpRequest req2 = new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1);
|
||||||
req2.setHeader("User-Agent","agent2");
|
req2.setHeader("User-Agent","agent2");
|
||||||
HttpResponse resp2 = HttpTestUtils.make200Response();
|
HttpResponse resp2 = HttpTestUtils.make200Response();
|
||||||
resp2.setHeader("Cache-Control","max-age=3600");
|
resp2.setHeader("Cache-Control","max-age=3600");
|
||||||
resp2.setHeader("Vary","User-Agent");
|
resp2.setHeader("Vary","User-Agent");
|
||||||
resp2.setHeader("Etag","\"etag2\"");
|
resp2.setHeader("Etag","\"etag2\"");
|
||||||
|
|
||||||
backendExpectsAnyRequest().andReturn(resp2);
|
backendExpectsAnyRequest().andReturn(resp2);
|
||||||
|
|
||||||
Capture<HttpRequest> cap = new Capture<HttpRequest>();
|
Capture<HttpRequest> cap = new Capture<HttpRequest>();
|
||||||
HttpRequest req3 = new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1);
|
HttpRequest req3 = new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1);
|
||||||
req3.setHeader("User-Agent","agent3");
|
req3.setHeader("User-Agent","agent3");
|
||||||
HttpResponse resp3 = HttpTestUtils.make200Response();
|
HttpResponse resp3 = HttpTestUtils.make200Response();
|
||||||
|
|
||||||
EasyMock.expect(mockBackend.execute(EasyMock.eq(host),
|
EasyMock.expect(mockBackend.execute(EasyMock.eq(host),
|
||||||
EasyMock.capture(cap), (HttpContext)EasyMock.isNull()))
|
EasyMock.capture(cap), (HttpContext)EasyMock.isNull()))
|
||||||
.andReturn(resp3);
|
.andReturn(resp3);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(host,req1);
|
impl.execute(host,req1);
|
||||||
impl.execute(host,req2);
|
impl.execute(host,req2);
|
||||||
impl.execute(host,req3);
|
impl.execute(host,req3);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
HttpRequest captured = cap.getValue();
|
HttpRequest captured = cap.getValue();
|
||||||
boolean foundEtag1 = false;
|
boolean foundEtag1 = false;
|
||||||
boolean foundEtag2 = false;
|
boolean foundEtag2 = false;
|
||||||
for(Header h : captured.getHeaders("If-None-Match")) {
|
for(Header h : captured.getHeaders("If-None-Match")) {
|
||||||
for(String etag : h.getValue().split(",")) {
|
for(String etag : h.getValue().split(",")) {
|
||||||
if ("\"etag1\"".equals(etag.trim())) {
|
if ("\"etag1\"".equals(etag.trim())) {
|
||||||
foundEtag1 = true;
|
foundEtag1 = true;
|
||||||
}
|
}
|
||||||
if ("\"etag2\"".equals(etag.trim())) {
|
if ("\"etag2\"".equals(etag.trim())) {
|
||||||
foundEtag2 = true;
|
foundEtag2 = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertTrue(foundEtag1 && foundEtag2);
|
assertTrue(foundEtag1 && foundEtag2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue