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:
parent
2e72fffacf
commit
594f24cf05
|
@ -112,6 +112,18 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
</plugin>
|
</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>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.apache.http.HttpHost;
|
||||||
import org.apache.http.HttpRequest;
|
import org.apache.http.HttpRequest;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.HttpVersion;
|
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.CloseableHttpResponse;
|
||||||
import org.apache.http.client.methods.HttpExecutionAware;
|
import org.apache.http.client.methods.HttpExecutionAware;
|
||||||
import org.apache.http.client.methods.HttpRequestWrapper;
|
import org.apache.http.client.methods.HttpRequestWrapper;
|
||||||
|
@ -55,9 +56,10 @@ public abstract class AbstractProtocolTest {
|
||||||
protected ClientExecChain mockBackend;
|
protected ClientExecChain mockBackend;
|
||||||
protected HttpCache mockCache;
|
protected HttpCache mockCache;
|
||||||
protected HttpRequestWrapper request;
|
protected HttpRequestWrapper request;
|
||||||
|
protected HttpCacheContext context;
|
||||||
protected CloseableHttpResponse originResponse;
|
protected CloseableHttpResponse originResponse;
|
||||||
protected CacheConfig config;
|
protected CacheConfig config;
|
||||||
protected CachingExec impl;
|
protected ClientExecChain impl;
|
||||||
protected HttpCache cache;
|
protected HttpCache cache;
|
||||||
|
|
||||||
public static HttpRequestWrapper eqRequest(final HttpRequestWrapper in) {
|
public static HttpRequestWrapper eqRequest(final HttpRequestWrapper in) {
|
||||||
|
@ -65,6 +67,11 @@ public abstract class AbstractProtocolTest {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static HttpResponse eqResponse(final HttpResponse in) {
|
||||||
|
EasyMock.reportMatcher(new ResponseEquivalent(in));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
host = new HttpHost("foo.example.com");
|
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));
|
request = HttpRequestWrapper.wrap(new BasicHttpRequest("GET", "/foo", HttpVersion.HTTP_1_1));
|
||||||
|
|
||||||
|
context = HttpCacheContext.create();
|
||||||
|
|
||||||
originResponse = Proxies.enhanceResponse(HttpTestUtils.make200Response());
|
originResponse = Proxies.enhanceResponse(HttpTestUtils.make200Response());
|
||||||
|
|
||||||
config = CacheConfig.custom()
|
config = CacheConfig.custom()
|
||||||
|
@ -85,7 +94,16 @@ public abstract class AbstractProtocolTest {
|
||||||
cache = new BasicHttpCache(config);
|
cache = new BasicHttpCache(config);
|
||||||
mockBackend = EasyMock.createNiceMock(ClientExecChain.class);
|
mockBackend = EasyMock.createNiceMock(ClientExecChain.class);
|
||||||
mockCache = EasyMock.createNiceMock(HttpCache.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() {
|
protected void replayMocks() {
|
||||||
|
|
|
@ -244,6 +244,12 @@ public class HttpTestUtils {
|
||||||
r2));
|
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) {
|
public static byte[] getRandomBytes(final int nbytes) {
|
||||||
final byte[] bytes = new byte[nbytes];
|
final byte[] bytes = new byte[nbytes];
|
||||||
(new Random()).nextBytes(bytes);
|
(new Random()).nextBytes(bytes);
|
||||||
|
|
54
httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ResponseEquivalent.java
vendored
Normal file
54
httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ResponseEquivalent.java
vendored
Normal 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
1703
httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingExecChain.java
vendored
Normal file
1703
httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingExecChain.java
vendored
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -112,7 +112,7 @@ public class TestHttpCacheJiraNumber1147 {
|
||||||
EasyMock.replay(backend);
|
EasyMock.replay(backend);
|
||||||
|
|
||||||
final BasicHttpCache cache = new BasicHttpCache(resourceFactory, httpCacheStorage, cacheConfig);
|
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);
|
final HttpResponse response1 = t.execute(route, get, context, null);
|
||||||
Assert.assertEquals(200, response1.getStatusLine().getStatusCode());
|
Assert.assertEquals(200, response1.getStatusLine().getStatusCode());
|
||||||
|
@ -137,4 +137,9 @@ public class TestHttpCacheJiraNumber1147 {
|
||||||
EasyMock.verify(backend);
|
EasyMock.verify(backend);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ClientExecChain createCachingExecChain(final ClientExecChain backend,
|
||||||
|
final BasicHttpCache cache, final CacheConfig config) {
|
||||||
|
return new CachingExec(backend, cache, config);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,8 +65,8 @@ public class TestProtocolAllowedBehavior extends AbstractProtocolTest {
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
behaveAsNonSharedCache();
|
behaveAsNonSharedCache();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route, req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
Assert.assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
|
Assert.assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
|
||||||
|
@ -86,8 +86,8 @@ public class TestProtocolAllowedBehavior extends AbstractProtocolTest {
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
behaveAsNonSharedCache();
|
behaveAsNonSharedCache();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route, req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
Assert.assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
|
Assert.assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
|
||||||
|
|
|
@ -37,6 +37,7 @@ import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.HttpStatus;
|
import org.apache.http.HttpStatus;
|
||||||
import org.apache.http.ProtocolVersion;
|
import org.apache.http.ProtocolVersion;
|
||||||
import org.apache.http.client.ClientProtocolException;
|
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.CloseableHttpResponse;
|
||||||
import org.apache.http.client.methods.HttpExecutionAware;
|
import org.apache.http.client.methods.HttpExecutionAware;
|
||||||
import org.apache.http.client.methods.HttpRequestWrapper;
|
import org.apache.http.client.methods.HttpRequestWrapper;
|
||||||
|
@ -84,9 +85,10 @@ public class TestProtocolDeviations {
|
||||||
private ClientExecChain mockBackend;
|
private ClientExecChain mockBackend;
|
||||||
private HttpCache mockCache;
|
private HttpCache mockCache;
|
||||||
private HttpRequest request;
|
private HttpRequest request;
|
||||||
|
private HttpCacheContext context;
|
||||||
private CloseableHttpResponse originResponse;
|
private CloseableHttpResponse originResponse;
|
||||||
|
|
||||||
private CachingExec impl;
|
private ClientExecChain impl;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
|
@ -98,6 +100,8 @@ public class TestProtocolDeviations {
|
||||||
|
|
||||||
request = new BasicHttpRequest("GET", "/foo", HTTP_1_1);
|
request = new BasicHttpRequest("GET", "/foo", HTTP_1_1);
|
||||||
|
|
||||||
|
context = HttpCacheContext.create();
|
||||||
|
|
||||||
originResponse = Proxies.enhanceResponse(make200Response());
|
originResponse = Proxies.enhanceResponse(make200Response());
|
||||||
|
|
||||||
final CacheConfig config = CacheConfig.custom()
|
final CacheConfig config = CacheConfig.custom()
|
||||||
|
@ -110,7 +114,12 @@ public class TestProtocolDeviations {
|
||||||
mockEntity = EasyMock.createNiceMock(HttpEntity.class);
|
mockEntity = EasyMock.createNiceMock(HttpEntity.class);
|
||||||
mockCache = EasyMock.createNiceMock(HttpCache.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() {
|
private HttpResponse make200Response() {
|
||||||
|
@ -169,7 +178,7 @@ public class TestProtocolDeviations {
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
|
|
||||||
final HttpResponse response = impl.execute(route, HttpRequestWrapper.wrap(post));
|
final HttpResponse response = impl.execute(route, HttpRequestWrapper.wrap(post), context, null);
|
||||||
|
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
|
@ -227,7 +236,7 @@ public class TestProtocolDeviations {
|
||||||
replayMocks();
|
replayMocks();
|
||||||
EasyMock.replay(mockBody);
|
EasyMock.replay(mockBody);
|
||||||
|
|
||||||
final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(post));
|
final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(post), context, null);
|
||||||
|
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
EasyMock.verify(mockBody);
|
EasyMock.verify(mockBody);
|
||||||
|
@ -266,7 +275,7 @@ public class TestProtocolDeviations {
|
||||||
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
|
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
|
||||||
replayMocks();
|
replayMocks();
|
||||||
|
|
||||||
impl.execute(route, HttpRequestWrapper.wrap(options));
|
impl.execute(route, HttpRequestWrapper.wrap(options), context, null);
|
||||||
|
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
|
@ -308,7 +317,7 @@ public class TestProtocolDeviations {
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
try {
|
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()
|
Assert.assertTrue(HttpStatus.SC_PARTIAL_CONTENT != result.getStatusLine()
|
||||||
.getStatusCode());
|
.getStatusCode());
|
||||||
} catch (final ClientProtocolException acceptableBehavior) {
|
} catch (final ClientProtocolException acceptableBehavior) {
|
||||||
|
@ -336,7 +345,7 @@ public class TestProtocolDeviations {
|
||||||
EasyMock.isA(HttpClientContext.class),
|
EasyMock.isA(HttpClientContext.class),
|
||||||
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
|
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
|
||||||
replayMocks();
|
replayMocks();
|
||||||
final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request));
|
final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request), context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
Assert.assertSame(originResponse, result);
|
Assert.assertSame(originResponse, result);
|
||||||
}
|
}
|
||||||
|
@ -359,7 +368,7 @@ public class TestProtocolDeviations {
|
||||||
EasyMock.isA(HttpClientContext.class),
|
EasyMock.isA(HttpClientContext.class),
|
||||||
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
|
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
|
||||||
replayMocks();
|
replayMocks();
|
||||||
final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request));
|
final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request), context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
Assert.assertSame(originResponse, result);
|
Assert.assertSame(originResponse, result);
|
||||||
}
|
}
|
||||||
|
@ -383,7 +392,7 @@ public class TestProtocolDeviations {
|
||||||
EasyMock.isA(HttpClientContext.class),
|
EasyMock.isA(HttpClientContext.class),
|
||||||
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
|
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
|
||||||
replayMocks();
|
replayMocks();
|
||||||
final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request));
|
final HttpResponse result = impl.execute(route, HttpRequestWrapper.wrap(request), context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
Assert.assertSame(originResponse, result);
|
Assert.assertSame(originResponse, result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ import org.apache.http.HttpVersion;
|
||||||
import org.apache.http.client.ClientProtocolException;
|
import org.apache.http.client.ClientProtocolException;
|
||||||
import org.apache.http.client.methods.HttpExecutionAware;
|
import org.apache.http.client.methods.HttpExecutionAware;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
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.methods.HttpRequestWrapper;
|
||||||
import org.apache.http.client.protocol.HttpClientContext;
|
import org.apache.http.client.protocol.HttpClientContext;
|
||||||
import org.apache.http.client.utils.DateUtils;
|
import org.apache.http.client.utils.DateUtils;
|
||||||
|
@ -91,7 +92,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
originResponse.setHeader("Content-Encoding", "identity");
|
originResponse.setHeader("Content-Encoding", "identity");
|
||||||
backendExpectsAnyRequest().andReturn(originResponse);
|
backendExpectsAnyRequest().andReturn(originResponse);
|
||||||
replayMocks();
|
replayMocks();
|
||||||
final HttpResponse result = impl.execute(route, request);
|
final HttpResponse result = impl.execute(route, request, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
boolean foundIdentity = false;
|
boolean foundIdentity = false;
|
||||||
for(final Header h : result.getHeaders("Content-Encoding")) {
|
for(final Header h : result.getHeaders("Content-Encoding")) {
|
||||||
|
@ -127,8 +128,8 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
req2.setHeader(conditionalHeader, validator);
|
req2.setHeader(conditionalHeader, validator);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route, req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
if (HttpStatus.SC_NOT_MODIFIED == result.getStatusLine().getStatusCode()) {
|
if (HttpStatus.SC_NOT_MODIFIED == result.getStatusLine().getStatusCode()) {
|
||||||
|
@ -247,15 +248,15 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
final Capture<HttpRequestWrapper> cap = new Capture<HttpRequestWrapper>();
|
final Capture<HttpRequestWrapper> cap = new Capture<HttpRequestWrapper>();
|
||||||
EasyMock.expect(
|
EasyMock.expect(
|
||||||
mockBackend.execute(
|
mockBackend.execute(
|
||||||
EasyMock.same(route),
|
EasyMock.eq(route),
|
||||||
EasyMock.capture(cap),
|
EasyMock.capture(cap),
|
||||||
EasyMock.isA(HttpClientContext.class),
|
EasyMock.isA(HttpClientContext.class),
|
||||||
EasyMock.<HttpExecutionAware>isNull())).andReturn(
|
EasyMock.<HttpExecutionAware>isNull())).andReturn(
|
||||||
Proxies.enhanceResponse(resp2)).times(0,1);
|
Proxies.enhanceResponse(resp2)).times(0,1);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route, req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
if (!cap.hasCaptured()
|
if (!cap.hasCaptured()
|
||||||
|
@ -321,7 +322,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequestAndReturn(resp);
|
backendExpectsAnyRequestAndReturn(resp);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
final HttpResponse result = impl.execute(route, req);
|
final HttpResponse result = impl.execute(route, req, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertNull(result.getFirstHeader(entityHeader));
|
assertNull(result.getFirstHeader(entityHeader));
|
||||||
|
@ -384,7 +385,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequestAndReturn(resp);
|
backendExpectsAnyRequestAndReturn(resp);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
final HttpResponse result = impl.execute(route, req);
|
final HttpResponse result = impl.execute(route, req, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertNull(result.getFirstHeader("Content-Range"));
|
assertNull(result.getFirstHeader("Content-Range"));
|
||||||
|
@ -423,10 +424,10 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequest().andThrow(new IOException());
|
backendExpectsAnyRequest().andThrow(new IOException());
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
HttpResponse result = null;
|
HttpResponse result = null;
|
||||||
try {
|
try {
|
||||||
result = impl.execute(route, req2);
|
result = impl.execute(route, req2, context, null);
|
||||||
} catch (final IOException acceptable) {
|
} catch (final IOException acceptable) {
|
||||||
}
|
}
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
@ -504,8 +505,8 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequest().andThrow(new IOException()).times(0,1);
|
backendExpectsAnyRequest().andThrow(new IOException()).times(0,1);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route, req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
|
assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
|
||||||
|
@ -565,8 +566,8 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequest().andThrow(new IOException()).anyTimes();
|
backendExpectsAnyRequest().andThrow(new IOException()).anyTimes();
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route, req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
|
assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
|
||||||
|
@ -606,7 +607,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequest().andReturn(originResponse);
|
backendExpectsAnyRequest().andReturn(originResponse);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
final HttpResponse result = impl.execute(route, request);
|
final HttpResponse result = impl.execute(route, request, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertNull(result.getFirstHeader("Warning"));
|
assertNull(result.getFirstHeader("Warning"));
|
||||||
|
@ -627,7 +628,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequest().andReturn(originResponse);
|
backendExpectsAnyRequest().andReturn(originResponse);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
final HttpResponse result = impl.execute(route, request);
|
final HttpResponse result = impl.execute(route, request, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertEquals(warning, result.getFirstHeader("Warning").getValue());
|
assertEquals(warning, result.getFirstHeader("Warning").getValue());
|
||||||
|
@ -645,7 +646,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
.getCanonicalHeaderValue(originResponse, headerName);
|
.getCanonicalHeaderValue(originResponse, headerName);
|
||||||
backendExpectsAnyRequest().andReturn(originResponse);
|
backendExpectsAnyRequest().andReturn(originResponse);
|
||||||
replayMocks();
|
replayMocks();
|
||||||
final HttpResponse result = impl.execute(route, request);
|
final HttpResponse result = impl.execute(route, request, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
assertEquals(headerValue,
|
assertEquals(headerValue,
|
||||||
result.getFirstHeader(headerName).getValue());
|
result.getFirstHeader(headerName).getValue());
|
||||||
|
@ -657,12 +658,12 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
final Capture<HttpRequestWrapper> cap = new Capture<HttpRequestWrapper>();
|
final Capture<HttpRequestWrapper> cap = new Capture<HttpRequestWrapper>();
|
||||||
EasyMock.expect(
|
EasyMock.expect(
|
||||||
mockBackend.execute(
|
mockBackend.execute(
|
||||||
EasyMock.same(route),
|
EasyMock.eq(route),
|
||||||
EasyMock.capture(cap),
|
EasyMock.capture(cap),
|
||||||
EasyMock.isA(HttpClientContext.class),
|
EasyMock.isA(HttpClientContext.class),
|
||||||
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
|
EasyMock.<HttpExecutionAware>isNull())).andReturn(originResponse);
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, request);
|
impl.execute(route, request, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
assertEquals(headerValue,
|
assertEquals(headerValue,
|
||||||
HttpTestUtils.getCanonicalHeaderValue(cap.getValue(),
|
HttpTestUtils.getCanonicalHeaderValue(cap.getValue(),
|
||||||
|
@ -947,15 +948,15 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
|
|
||||||
EasyMock.expect(
|
EasyMock.expect(
|
||||||
mockBackend.execute(
|
mockBackend.execute(
|
||||||
EasyMock.same(route),
|
EasyMock.eq(route),
|
||||||
EasyMock.capture(cap),
|
EasyMock.capture(cap),
|
||||||
EasyMock.isA(HttpClientContext.class),
|
EasyMock.isA(HttpClientContext.class),
|
||||||
EasyMock.<HttpExecutionAware>isNull())).andReturn(
|
EasyMock.<HttpExecutionAware>isNull())).andReturn(
|
||||||
Proxies.enhanceResponse(resp2));
|
Proxies.enhanceResponse(resp2));
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
impl.execute(route, req2);
|
impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
final HttpRequest captured = cap.getValue();
|
final HttpRequest captured = cap.getValue();
|
||||||
|
@ -998,15 +999,15 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
|
|
||||||
EasyMock.expect(
|
EasyMock.expect(
|
||||||
mockBackend.execute(
|
mockBackend.execute(
|
||||||
EasyMock.same(route),
|
EasyMock.eq(route),
|
||||||
EasyMock.capture(cap),
|
EasyMock.capture(cap),
|
||||||
EasyMock.isA(HttpClientContext.class),
|
EasyMock.isA(HttpClientContext.class),
|
||||||
EasyMock.<HttpExecutionAware>isNull())).andReturn(
|
EasyMock.<HttpExecutionAware>isNull())).andReturn(
|
||||||
Proxies.enhanceResponse(resp2));
|
Proxies.enhanceResponse(resp2));
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
impl.execute(route, req2);
|
impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
final HttpRequest captured = cap.getValue();
|
final HttpRequest captured = cap.getValue();
|
||||||
|
@ -1057,15 +1058,15 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
|
|
||||||
EasyMock.expect(
|
EasyMock.expect(
|
||||||
mockBackend.execute(
|
mockBackend.execute(
|
||||||
EasyMock.same(route),
|
EasyMock.eq(route),
|
||||||
eqRequest(revalidate),
|
eqRequest(revalidate),
|
||||||
EasyMock.isA(HttpClientContext.class),
|
EasyMock.isA(HttpClientContext.class),
|
||||||
EasyMock.<HttpExecutionAware>isNull())).andReturn(
|
EasyMock.<HttpExecutionAware>isNull())).andReturn(
|
||||||
Proxies.enhanceResponse(resp2));
|
Proxies.enhanceResponse(resp2));
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route, req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertEquals(HttpStatus.SC_OK,
|
assertEquals(HttpStatus.SC_OK,
|
||||||
|
@ -1117,15 +1118,15 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
|
|
||||||
EasyMock.expect(
|
EasyMock.expect(
|
||||||
mockBackend.execute(
|
mockBackend.execute(
|
||||||
EasyMock.same(route),
|
EasyMock.eq(route),
|
||||||
EasyMock.capture(cap),
|
EasyMock.capture(cap),
|
||||||
EasyMock.isA(HttpClientContext.class),
|
EasyMock.isA(HttpClientContext.class),
|
||||||
EasyMock.<HttpExecutionAware>isNull())).andReturn(
|
EasyMock.<HttpExecutionAware>isNull())).andReturn(
|
||||||
Proxies.enhanceResponse(resp3));
|
Proxies.enhanceResponse(resp3));
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
impl.execute(route, req2);
|
impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
final HttpRequest captured = cap.getValue();
|
final HttpRequest captured = cap.getValue();
|
||||||
|
@ -1193,16 +1194,16 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
|
|
||||||
EasyMock.expect(
|
EasyMock.expect(
|
||||||
mockBackend.execute(
|
mockBackend.execute(
|
||||||
EasyMock.same(route),
|
EasyMock.eq(route),
|
||||||
EasyMock.capture(cap),
|
EasyMock.capture(cap),
|
||||||
EasyMock.isA(HttpClientContext.class),
|
EasyMock.isA(HttpClientContext.class),
|
||||||
EasyMock.<HttpExecutionAware>isNull())).andReturn(
|
EasyMock.<HttpExecutionAware>isNull())).andReturn(
|
||||||
Proxies.enhanceResponse(resp3));
|
Proxies.enhanceResponse(resp3));
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route,req1);
|
impl.execute(route, req1, context, null);
|
||||||
impl.execute(route,req2);
|
impl.execute(route, req2, context, null);
|
||||||
impl.execute(route,req3);
|
impl.execute(route, req3, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
final HttpRequest captured = cap.getValue();
|
final HttpRequest captured = cap.getValue();
|
||||||
|
@ -1275,10 +1276,10 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
req4.setHeader("User-Agent", "agent1");
|
req4.setHeader("User-Agent", "agent1");
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
impl.execute(route, req2);
|
impl.execute(route, req2, context, null);
|
||||||
final HttpResponse result1 = impl.execute(route, req3);
|
final HttpResponse result1 = impl.execute(route, req3, context, null);
|
||||||
final HttpResponse result2 = impl.execute(route, req4);
|
final HttpResponse result2 = impl.execute(route, req4, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertEquals(HttpStatus.SC_OK, result1.getStatusLine().getStatusCode());
|
assertEquals(HttpStatus.SC_OK, result1.getStatusLine().getStatusCode());
|
||||||
|
@ -1321,9 +1322,9 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
req3.setHeader("User-Agent", "agent2");
|
req3.setHeader("User-Agent", "agent2");
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
impl.execute(route, req2);
|
impl.execute(route, req2, context, null);
|
||||||
impl.execute(route, req3);
|
impl.execute(route, req3, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1372,16 +1373,16 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
final Capture<HttpRequestWrapper> cap = new Capture<HttpRequestWrapper>();
|
final Capture<HttpRequestWrapper> cap = new Capture<HttpRequestWrapper>();
|
||||||
EasyMock.expect(
|
EasyMock.expect(
|
||||||
mockBackend.execute(
|
mockBackend.execute(
|
||||||
EasyMock.same(route),
|
EasyMock.eq(route),
|
||||||
EasyMock.capture(cap),
|
EasyMock.capture(cap),
|
||||||
EasyMock.isA(HttpClientContext.class),
|
EasyMock.isA(HttpClientContext.class),
|
||||||
EasyMock.<HttpExecutionAware>isNull())).andReturn(
|
EasyMock.<HttpExecutionAware>isNull())).andReturn(
|
||||||
Proxies.enhanceResponse(resp3));
|
Proxies.enhanceResponse(resp3));
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
impl.execute(route, req2);
|
impl.execute(route, req2, context, null);
|
||||||
impl.execute(route, req3);
|
impl.execute(route, req3, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
final HttpRequest captured = cap.getValue();
|
final HttpRequest captured = cap.getValue();
|
||||||
|
@ -1414,7 +1415,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequestAndReturn(resp1);
|
backendExpectsAnyRequestAndReturn(resp1);
|
||||||
|
|
||||||
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
|
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
|
||||||
new HttpGet("http://foo.example.com/bar"));
|
new HttpPost("http://foo.example.com/bar"));
|
||||||
final HttpResponse resp2 = HttpTestUtils.make200Response();
|
final HttpResponse resp2 = HttpTestUtils.make200Response();
|
||||||
resp2.setHeader("ETag", "\"new-etag\"");
|
resp2.setHeader("ETag", "\"new-etag\"");
|
||||||
resp2.setHeader("Date", DateUtils.formatDate(now));
|
resp2.setHeader("Date", DateUtils.formatDate(now));
|
||||||
|
@ -1429,9 +1430,9 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequestAndReturn(resp3);
|
backendExpectsAnyRequestAndReturn(resp3);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
impl.execute(route, req2);
|
impl.execute(route, req2, context, null);
|
||||||
impl.execute(route, req3);
|
impl.execute(route, req3, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1455,7 +1456,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequestAndReturn(resp2);
|
backendExpectsAnyRequestAndReturn(resp2);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req2);
|
impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1473,7 +1474,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequestAndReturn(resp2);
|
backendExpectsAnyRequestAndReturn(resp2);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req2);
|
impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1509,9 +1510,9 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequestAndReturn(resp3);
|
backendExpectsAnyRequestAndReturn(resp3);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
impl.execute(route, req2);
|
impl.execute(route, req2, context, null);
|
||||||
final HttpResponse result = impl.execute(route, req3);
|
final HttpResponse result = impl.execute(route, req3, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertTrue(HttpTestUtils.semanticallyTransparent(resp3, result));
|
assertTrue(HttpTestUtils.semanticallyTransparent(resp3, result));
|
||||||
|
@ -1563,11 +1564,11 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequestAndReturn(resp5);
|
backendExpectsAnyRequestAndReturn(resp5);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
impl.execute(route, req2);
|
impl.execute(route, req2, context, null);
|
||||||
impl.execute(route, req3);
|
impl.execute(route, req3, context, null);
|
||||||
final HttpResponse result4 = impl.execute(route, req4);
|
final HttpResponse result4 = impl.execute(route, req4, context, null);
|
||||||
final HttpResponse result5 = impl.execute(route, req5);
|
final HttpResponse result5 = impl.execute(route, req5, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertTrue(HttpTestUtils.semanticallyTransparent(resp4, result4));
|
assertTrue(HttpTestUtils.semanticallyTransparent(resp4, result4));
|
||||||
|
@ -1604,9 +1605,9 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
|
final HttpRequestWrapper req3 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
impl.execute(route, req2);
|
impl.execute(route, req2, context, null);
|
||||||
final HttpResponse result = impl.execute(route, req3);
|
final HttpResponse result = impl.execute(route, req3, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertTrue(HttpTestUtils.semanticallyTransparent(resp2, result));
|
assertTrue(HttpTestUtils.semanticallyTransparent(resp2, result));
|
||||||
|
@ -1642,8 +1643,8 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequestAndReturn(resp2);
|
backendExpectsAnyRequestAndReturn(resp2);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route, req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertTrue(HttpTestUtils.semanticallyTransparent(resp2, result));
|
assertTrue(HttpTestUtils.semanticallyTransparent(resp2, result));
|
||||||
|
@ -1668,8 +1669,8 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequestAndReturn(resp2);
|
backendExpectsAnyRequestAndReturn(resp2);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route, req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertTrue(HttpTestUtils.semanticallyTransparent(resp2, result));
|
assertTrue(HttpTestUtils.semanticallyTransparent(resp2, result));
|
||||||
|
@ -1692,14 +1693,14 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
final Capture<HttpRequestWrapper> cap = new Capture<HttpRequestWrapper>();
|
final Capture<HttpRequestWrapper> cap = new Capture<HttpRequestWrapper>();
|
||||||
EasyMock.expect(
|
EasyMock.expect(
|
||||||
mockBackend.execute(
|
mockBackend.execute(
|
||||||
EasyMock.same(route),
|
EasyMock.eq(route),
|
||||||
EasyMock.capture(cap),
|
EasyMock.capture(cap),
|
||||||
EasyMock.isA(HttpClientContext.class),
|
EasyMock.isA(HttpClientContext.class),
|
||||||
EasyMock.<HttpExecutionAware>isNull())).andReturn(
|
EasyMock.<HttpExecutionAware>isNull())).andReturn(
|
||||||
Proxies.enhanceResponse(HttpTestUtils.make200Response()));
|
Proxies.enhanceResponse(HttpTestUtils.make200Response()));
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
final HttpRequest captured = cap.getValue();
|
final HttpRequest captured = cap.getValue();
|
||||||
|
@ -1737,7 +1738,7 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
req.setHeader("Cache-Control", "only-if-cached");
|
req.setHeader("Cache-Control", "only-if-cached");
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
final HttpResponse result = impl.execute(route, req);
|
final HttpResponse result = impl.execute(route, req, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertEquals(HttpStatus.SC_GATEWAY_TIMEOUT,
|
assertEquals(HttpStatus.SC_GATEWAY_TIMEOUT,
|
||||||
|
@ -1757,8 +1758,8 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
req2.setHeader("Cache-Control", "only-if-cached");
|
req2.setHeader("Cache-Control", "only-if-cached");
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route, req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertTrue(HttpTestUtils.semanticallyTransparent(resp1, result));
|
assertTrue(HttpTestUtils.semanticallyTransparent(resp1, result));
|
||||||
|
@ -1778,8 +1779,8 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
req2.setHeader("Cache-Control", "only-if-cached");
|
req2.setHeader("Cache-Control", "only-if-cached");
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route, req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertEquals(HttpStatus.SC_GATEWAY_TIMEOUT,
|
assertEquals(HttpStatus.SC_GATEWAY_TIMEOUT,
|
||||||
|
@ -1801,8 +1802,8 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
req2.setHeader("Cache-Control", "max-stale=20, only-if-cached");
|
req2.setHeader("Cache-Control", "max-stale=20, only-if-cached");
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route, req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertTrue(HttpTestUtils.semanticallyTransparent(resp1, result));
|
assertTrue(HttpTestUtils.semanticallyTransparent(resp1, result));
|
||||||
|
@ -1822,8 +1823,8 @@ public class TestProtocolRecommendations extends AbstractProtocolTest {
|
||||||
req2.setHeader("If-None-Match","W/\"weak-sauce\"");
|
req2.setHeader("If-None-Match","W/\"weak-sauce\"");
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route, req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertEquals(HttpStatus.SC_NOT_MODIFIED, result.getStatusLine().getStatusCode());
|
assertEquals(HttpStatus.SC_NOT_MODIFIED, result.getStatusLine().getStatusCode());
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -82,8 +82,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequestAndReturn(resp2);
|
backendExpectsAnyRequestAndReturn(resp2);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route,req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route,req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
HttpTestUtils.assert110WarningFound(result);
|
HttpTestUtils.assert110WarningFound(result);
|
||||||
|
@ -110,8 +110,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequestAndReturn(resp2);
|
backendExpectsAnyRequestAndReturn(resp2);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route,req1);
|
impl.execute(route, req1, context, null);
|
||||||
impl.execute(route,req2);
|
impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertTrue(cis.wasClosed());
|
assertTrue(cis.wasClosed());
|
||||||
|
@ -133,8 +133,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequestAndReturn(resp2);
|
backendExpectsAnyRequestAndReturn(resp2);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route,req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route,req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertTrue(HttpStatus.SC_OK != result.getStatusLine().getStatusCode());
|
assertTrue(HttpStatus.SC_OK != result.getStatusLine().getStatusCode());
|
||||||
|
@ -157,8 +157,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequestAndReturn(resp2);
|
backendExpectsAnyRequestAndReturn(resp2);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route,req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route,req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertTrue(HttpStatus.SC_OK != result.getStatusLine().getStatusCode());
|
assertTrue(HttpStatus.SC_OK != result.getStatusLine().getStatusCode());
|
||||||
|
@ -184,8 +184,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequestAndReturn(resp2);
|
backendExpectsAnyRequestAndReturn(resp2);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route,req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route,req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
HttpTestUtils.assert110WarningFound(result);
|
HttpTestUtils.assert110WarningFound(result);
|
||||||
|
@ -208,8 +208,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequestAndReturn(resp2);
|
backendExpectsAnyRequestAndReturn(resp2);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route,req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route,req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertTrue(HttpStatus.SC_OK != result.getStatusLine().getStatusCode());
|
assertTrue(HttpStatus.SC_OK != result.getStatusLine().getStatusCode());
|
||||||
|
@ -232,8 +232,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequestAndReturn(resp2);
|
backendExpectsAnyRequestAndReturn(resp2);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route,req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route,req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
HttpTestUtils.assert110WarningFound(result);
|
HttpTestUtils.assert110WarningFound(result);
|
||||||
|
@ -256,8 +256,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequestAndReturn(resp2);
|
backendExpectsAnyRequestAndReturn(resp2);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route,req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route,req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR,
|
assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR,
|
||||||
|
@ -282,8 +282,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequestAndReturn(resp2);
|
backendExpectsAnyRequestAndReturn(resp2);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route,req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route,req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR,
|
assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR,
|
||||||
|
@ -324,8 +324,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
|
||||||
new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
|
new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route, req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
|
assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
|
||||||
|
@ -369,8 +369,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
|
||||||
req2.setHeader("If-None-Match","\"etag\"");
|
req2.setHeader("If-None-Match","\"etag\"");
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route, req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertEquals(HttpStatus.SC_NOT_MODIFIED, result.getStatusLine().getStatusCode());
|
assertEquals(HttpStatus.SC_NOT_MODIFIED, result.getStatusLine().getStatusCode());
|
||||||
|
@ -420,8 +420,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequestAndReturn(resp2);
|
backendExpectsAnyRequestAndReturn(resp2);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route, req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
|
assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
|
||||||
|
@ -471,8 +471,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequestAndReturn(resp2);
|
backendExpectsAnyRequestAndReturn(resp2);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route, req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
|
assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
|
||||||
|
@ -523,8 +523,8 @@ public class TestRFC5861Compliance extends AbstractProtocolTest {
|
||||||
backendExpectsAnyRequestAndReturn(resp2);
|
backendExpectsAnyRequestAndReturn(resp2);
|
||||||
|
|
||||||
replayMocks();
|
replayMocks();
|
||||||
impl.execute(route, req1);
|
impl.execute(route, req1, context, null);
|
||||||
final HttpResponse result = impl.execute(route, req2);
|
final HttpResponse result = impl.execute(route, req2, context, null);
|
||||||
verifyMocks();
|
verifyMocks();
|
||||||
|
|
||||||
assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
|
assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
|
||||||
|
|
Loading…
Reference in New Issue