HTTPASYNC-46: HttpClient cache test cases can be shared with HttpAsyncClient

Contributed by James Leigh <james at 3roundstones.com>

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1494755 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2013-06-19 19:50:02 +00:00
parent 2e72fffacf
commit 594f24cf05
12 changed files with 2210 additions and 1954 deletions

View File

@ -112,6 +112,18 @@
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -33,6 +33,7 @@ import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.HttpVersion;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpExecutionAware;
import org.apache.http.client.methods.HttpRequestWrapper;
@ -55,9 +56,10 @@ public abstract class AbstractProtocolTest {
protected ClientExecChain mockBackend;
protected HttpCache mockCache;
protected HttpRequestWrapper request;
protected HttpCacheContext context;
protected CloseableHttpResponse originResponse;
protected CacheConfig config;
protected CachingExec impl;
protected ClientExecChain impl;
protected HttpCache cache;
public static HttpRequestWrapper eqRequest(final HttpRequestWrapper in) {
@ -65,6 +67,11 @@ public abstract class AbstractProtocolTest {
return null;
}
public static HttpResponse eqResponse(final HttpResponse in) {
EasyMock.reportMatcher(new ResponseEquivalent(in));
return null;
}
@Before
public void setUp() {
host = new HttpHost("foo.example.com");
@ -75,6 +82,8 @@ public abstract class AbstractProtocolTest {
request = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/foo", HttpVersion.HTTP_1_1));
context = HttpCacheContext.create();
originResponse = Proxies.enhanceResponse(HttpTestUtils.make200Response());
config = CacheConfig.custom()
@ -85,7 +94,16 @@ public abstract class AbstractProtocolTest {
cache = new BasicHttpCache(config);
mockBackend = EasyMock.createNiceMock(ClientExecChain.class);
mockCache = EasyMock.createNiceMock(HttpCache.class);
impl = new CachingExec(mockBackend, cache, config);
impl = createCachingExecChain(mockBackend, cache, config);
}
protected ClientExecChain createCachingExecChain(final ClientExecChain backend,
final HttpCache cache, final CacheConfig config) {
return new CachingExec(backend, cache, config);
}
protected boolean supportsRangeAndContentRangeHeaders(final ClientExecChain impl) {
return impl instanceof CachingExec && ((CachingExec) impl).supportsRangeAndContentRangeHeaders();
}
protected void replayMocks() {

View File

@ -244,6 +244,12 @@ public class HttpTestUtils {
r2));
}
/* Assert.asserts that two requests are morally equivalent. */
public static boolean equivalent(final HttpResponse r1, final HttpResponse r2) {
return (equivalent(r1.getStatusLine(), r2.getStatusLine()) && isEndToEndHeaderSubset(r1,
r2));
}
public static byte[] getRandomBytes(final int nbytes) {
final byte[] bytes = new byte[nbytes];
(new Random()).nextBytes(bytes);

View File

@ -0,0 +1,54 @@
/*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.http.impl.client.cache;
import org.apache.http.HttpResponse;
import org.easymock.IArgumentMatcher;
public class ResponseEquivalent implements IArgumentMatcher {
private final HttpResponse expected;
public ResponseEquivalent(final HttpResponse expected) {
this.expected = expected;
}
public boolean matches(final Object actual) {
if (!(actual instanceof HttpResponse)) {
return false;
}
final HttpResponse other = (HttpResponse) actual;
return HttpTestUtils.equivalent(expected, other);
}
public void appendTo(final StringBuffer buf) {
buf.append("eqRequest(");
buf.append(expected);
buf.append(")");
}
}

File diff suppressed because it is too large Load Diff

View File

@ -112,7 +112,7 @@ public class TestHttpCacheJiraNumber1147 {
EasyMock.replay(backend);
final BasicHttpCache cache = new BasicHttpCache(resourceFactory, httpCacheStorage, cacheConfig);
final CachingExec t = new CachingExec(backend, cache, cacheConfig);
final ClientExecChain t = createCachingExecChain(backend, cache, cacheConfig);
final HttpResponse response1 = t.execute(route, get, context, null);
Assert.assertEquals(200, response1.getStatusLine().getStatusCode());
@ -137,4 +137,9 @@ public class TestHttpCacheJiraNumber1147 {
EasyMock.verify(backend);
}
protected ClientExecChain createCachingExecChain(final ClientExecChain backend,
final BasicHttpCache cache, final CacheConfig config) {
return new CachingExec(backend, cache, config);
}
}

View File

@ -65,8 +65,8 @@ public class TestProtocolAllowedBehavior extends AbstractProtocolTest {
replayMocks();
behaveAsNonSharedCache();
impl.execute(route, req1);
final HttpResponse result = impl.execute(route, req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
Assert.assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
@ -86,8 +86,8 @@ public class TestProtocolAllowedBehavior extends AbstractProtocolTest {
replayMocks();
behaveAsNonSharedCache();
impl.execute(route, req1);
final HttpResponse result = impl.execute(route, req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
Assert.assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());

View File

@ -37,6 +37,7 @@ import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.ProtocolVersion;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.cache.HttpCacheContext;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpExecutionAware;
import org.apache.http.client.methods.HttpRequestWrapper;
@ -84,9 +85,10 @@ public class TestProtocolDeviations {
private ClientExecChain mockBackend;
private HttpCache mockCache;
private HttpRequest request;
private HttpCacheContext context;
private CloseableHttpResponse originResponse;
private CachingExec impl;
private ClientExecChain impl;
@Before
public void setUp() {
@ -98,6 +100,8 @@ public class TestProtocolDeviations {
request = new BasicHttpRequest("GET", "/foo", HTTP_1_1);
context = HttpCacheContext.create();
originResponse = Proxies.enhanceResponse(make200Response());
final CacheConfig config = CacheConfig.custom()
@ -110,7 +114,12 @@ public class TestProtocolDeviations {
mockEntity = EasyMock.createNiceMock(HttpEntity.class);
mockCache = EasyMock.createNiceMock(HttpCache.class);
impl = new CachingExec(mockBackend, cache, config);
impl = createCachingExecChain(mockBackend, cache, config);
}
protected ClientExecChain createCachingExecChain(
final ClientExecChain backend, final HttpCache cache, final CacheConfig config) {
return new CachingExec(backend, cache, config);
}
private HttpResponse make200Response() {
@ -169,7 +178,7 @@ public class TestProtocolDeviations {
replayMocks();
final HttpResponse response = impl.execute(route, HttpRequestWrapper.wrap(post));
final HttpResponse response = impl.execute(route, HttpRequestWrapper.wrap(post), context, null);
verifyMocks();
@ -227,7 +236,7 @@ public class TestProtocolDeviations {
replayMocks();
EasyMock.replay(mockBody);
final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(post));
final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(post), context, null);
verifyMocks();
EasyMock.verify(mockBody);
@ -266,7 +275,7 @@ public class TestProtocolDeviations {
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
replayMocks();
impl.execute(route, HttpRequestWrapper.wrap(options));
impl.execute(route, HttpRequestWrapper.wrap(options), context, null);
verifyMocks();
@ -308,7 +317,7 @@ public class TestProtocolDeviations {
replayMocks();
try {
final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request));
final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request), context, null);
Assert.assertTrue(HttpStatus.SC_PARTIAL_CONTENT != result.getStatusLine()
.getStatusCode());
} catch (final ClientProtocolException acceptableBehavior) {
@ -336,7 +345,7 @@ public class TestProtocolDeviations {
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
replayMocks();
final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request));
final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request), context, null);
verifyMocks();
Assert.assertSame(originResponse, result);
}
@ -359,7 +368,7 @@ public class TestProtocolDeviations {
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
replayMocks();
final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request));
final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request), context, null);
verifyMocks();
Assert.assertSame(originResponse, result);
}
@ -383,7 +392,7 @@ public class TestProtocolDeviations {
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
replayMocks();
final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request));
final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request), context, null);
verifyMocks();
Assert.assertSame(originResponse, result);
}

View File

@ -47,6 +47,7 @@ import org.apache.http.HttpVersion;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpExecutionAware;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpRequestWrapper;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.client.utils.DateUtils;
@ -91,7 +92,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
originResponse.setHeader("Content-Encoding", "identity");
backendExpectsAnyRequest().andReturn(originResponse);
replayMocks();
final HttpResponse result = impl.execute(route, request);
final HttpResponse result = impl.execute(route, request, context, null);
verifyMocks();
boolean foundIdentity = false;
for(final Header h : result.getHeaders("Content-Encoding")) {
@ -127,8 +128,8 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
req2.setHeader(conditionalHeader, validator);
replayMocks();
impl.execute(route, req1);
final HttpResponse result = impl.execute(route, req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
if (HttpStatus.SC_NOT_MODIFIED == result.getStatusLine().getStatusCode()) {
@ -247,15 +248,15 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
final Capture<HttpRequestWrapper> cap = new Capture<HttpRequestWrapper>();
EasyMock.expect(
mockBackend.execute(
EasyMock.same(route),
EasyMock.eq(route),
EasyMock.capture(cap),
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(
Proxies.enhanceResponse(resp2)).times(0,1);
replayMocks();
impl.execute(route, req1);
final HttpResponse result = impl.execute(route, req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
if (!cap.hasCaptured()
@ -321,7 +322,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp);
replayMocks();
final HttpResponse result = impl.execute(route, req);
final HttpResponse result = impl.execute(route, req, context, null);
verifyMocks();
assertNull(result.getFirstHeader(entityHeader));
@ -384,7 +385,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp);
replayMocks();
final HttpResponse result = impl.execute(route, req);
final HttpResponse result = impl.execute(route, req, context, null);
verifyMocks();
assertNull(result.getFirstHeader("Content-Range"));
@ -423,10 +424,10 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequest().andThrow(new IOException());
replayMocks();
impl.execute(route, req1);
impl.execute(route, req1, context, null);
HttpResponse result = null;
try {
result = impl.execute(route, req2);
result = impl.execute(route, req2, context, null);
} catch (final IOException acceptable) {
}
verifyMocks();
@ -504,8 +505,8 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequest().andThrow(new IOException()).times(0,1);
replayMocks();
impl.execute(route, req1);
final HttpResponse result = impl.execute(route, req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
@ -565,8 +566,8 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequest().andThrow(new IOException()).anyTimes();
replayMocks();
impl.execute(route, req1);
final HttpResponse result = impl.execute(route, req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
@ -606,7 +607,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequest().andReturn(originResponse);
replayMocks();
final HttpResponse result = impl.execute(route, request);
final HttpResponse result = impl.execute(route, request, context, null);
verifyMocks();
assertNull(result.getFirstHeader("Warning"));
@ -627,7 +628,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequest().andReturn(originResponse);
replayMocks();
final HttpResponse result = impl.execute(route, request);
final HttpResponse result = impl.execute(route, request, context, null);
verifyMocks();
assertEquals(warning, result.getFirstHeader("Warning").getValue());
@ -645,7 +646,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
.getCanonicalHeaderValue(originResponse, headerName);
backendExpectsAnyRequest().andReturn(originResponse);
replayMocks();
final HttpResponse result = impl.execute(route, request);
final HttpResponse result = impl.execute(route, request, context, null);
verifyMocks();
assertEquals(headerValue,
result.getFirstHeader(headerName).getValue());
@ -657,12 +658,12 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
final Capture<HttpRequestWrapper> cap = new Capture<HttpRequestWrapper>();
EasyMock.expect(
mockBackend.execute(
EasyMock.same(route),
EasyMock.eq(route),
EasyMock.capture(cap),
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
replayMocks();
impl.execute(route, request);
impl.execute(route, request, context, null);
verifyMocks();
assertEquals(headerValue,
HttpTestUtils.getCanonicalHeaderValue(cap.getValue(),
@ -947,15 +948,15 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
EasyMock.expect(
mockBackend.execute(
EasyMock.same(route),
EasyMock.eq(route),
EasyMock.capture(cap),
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(
Proxies.enhanceResponse(resp2));
replayMocks();
impl.execute(route, req1);
impl.execute(route, req2);
impl.execute(route, req1, context, null);
impl.execute(route, req2, context, null);
verifyMocks();
final HttpRequest captured = cap.getValue();
@ -998,15 +999,15 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
EasyMock.expect(
mockBackend.execute(
EasyMock.same(route),
EasyMock.eq(route),
EasyMock.capture(cap),
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(
Proxies.enhanceResponse(resp2));
replayMocks();
impl.execute(route, req1);
impl.execute(route, req2);
impl.execute(route, req1, context, null);
impl.execute(route, req2, context, null);
verifyMocks();
final HttpRequest captured = cap.getValue();
@ -1057,15 +1058,15 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
EasyMock.expect(
mockBackend.execute(
EasyMock.same(route),
EasyMock.eq(route),
eqRequest(revalidate),
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(
Proxies.enhanceResponse(resp2));
replayMocks();
impl.execute(route, req1);
final HttpResponse result = impl.execute(route, req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
assertEquals(HttpStatus.SC_OK,
@ -1117,15 +1118,15 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
EasyMock.expect(
mockBackend.execute(
EasyMock.same(route),
EasyMock.eq(route),
EasyMock.capture(cap),
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(
Proxies.enhanceResponse(resp3));
replayMocks();
impl.execute(route, req1);
impl.execute(route, req2);
impl.execute(route, req1, context, null);
impl.execute(route, req2, context, null);
verifyMocks();
final HttpRequest captured = cap.getValue();
@ -1193,16 +1194,16 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
EasyMock.expect(
mockBackend.execute(
EasyMock.same(route),
EasyMock.eq(route),
EasyMock.capture(cap),
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(
Proxies.enhanceResponse(resp3));
replayMocks();
impl.execute(route,req1);
impl.execute(route,req2);
impl.execute(route,req3);
impl.execute(route, req1, context, null);
impl.execute(route, req2, context, null);
impl.execute(route, req3, context, null);
verifyMocks();
final HttpRequest captured = cap.getValue();
@ -1275,10 +1276,10 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
req4.setHeader("User-Agent", "agent1");
replayMocks();
impl.execute(route, req1);
impl.execute(route, req2);
final HttpResponse result1 = impl.execute(route, req3);
final HttpResponse result2 = impl.execute(route, req4);
impl.execute(route, req1, context, null);
impl.execute(route, req2, context, null);
final HttpResponse result1 = impl.execute(route, req3, context, null);
final HttpResponse result2 = impl.execute(route, req4, context, null);
verifyMocks();
assertEquals(HttpStatus.SC_OK, result1.getStatusLine().getStatusCode());
@ -1321,9 +1322,9 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
req3.setHeader("User-Agent", "agent2");
replayMocks();
impl.execute(route, req1);
impl.execute(route, req2);
impl.execute(route, req3);
impl.execute(route, req1, context, null);
impl.execute(route, req2, context, null);
impl.execute(route, req3, context, null);
verifyMocks();
}
@ -1372,16 +1373,16 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
final Capture<HttpRequestWrapper> cap = new Capture<HttpRequestWrapper>();
EasyMock.expect(
mockBackend.execute(
EasyMock.same(route),
EasyMock.eq(route),
EasyMock.capture(cap),
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(
Proxies.enhanceResponse(resp3));
replayMocks();
impl.execute(route, req1);
impl.execute(route, req2);
impl.execute(route, req3);
impl.execute(route, req1, context, null);
impl.execute(route, req2, context, null);
impl.execute(route, req3, context, null);
verifyMocks();
final HttpRequest captured = cap.getValue();
@ -1414,7 +1415,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp1);
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
new HttpGet("http://foo.example.com/bar"));
new HttpPost("http://foo.example.com/bar"));
final HttpResponse resp2 = HttpTestUtils.make200Response();
resp2.setHeader("ETag", "\"new-etag\"");
resp2.setHeader("Date", DateUtils.formatDate(now));
@ -1429,9 +1430,9 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp3);
replayMocks();
impl.execute(route, req1);
impl.execute(route, req2);
impl.execute(route, req3);
impl.execute(route, req1, context, null);
impl.execute(route, req2, context, null);
impl.execute(route, req3, context, null);
verifyMocks();
}
@ -1455,7 +1456,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
replayMocks();
impl.execute(route, req2);
impl.execute(route, req2, context, null);
verifyMocks();
}
@ -1473,7 +1474,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
replayMocks();
impl.execute(route, req2);
impl.execute(route, req2, context, null);
verifyMocks();
}
@ -1509,9 +1510,9 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp3);
replayMocks();
impl.execute(route, req1);
impl.execute(route, req2);
final HttpResponse result = impl.execute(route, req3);
impl.execute(route, req1, context, null);
impl.execute(route, req2, context, null);
final HttpResponse result = impl.execute(route, req3, context, null);
verifyMocks();
assertTrue(HttpTestUtils.semanticallyTransparent(resp3, result));
@ -1563,11 +1564,11 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp5);
replayMocks();
impl.execute(route, req1);
impl.execute(route, req2);
impl.execute(route, req3);
final HttpResponse result4 = impl.execute(route, req4);
final HttpResponse result5 = impl.execute(route, req5);
impl.execute(route, req1, context, null);
impl.execute(route, req2, context, null);
impl.execute(route, req3, context, null);
final HttpResponse result4 = impl.execute(route, req4, context, null);
final HttpResponse result5 = impl.execute(route, req5, context, null);
verifyMocks();
assertTrue(HttpTestUtils.semanticallyTransparent(resp4, result4));
@ -1604,9 +1605,9 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
replayMocks();
impl.execute(route, req1);
impl.execute(route, req2);
final HttpResponse result = impl.execute(route, req3);
impl.execute(route, req1, context, null);
impl.execute(route, req2, context, null);
final HttpResponse result = impl.execute(route, req3, context, null);
verifyMocks();
assertTrue(HttpTestUtils.semanticallyTransparent(resp2, result));
@ -1642,8 +1643,8 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
replayMocks();
impl.execute(route, req1);
final HttpResponse result = impl.execute(route, req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
assertTrue(HttpTestUtils.semanticallyTransparent(resp2, result));
@ -1668,8 +1669,8 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
replayMocks();
impl.execute(route, req1);
final HttpResponse result = impl.execute(route, req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
assertTrue(HttpTestUtils.semanticallyTransparent(resp2, result));
@ -1692,14 +1693,14 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
final Capture<HttpRequestWrapper> cap = new Capture<HttpRequestWrapper>();
EasyMock.expect(
mockBackend.execute(
EasyMock.same(route),
EasyMock.eq(route),
EasyMock.capture(cap),
EasyMock.isA(HttpClientContext.class),
EasyMock.<HttpExecutionAware>isNull())).andReturn(
Proxies.enhanceResponse(HttpTestUtils.make200Response()));
replayMocks();
impl.execute(route, req1);
impl.execute(route, req1, context, null);
verifyMocks();
final HttpRequest captured = cap.getValue();
@ -1737,7 +1738,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
req.setHeader("Cache-Control", "only-if-cached");
replayMocks();
final HttpResponse result = impl.execute(route, req);
final HttpResponse result = impl.execute(route, req, context, null);
verifyMocks();
assertEquals(HttpStatus.SC_GATEWAY_TIMEOUT,
@ -1757,8 +1758,8 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
req2.setHeader("Cache-Control", "only-if-cached");
replayMocks();
impl.execute(route, req1);
final HttpResponse result = impl.execute(route, req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
assertTrue(HttpTestUtils.semanticallyTransparent(resp1, result));
@ -1778,8 +1779,8 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
req2.setHeader("Cache-Control", "only-if-cached");
replayMocks();
impl.execute(route, req1);
final HttpResponse result = impl.execute(route, req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
assertEquals(HttpStatus.SC_GATEWAY_TIMEOUT,
@ -1801,8 +1802,8 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
req2.setHeader("Cache-Control", "max-stale=20, only-if-cached");
replayMocks();
impl.execute(route, req1);
final HttpResponse result = impl.execute(route, req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
assertTrue(HttpTestUtils.semanticallyTransparent(resp1, result));
@ -1822,8 +1823,8 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
req2.setHeader("If-None-Match","W/\"weak-sauce\"");
replayMocks();
impl.execute(route, req1);
final HttpResponse result = impl.execute(route, req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
assertEquals(HttpStatus.SC_NOT_MODIFIED, result.getStatusLine().getStatusCode());

View File

@ -82,8 +82,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
replayMocks();
impl.execute(route,req1);
final HttpResponse result = impl.execute(route,req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
HttpTestUtils.assert110WarningFound(result);
@ -110,8 +110,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
replayMocks();
impl.execute(route,req1);
impl.execute(route,req2);
impl.execute(route, req1, context, null);
impl.execute(route, req2, context, null);
verifyMocks();
assertTrue(cis.wasClosed());
@ -133,8 +133,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
replayMocks();
impl.execute(route,req1);
final HttpResponse result = impl.execute(route,req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
assertTrue(HttpStatus.SC_OK != result.getStatusLine().getStatusCode());
@ -157,8 +157,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
replayMocks();
impl.execute(route,req1);
final HttpResponse result = impl.execute(route,req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
assertTrue(HttpStatus.SC_OK != result.getStatusLine().getStatusCode());
@ -184,8 +184,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
replayMocks();
impl.execute(route,req1);
final HttpResponse result = impl.execute(route,req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
HttpTestUtils.assert110WarningFound(result);
@ -208,8 +208,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
replayMocks();
impl.execute(route,req1);
final HttpResponse result = impl.execute(route,req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
assertTrue(HttpStatus.SC_OK != result.getStatusLine().getStatusCode());
@ -232,8 +232,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
replayMocks();
impl.execute(route,req1);
final HttpResponse result = impl.execute(route,req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
HttpTestUtils.assert110WarningFound(result);
@ -256,8 +256,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
replayMocks();
impl.execute(route,req1);
final HttpResponse result = impl.execute(route,req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR,
@ -282,8 +282,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
replayMocks();
impl.execute(route,req1);
final HttpResponse result = impl.execute(route,req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR,
@ -324,8 +324,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
replayMocks();
impl.execute(route, req1);
final HttpResponse result = impl.execute(route, req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
@ -369,8 +369,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
req2.setHeader("If-None-Match","\"etag\"");
replayMocks();
impl.execute(route, req1);
final HttpResponse result = impl.execute(route, req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
assertEquals(HttpStatus.SC_NOT_MODIFIED, result.getStatusLine().getStatusCode());
@ -420,8 +420,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
replayMocks();
impl.execute(route, req1);
final HttpResponse result = impl.execute(route, req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
@ -471,8 +471,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
replayMocks();
impl.execute(route, req1);
final HttpResponse result = impl.execute(route, req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
@ -523,8 +523,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
backendExpectsAnyRequestAndReturn(resp2);
replayMocks();
impl.execute(route, req1);
final HttpResponse result = impl.execute(route, req2);
impl.execute(route, req1, context, null);
final HttpResponse result = impl.execute(route, req2, context, null);
verifyMocks();
assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());