hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1418743 [6/6] - in /httpcomponents/httpclient/trunk: httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/ httpclient-cache/src/test/java/org/apache/ht...
Date Sat, 08 Dec 2012 19:59:26 GMT
Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestRFC5861Compliance.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestRFC5861Compliance.java?rev=1418743&r1=1418742&r2=1418743&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestRFC5861Compliance.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestRFC5861Compliance.java
Sat Dec  8 19:59:24 2012
@@ -33,10 +33,10 @@ import java.util.Date;
 
 import org.apache.http.Header;
 import org.apache.http.HttpEntity;
-import org.apache.http.HttpRequest;
 import org.apache.http.HttpResponse;
 import org.apache.http.HttpStatus;
 import org.apache.http.HttpVersion;
+import org.apache.http.client.methods.HttpRequestWrapper;
 import org.apache.http.entity.InputStreamEntity;
 import org.apache.http.impl.cookie.DateUtils;
 import org.apache.http.message.BasicHttpRequest;
@@ -68,20 +68,20 @@ public class TestRFC5861Compliance exten
     public void testStaleIfErrorInResponseIsTrueReturnsStaleEntryWithWarning()
             throws Exception{
         Date tenSecondsAgo = new Date(new Date().getTime() - 10 * 1000L);
-        HttpRequest req1 = HttpTestUtils.makeDefaultRequest();
+        HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
         HttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo,
                 "public, max-age=5, stale-if-error=60");
 
-        backendExpectsAnyRequest().andReturn(resp1);
+        backendExpectsAnyRequestAndReturn(resp1);
 
-        HttpRequest req2 = HttpTestUtils.makeDefaultRequest();
+        HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
         HttpResponse resp2 = HttpTestUtils.make500Response();
 
-        backendExpectsAnyRequest().andReturn(resp2);
+        backendExpectsAnyRequestAndReturn(resp2);
 
         replayMocks();
-        impl.execute(host,req1);
-        HttpResponse result = impl.execute(host,req2);
+        impl.execute(route,req1);
+        HttpResponse result = impl.execute(route,req2);
         verifyMocks();
 
         HttpTestUtils.assert110WarningFound(result);
@@ -91,13 +91,13 @@ public class TestRFC5861Compliance exten
     public void testConsumesErrorResponseWhenServingStale()
             throws Exception{
         Date tenSecondsAgo = new Date(new Date().getTime() - 10 * 1000L);
-        HttpRequest req1 = HttpTestUtils.makeDefaultRequest();
+        HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
         HttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo,
                 "public, max-age=5, stale-if-error=60");
 
-        backendExpectsAnyRequest().andReturn(resp1);
+        backendExpectsAnyRequestAndReturn(resp1);
 
-        HttpRequest req2 = HttpTestUtils.makeDefaultRequest();
+        HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
         HttpResponse resp2 = HttpTestUtils.make500Response();
         byte[] body = HttpTestUtils.getRandomBytes(101);
         ByteArrayInputStream buf = new ByteArrayInputStream(body);
@@ -105,11 +105,11 @@ public class TestRFC5861Compliance exten
         HttpEntity entity = new InputStreamEntity(cis, 101);
         resp2.setEntity(entity);
 
-        backendExpectsAnyRequest().andReturn(resp2);
+        backendExpectsAnyRequestAndReturn(resp2);
 
         replayMocks();
-        impl.execute(host,req1);
-        impl.execute(host,req2);
+        impl.execute(route,req1);
+        impl.execute(route,req2);
         verifyMocks();
 
         assertTrue(cis.wasClosed());
@@ -119,20 +119,20 @@ public class TestRFC5861Compliance exten
     public void testStaleIfErrorInResponseYieldsToMustRevalidate()
             throws Exception{
         Date tenSecondsAgo = new Date(new Date().getTime() - 10 * 1000L);
-        HttpRequest req1 = HttpTestUtils.makeDefaultRequest();
+        HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
         HttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo,
                 "public, max-age=5, stale-if-error=60, must-revalidate");
 
-        backendExpectsAnyRequest().andReturn(resp1);
+        backendExpectsAnyRequestAndReturn(resp1);
 
-        HttpRequest req2 = HttpTestUtils.makeDefaultRequest();
+        HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
         HttpResponse resp2 = HttpTestUtils.make500Response();
 
-        backendExpectsAnyRequest().andReturn(resp2);
+        backendExpectsAnyRequestAndReturn(resp2);
 
         replayMocks();
-        impl.execute(host,req1);
-        HttpResponse result = impl.execute(host,req2);
+        impl.execute(route,req1);
+        HttpResponse result = impl.execute(route,req2);
         verifyMocks();
 
         assertTrue(HttpStatus.SC_OK != result.getStatusLine().getStatusCode());
@@ -141,22 +141,22 @@ public class TestRFC5861Compliance exten
     @Test
     public void testStaleIfErrorInResponseYieldsToProxyRevalidateForSharedCache()
             throws Exception{
-        assertTrue(impl.isSharedCache());
+        assertTrue(config.isSharedCache());
         Date tenSecondsAgo = new Date(new Date().getTime() - 10 * 1000L);
-        HttpRequest req1 = HttpTestUtils.makeDefaultRequest();
+        HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
         HttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo,
                 "public, max-age=5, stale-if-error=60, proxy-revalidate");
 
-        backendExpectsAnyRequest().andReturn(resp1);
+        backendExpectsAnyRequestAndReturn(resp1);
 
-        HttpRequest req2 = HttpTestUtils.makeDefaultRequest();
+        HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
         HttpResponse resp2 = HttpTestUtils.make500Response();
 
-        backendExpectsAnyRequest().andReturn(resp2);
+        backendExpectsAnyRequestAndReturn(resp2);
 
         replayMocks();
-        impl.execute(host,req1);
-        HttpResponse result = impl.execute(host,req2);
+        impl.execute(route,req1);
+        HttpResponse result = impl.execute(route,req2);
         verifyMocks();
 
         assertTrue(HttpStatus.SC_OK != result.getStatusLine().getStatusCode());
@@ -167,23 +167,23 @@ public class TestRFC5861Compliance exten
             throws Exception{
         CacheConfig config = CacheConfig.custom()
                 .setSharedCache(false).build();
-        impl = new CachingHttpClient(mockBackend, config);
+        impl = new CachingExec(mockBackend, new BasicHttpCache(config), config);
 
         Date tenSecondsAgo = new Date(new Date().getTime() - 10 * 1000L);
-        HttpRequest req1 = HttpTestUtils.makeDefaultRequest();
+        HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
         HttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo,
                 "public, max-age=5, stale-if-error=60, proxy-revalidate");
 
-        backendExpectsAnyRequest().andReturn(resp1);
+        backendExpectsAnyRequestAndReturn(resp1);
 
-        HttpRequest req2 = HttpTestUtils.makeDefaultRequest();
+        HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
         HttpResponse resp2 = HttpTestUtils.make500Response();
 
-        backendExpectsAnyRequest().andReturn(resp2);
+        backendExpectsAnyRequestAndReturn(resp2);
 
         replayMocks();
-        impl.execute(host,req1);
-        HttpResponse result = impl.execute(host,req2);
+        impl.execute(route,req1);
+        HttpResponse result = impl.execute(route,req2);
         verifyMocks();
 
         HttpTestUtils.assert110WarningFound(result);
@@ -193,21 +193,21 @@ public class TestRFC5861Compliance exten
     public void testStaleIfErrorInResponseYieldsToExplicitFreshnessRequest()
             throws Exception{
         Date tenSecondsAgo = new Date(new Date().getTime() - 10 * 1000L);
-        HttpRequest req1 = HttpTestUtils.makeDefaultRequest();
+        HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
         HttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo,
                 "public, max-age=5, stale-if-error=60");
 
-        backendExpectsAnyRequest().andReturn(resp1);
+        backendExpectsAnyRequestAndReturn(resp1);
 
-        HttpRequest req2 = HttpTestUtils.makeDefaultRequest();
+        HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
         req2.setHeader("Cache-Control","min-fresh=2");
         HttpResponse resp2 = HttpTestUtils.make500Response();
 
-        backendExpectsAnyRequest().andReturn(resp2);
+        backendExpectsAnyRequestAndReturn(resp2);
 
         replayMocks();
-        impl.execute(host,req1);
-        HttpResponse result = impl.execute(host,req2);
+        impl.execute(route,req1);
+        HttpResponse result = impl.execute(route,req2);
         verifyMocks();
 
         assertTrue(HttpStatus.SC_OK != result.getStatusLine().getStatusCode());
@@ -217,21 +217,21 @@ public class TestRFC5861Compliance exten
     public void testStaleIfErrorInRequestIsTrueReturnsStaleEntryWithWarning()
             throws Exception{
         Date tenSecondsAgo = new Date(new Date().getTime() - 10 * 1000L);
-        HttpRequest req1 = HttpTestUtils.makeDefaultRequest();
+        HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
         HttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo,
                 "public, max-age=5");
 
-        backendExpectsAnyRequest().andReturn(resp1);
+        backendExpectsAnyRequestAndReturn(resp1);
 
-        HttpRequest req2 = HttpTestUtils.makeDefaultRequest();
+        HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
         req2.setHeader("Cache-Control","public, stale-if-error=60");
         HttpResponse resp2 = HttpTestUtils.make500Response();
 
-        backendExpectsAnyRequest().andReturn(resp2);
+        backendExpectsAnyRequestAndReturn(resp2);
 
         replayMocks();
-        impl.execute(host,req1);
-        HttpResponse result = impl.execute(host,req2);
+        impl.execute(route,req1);
+        HttpResponse result = impl.execute(route,req2);
         verifyMocks();
 
         HttpTestUtils.assert110WarningFound(result);
@@ -242,20 +242,20 @@ public class TestRFC5861Compliance exten
             throws Exception{
         Date now = new Date();
         Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
-        HttpRequest req1 = HttpTestUtils.makeDefaultRequest();
+        HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
         HttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo,
                 "public, max-age=5, stale-if-error=2");
 
-        backendExpectsAnyRequest().andReturn(resp1);
+        backendExpectsAnyRequestAndReturn(resp1);
 
-        HttpRequest req2 = HttpTestUtils.makeDefaultRequest();
+        HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
         HttpResponse resp2 = HttpTestUtils.make500Response();
 
-        backendExpectsAnyRequest().andReturn(resp2);
+        backendExpectsAnyRequestAndReturn(resp2);
 
         replayMocks();
-        impl.execute(host,req1);
-        HttpResponse result = impl.execute(host,req2);
+        impl.execute(route,req1);
+        HttpResponse result = impl.execute(route,req2);
         verifyMocks();
 
         assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR,
@@ -267,21 +267,21 @@ public class TestRFC5861Compliance exten
             throws Exception{
         Date now = new Date();
         Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
-        HttpRequest req1 = HttpTestUtils.makeDefaultRequest();
+        HttpRequestWrapper req1 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
         HttpResponse resp1 = HttpTestUtils.make200Response(tenSecondsAgo,
                 "public, max-age=5");
 
-        backendExpectsAnyRequest().andReturn(resp1);
+        backendExpectsAnyRequestAndReturn(resp1);
 
-        HttpRequest req2 = HttpTestUtils.makeDefaultRequest();
+        HttpRequestWrapper req2 = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest());
         req2.setHeader("Cache-Control","stale-if-error=2");
         HttpResponse resp2 = HttpTestUtils.make500Response();
 
-        backendExpectsAnyRequest().andReturn(resp2);
+        backendExpectsAnyRequestAndReturn(resp2);
 
         replayMocks();
-        impl.execute(host,req1);
-        HttpResponse result = impl.execute(host,req2);
+        impl.execute(route,req1);
+        HttpResponse result = impl.execute(route,req2);
         verifyMocks();
 
         assertEquals(HttpStatus.SC_INTERNAL_SERVER_ERROR,
@@ -305,9 +305,10 @@ public class TestRFC5861Compliance exten
                 .setAsynchronousWorkersMax(1)
                 .build();
 
-        impl = new CachingHttpClient(mockBackend, cache, config);
+        impl = new CachingExec(mockBackend, cache, config);
 
-        HttpRequest req1 = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
+        HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
+                new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
         HttpResponse resp1 = HttpTestUtils.make200Response();
         Date now = new Date();
         Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
@@ -315,13 +316,14 @@ public class TestRFC5861Compliance exten
         resp1.setHeader("ETag","\"etag\"");
         resp1.setHeader("Date", DateUtils.formatDate(tenSecondsAgo));
 
-        backendExpectsAnyRequest().andReturn(resp1).times(1,2);
+        backendExpectsAnyRequestAndReturn(resp1).times(1,2);
 
-        HttpRequest req2 = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
+        HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
+                new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
 
         replayMocks();
-        impl.execute(host, req1);
-        HttpResponse result = impl.execute(host, req2);
+        impl.execute(route, req1);
+        HttpResponse result = impl.execute(route, req2);
         verifyMocks();
 
         assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
@@ -347,9 +349,10 @@ public class TestRFC5861Compliance exten
                 .setAsynchronousWorkersMax(1)
                 .setSharedCache(false)
                 .build();
-        impl = new CachingHttpClient(mockBackend, cache, config);
+        impl = new CachingExec(mockBackend, cache, config);
 
-        HttpRequest req1 = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
+        HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
+                new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
         HttpResponse resp1 = HttpTestUtils.make200Response();
         Date now = new Date();
         Date tenSecondsAgo = new Date(now.getTime() - 10 * 1000L);
@@ -357,14 +360,15 @@ public class TestRFC5861Compliance exten
         resp1.setHeader("ETag","\"etag\"");
         resp1.setHeader("Date", DateUtils.formatDate(tenSecondsAgo));
 
-        backendExpectsAnyRequest().andReturn(resp1).times(1,2);
+        backendExpectsAnyRequestAndReturn(resp1).times(1,2);
 
-        HttpRequest req2 = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
+        HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
+                new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
         req2.setHeader("If-None-Match","\"etag\"");
 
         replayMocks();
-        impl.execute(host, req1);
-        HttpResponse result = impl.execute(host, req2);
+        impl.execute(route, req1);
+        HttpResponse result = impl.execute(route, req2);
         verifyMocks();
 
         assertEquals(HttpStatus.SC_NOT_MODIFIED, result.getStatusLine().getStatusCode());
@@ -393,27 +397,29 @@ public class TestRFC5861Compliance exten
                 .setMaxObjectSize(MAX_BYTES)
                 .setAsynchronousWorkersMax(1)
                 .build();
-        impl = new CachingHttpClient(mockBackend, cache, config);
+        impl = new CachingExec(mockBackend, cache, config);
 
-        HttpRequest req1 = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
+        HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
+                new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
         HttpResponse resp1 = HttpTestUtils.make200Response();
         resp1.setHeader("Cache-Control", "public, max-age=5, stale-while-revalidate=15, must-revalidate");
         resp1.setHeader("ETag","\"etag\"");
         resp1.setHeader("Date", DateUtils.formatDate(tenSecondsAgo));
 
-        backendExpectsAnyRequest().andReturn(resp1);
+        backendExpectsAnyRequestAndReturn(resp1);
 
-        HttpRequest req2 = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
+        HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
+                new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
         HttpResponse resp2 = HttpTestUtils.make200Response();
         resp2.setHeader("Cache-Control", "public, max-age=5, stale-while-revalidate=15, must-revalidate");
         resp2.setHeader("ETag","\"etag\"");
         resp2.setHeader("Date", DateUtils.formatDate(now));
 
-        backendExpectsAnyRequest().andReturn(resp2);
+        backendExpectsAnyRequestAndReturn(resp2);
 
         replayMocks();
-        impl.execute(host, req1);
-        HttpResponse result = impl.execute(host, req2);
+        impl.execute(route, req1);
+        HttpResponse result = impl.execute(route, req2);
         verifyMocks();
 
         assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
@@ -442,27 +448,29 @@ public class TestRFC5861Compliance exten
                 .setAsynchronousWorkersMax(1)
                 .setSharedCache(true)
                 .build();
-        impl = new CachingHttpClient(mockBackend, cache, config);
+        impl = new CachingExec(mockBackend, cache, config);
 
-        HttpRequest req1 = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
+        HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
+                new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
         HttpResponse resp1 = HttpTestUtils.make200Response();
         resp1.setHeader("Cache-Control", "public, max-age=5, stale-while-revalidate=15, proxy-revalidate");
         resp1.setHeader("ETag","\"etag\"");
         resp1.setHeader("Date", DateUtils.formatDate(tenSecondsAgo));
 
-        backendExpectsAnyRequest().andReturn(resp1);
+        backendExpectsAnyRequestAndReturn(resp1);
 
-        HttpRequest req2 = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
+        HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
+                new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
         HttpResponse resp2 = HttpTestUtils.make200Response();
         resp2.setHeader("Cache-Control", "public, max-age=5, stale-while-revalidate=15, proxy-revalidate");
         resp2.setHeader("ETag","\"etag\"");
         resp2.setHeader("Date", DateUtils.formatDate(now));
 
-        backendExpectsAnyRequest().andReturn(resp2);
+        backendExpectsAnyRequestAndReturn(resp2);
 
         replayMocks();
-        impl.execute(host, req1);
-        HttpResponse result = impl.execute(host, req2);
+        impl.execute(route, req1);
+        HttpResponse result = impl.execute(route, req2);
         verifyMocks();
 
         assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());
@@ -491,28 +499,30 @@ public class TestRFC5861Compliance exten
                 .setAsynchronousWorkersMax(1)
                 .setSharedCache(true)
                 .build();
-        impl = new CachingHttpClient(mockBackend, cache, config);
+        impl = new CachingExec(mockBackend, cache, config);
 
-        HttpRequest req1 = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
+        HttpRequestWrapper req1 = HttpRequestWrapper.wrap(
+                new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
         HttpResponse resp1 = HttpTestUtils.make200Response();
         resp1.setHeader("Cache-Control", "public, max-age=5, stale-while-revalidate=15");
         resp1.setHeader("ETag","\"etag\"");
         resp1.setHeader("Date", DateUtils.formatDate(tenSecondsAgo));
 
-        backendExpectsAnyRequest().andReturn(resp1);
+        backendExpectsAnyRequestAndReturn(resp1);
 
-        HttpRequest req2 = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
+        HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
+                new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1));
         req2.setHeader("Cache-Control","min-fresh=2");
         HttpResponse resp2 = HttpTestUtils.make200Response();
         resp2.setHeader("Cache-Control", "public, max-age=5, stale-while-revalidate=15");
         resp2.setHeader("ETag","\"etag\"");
         resp2.setHeader("Date", DateUtils.formatDate(now));
 
-        backendExpectsAnyRequest().andReturn(resp2);
+        backendExpectsAnyRequestAndReturn(resp2);
 
         replayMocks();
-        impl.execute(host, req1);
-        HttpResponse result = impl.execute(host, req2);
+        impl.execute(route, req1);
+        HttpResponse result = impl.execute(route, req2);
         verifyMocks();
 
         assertEquals(HttpStatus.SC_OK, result.getStatusLine().getStatusCode());

Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheProtocolRequirements.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheProtocolRequirements.java?rev=1418743&r1=1418742&r2=1418743&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheProtocolRequirements.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/ehcache/TestEhcacheProtocolRequirements.java
Sat Dec  8 19:59:24 2012
@@ -31,12 +31,12 @@ import net.sf.ehcache.config.CacheConfig
 import net.sf.ehcache.config.Configuration;
 import net.sf.ehcache.store.MemoryStoreEvictionPolicy;
 
-import org.apache.http.client.HttpClient;
 import org.apache.http.client.cache.HttpCacheStorage;
 import org.apache.http.impl.client.cache.CacheConfig;
-import org.apache.http.impl.client.cache.CachingHttpClient;
+import org.apache.http.impl.client.cache.CachingExec;
 import org.apache.http.impl.client.cache.HeapResourceFactory;
 import org.apache.http.impl.client.cache.TestProtocolRequirements;
+import org.apache.http.impl.client.execchain.ClientExecChain;
 import org.easymock.classextension.EasyMock;
 import org.junit.After;
 import org.junit.AfterClass;
@@ -70,9 +70,9 @@ public class TestEhcacheProtocolRequirem
         }
         CACHE_MANAGER.addCache(TEST_EHCACHE_NAME);
         HttpCacheStorage storage = new EhcacheHttpCacheStorage(CACHE_MANAGER.getCache(TEST_EHCACHE_NAME));
-        mockBackend = EasyMock.createNiceMock(HttpClient.class);
+        mockBackend = EasyMock.createNiceMock(ClientExecChain.class);
 
-        impl = new CachingHttpClient(mockBackend, new HeapResourceFactory(), storage, config);
+        impl = new CachingExec(mockBackend, new HeapResourceFactory(), storage, config);
     }
 
     @After

Modified: httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestMemcachedHttpCacheStorage.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestMemcachedHttpCacheStorage.java?rev=1418743&r1=1418742&r2=1418743&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestMemcachedHttpCacheStorage.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestMemcachedHttpCacheStorage.java
Sat Dec  8 19:59:24 2012
@@ -109,7 +109,7 @@ public class TestMemcachedHttpCacheStora
         impl.putEntry(url, value);
         verifyMocks();
     }
-    
+
     @Test
     public void testCachePutFailsSilentlyWhenWeCannotHashAKey() throws IOException {
         final String url = "foo";
@@ -127,7 +127,7 @@ public class TestMemcachedHttpCacheStora
         impl.putEntry(url, value);
         verifyMocks();
     }
-    
+
     public void testThrowsIOExceptionWhenMemcachedPutTimesOut() {
         final String url = "foo";
         final String key = "key";
@@ -170,11 +170,11 @@ public class TestMemcachedHttpCacheStora
             impl.putEntry(url, value);
             fail("should have thrown exception");
         } catch (IOException expected) {
-            
+
         }
         verifyMocks();
     }
-    
+
     @Test
     public void testSuccessfulCacheGet() throws UnsupportedEncodingException,
             IOException {
@@ -182,7 +182,7 @@ public class TestMemcachedHttpCacheStora
         final String key = "key";
         byte[] serialized = HttpTestUtils.getRandomBytes(128);
         final HttpCacheEntry cacheEntry = HttpTestUtils.makeCacheEntry();
-        
+
         EasyMock.expect(mockKeyHashingScheme.hash(url)).andReturn(key);
         EasyMock.expect(mockMemcachedClient.get(key)).andReturn(serialized);
         EasyMock.expect(mockMemcachedCacheEntryFactory.getUnsetCacheEntry())
@@ -190,57 +190,57 @@ public class TestMemcachedHttpCacheStora
         mockMemcachedCacheEntry.set(serialized);
         EasyMock.expect(mockMemcachedCacheEntry.getStorageKey()).andReturn(url);
         EasyMock.expect(mockMemcachedCacheEntry.getHttpCacheEntry()).andReturn(cacheEntry);
-        
+
         replayMocks();
         HttpCacheEntry resultingEntry = impl.getEntry(url);
         verifyMocks();
         assertSame(cacheEntry, resultingEntry);
     }
-    
+
     @Test
     public void testTreatsNoneByteArrayFromMemcachedAsCacheMiss() throws UnsupportedEncodingException,
             IOException {
         final String url = "foo";
         final String key = "key";
-        
+
         EasyMock.expect(mockKeyHashingScheme.hash(url)).andReturn(key);
         EasyMock.expect(mockMemcachedClient.get(key)).andReturn(new Object());
-        
+
         replayMocks();
         HttpCacheEntry resultingEntry = impl.getEntry(url);
         verifyMocks();
         assertNull(resultingEntry);
     }
-    
+
     @Test
     public void testTreatsNullFromMemcachedAsCacheMiss() throws UnsupportedEncodingException,
             IOException {
         final String url = "foo";
         final String key = "key";
-        
+
         EasyMock.expect(mockKeyHashingScheme.hash(url)).andReturn(key);
         EasyMock.expect(mockMemcachedClient.get(key)).andReturn(null);
-        
+
         replayMocks();
         HttpCacheEntry resultingEntry = impl.getEntry(url);
         verifyMocks();
         assertNull(resultingEntry);
     }
-    
+
     @Test
     public void testTreatsAsCacheMissIfCannotReconstituteEntry() throws UnsupportedEncodingException,
             IOException {
         final String url = "foo";
         final String key = "key";
         byte[] serialized = HttpTestUtils.getRandomBytes(128);
-        
+
         EasyMock.expect(mockKeyHashingScheme.hash(url)).andReturn(key);
         EasyMock.expect(mockMemcachedClient.get(key)).andReturn(serialized);
         EasyMock.expect(mockMemcachedCacheEntryFactory.getUnsetCacheEntry())
             .andReturn(mockMemcachedCacheEntry);
         mockMemcachedCacheEntry.set(serialized);
         EasyMock.expectLastCall().andThrow(new MemcachedSerializationException(new Exception()));
-        
+
         replayMocks();
         assertNull(impl.getEntry(url));
         verifyMocks();
@@ -250,9 +250,9 @@ public class TestMemcachedHttpCacheStora
     public void testTreatsAsCacheMissIfCantHashStorageKey() throws UnsupportedEncodingException,
             IOException {
         final String url = "foo";
-        
+
         EasyMock.expect(mockKeyHashingScheme.hash(url)).andThrow(new MemcachedKeyHashingException(new
Exception()));
-        
+
         replayMocks();
         assertNull(impl.getEntry(url));
         verifyMocks();
@@ -265,7 +265,7 @@ public class TestMemcachedHttpCacheStora
         EasyMock.expect(mockKeyHashingScheme.hash(url)).andReturn(key);
         EasyMock.expect(mockMemcachedClient.get(key))
             .andThrow(new OperationTimeoutException(""));
-        
+
         replayMocks();
         try {
             impl.getEntry(url);
@@ -285,7 +285,7 @@ public class TestMemcachedHttpCacheStora
         impl.removeEntry(url);
         verifyMocks();
     }
-    
+
     @Test
     public void testCacheRemoveHandlesKeyHashingFailure() throws IOException {
         final String url = "foo";
@@ -302,7 +302,7 @@ public class TestMemcachedHttpCacheStora
         EasyMock.expect(mockKeyHashingScheme.hash(url)).andReturn(key);
         EasyMock.expect(mockMemcachedClient.delete(key))
             .andThrow(new OperationTimeoutException(""));
-        
+
         replayMocks();
         try {
             impl.removeEntry(url);
@@ -341,7 +341,7 @@ public class TestMemcachedHttpCacheStora
         impl.updateEntry(url, callback);
         verifyMocks();
     }
-    
+
     @Test
     public void testCacheUpdateOverwritesNonMatchingHashCollision() throws IOException,
             HttpCacheUpdateException {
@@ -366,7 +366,7 @@ public class TestMemcachedHttpCacheStora
             .andReturn(mockMemcachedCacheEntry);
         mockMemcachedCacheEntry.set(oldBytes);
         EasyMock.expect(mockMemcachedCacheEntry.getStorageKey()).andReturn("not" + url).anyTimes();
-        
+
         EasyMock.expect(mockMemcachedCacheEntryFactory.getMemcachedCacheEntry(url, updatedValue))
             .andReturn(mockMemcachedCacheEntry2);
         EasyMock.expect(mockMemcachedCacheEntry2.toByteArray()).andReturn(newBytes);
@@ -389,7 +389,7 @@ public class TestMemcachedHttpCacheStora
         final byte[] oldBytes = HttpTestUtils.getRandomBytes(128);
         CASValue<Object> casValue = new CASValue<Object>(1, oldBytes);
         final byte[] newBytes = HttpTestUtils.getRandomBytes(128);
-        
+
 
         HttpCacheUpdateCallback callback = new HttpCacheUpdateCallback() {
             public HttpCacheEntry update(HttpCacheEntry old) {
@@ -406,7 +406,7 @@ public class TestMemcachedHttpCacheStora
         mockMemcachedCacheEntry.set(oldBytes);
         EasyMock.expect(mockMemcachedCacheEntry.getStorageKey()).andReturn(url);
         EasyMock.expect(mockMemcachedCacheEntry.getHttpCacheEntry()).andReturn(existingValue);
-        
+
         EasyMock.expect(mockMemcachedCacheEntryFactory.getMemcachedCacheEntry(url, updatedValue))
             .andReturn(mockMemcachedCacheEntry2);
         EasyMock.expect(mockMemcachedCacheEntry2.toByteArray()).andReturn(newBytes);
@@ -419,7 +419,7 @@ public class TestMemcachedHttpCacheStora
         impl.updateEntry(url, callback);
         verifyMocks();
     }
-    
+
     @Test
     public void testCacheUpdateThrowsExceptionsIfCASFailsEnoughTimes() throws IOException
{
         final String url = "foo";
@@ -429,7 +429,7 @@ public class TestMemcachedHttpCacheStora
         final byte[] oldBytes = HttpTestUtils.getRandomBytes(128);
         CASValue<Object> casValue = new CASValue<Object>(1, oldBytes);
         final byte[] newBytes = HttpTestUtils.getRandomBytes(128);
-        
+
         CacheConfig config = CacheConfig.custom().setMaxUpdateRetries(0).build();
         impl = new MemcachedHttpCacheStorage(mockMemcachedClient, config,
                 mockMemcachedCacheEntryFactory, mockKeyHashingScheme);
@@ -449,7 +449,7 @@ public class TestMemcachedHttpCacheStora
         mockMemcachedCacheEntry.set(oldBytes);
         EasyMock.expect(mockMemcachedCacheEntry.getStorageKey()).andReturn(url);
         EasyMock.expect(mockMemcachedCacheEntry.getHttpCacheEntry()).andReturn(existingValue);
-        
+
         EasyMock.expect(mockMemcachedCacheEntryFactory.getMemcachedCacheEntry(url, updatedValue))
             .andReturn(mockMemcachedCacheEntry2);
         EasyMock.expect(mockMemcachedCacheEntry2.toByteArray()).andReturn(newBytes);
@@ -467,7 +467,7 @@ public class TestMemcachedHttpCacheStora
         verifyMocks();
     }
 
-    
+
     @Test
     public void testCacheUpdateCanUpdateExistingEntryWithRetry() throws IOException,
             HttpCacheUpdateException {
@@ -499,7 +499,7 @@ public class TestMemcachedHttpCacheStora
         mockMemcachedCacheEntry.set(oldBytes);
         EasyMock.expect(mockMemcachedCacheEntry.getStorageKey()).andReturn(url);
         EasyMock.expect(mockMemcachedCacheEntry.getHttpCacheEntry()).andReturn(existingValue);
-        
+
         EasyMock.expect(mockMemcachedCacheEntryFactory.getMemcachedCacheEntry(url, updatedValue))
             .andReturn(mockMemcachedCacheEntry2);
         EasyMock.expect(mockMemcachedCacheEntry2.toByteArray()).andReturn(newBytes);
@@ -515,7 +515,7 @@ public class TestMemcachedHttpCacheStora
         mockMemcachedCacheEntry3.set(oldBytes2);
         EasyMock.expect(mockMemcachedCacheEntry3.getStorageKey()).andReturn(url);
         EasyMock.expect(mockMemcachedCacheEntry3.getHttpCacheEntry()).andReturn(existingValue2);
-        
+
         EasyMock.expect(mockMemcachedCacheEntryFactory.getMemcachedCacheEntry(url, updatedValue2))
             .andReturn(mockMemcachedCacheEntry4);
         EasyMock.expect(mockMemcachedCacheEntry4.toByteArray()).andReturn(newBytes2);
@@ -523,7 +523,7 @@ public class TestMemcachedHttpCacheStora
         EasyMock.expect(
                 mockMemcachedClient.cas(EasyMock.eq(key), EasyMock.eq(casValue2.getCas()),
                         EasyMock.aryEq(newBytes2))).andReturn(CASResponse.OK);
-        
+
         replayMocks();
         impl.updateEntry(url, callback);
         verifyMocks();
@@ -557,7 +557,7 @@ public class TestMemcachedHttpCacheStora
         verifyMocks();
     }
 
-    
+
     @Test(expected=HttpCacheUpdateException.class)
     public void testThrowsExceptionOnUpdateIfCannotHashStorageKey() throws Exception {
         final String url = "foo";

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/MainClientExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/MainClientExec.java?rev=1418743&r1=1418742&r2=1418743&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/MainClientExec.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/MainClientExec.java
Sat Dec  8 19:59:24 2012
@@ -167,7 +167,7 @@ public class MainClientExec implements C
         }
 
         if (request instanceof HttpEntityEnclosingRequest) {
-            ExecProxies.enhanceEntity((HttpEntityEnclosingRequest) request);
+            Proxies.enhanceEntity((HttpEntityEnclosingRequest) request);
         }
 
         Object userToken = context.getUserToken();
@@ -220,7 +220,7 @@ public class MainClientExec implements C
             HttpResponse response = null;
             for (int execCount = 1;; execCount++) {
 
-                if (execCount > 1 && !ExecProxies.isRepeatable(request)) {
+                if (execCount > 1 && !Proxies.isRepeatable(request)) {
                     throw new NonRepeatableRequestException("Cannot retry request " +
                             "with a non-repeatable request entity.");
                 }
@@ -333,9 +333,9 @@ public class MainClientExec implements C
             if (entity == null || !entity.isStreaming()) {
                 // connection not needed and (assumed to be) in re-usable state
                 releaseTrigger.releaseConnection();
-                return ExecProxies.enhanceResponse(response, null);
+                return Proxies.enhanceResponse(response, null);
             } else {
-                return ExecProxies.enhanceResponse(response, releaseTrigger);
+                return Proxies.enhanceResponse(response, releaseTrigger);
             }
         } catch (ConnectionShutdownException ex) {
             InterruptedIOException ioex = new InterruptedIOException(

Copied: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/Proxies.java
(from r1418654, httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ExecProxies.java)
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/Proxies.java?p2=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/Proxies.java&p1=httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ExecProxies.java&r1=1418654&r2=1418743&rev=1418743&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/ExecProxies.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/Proxies.java
Sat Dec  8 19:59:24 2012
@@ -16,7 +16,7 @@ import org.apache.http.client.methods.Cl
  * @since 4.3
  */
 @NotThreadSafe
-class ExecProxies {
+class Proxies {
 
     static void enhanceEntity(final HttpEntityEnclosingRequest request) {
         HttpEntity entity = request.getEntity();

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/Proxies.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/Proxies.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/Proxies.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RedirectExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RedirectExec.java?rev=1418743&r1=1418742&r2=1418743&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RedirectExec.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RedirectExec.java
Sat Dec  8 19:59:24 2012
@@ -119,7 +119,7 @@ public class RedirectExec implements Cli
                     currentRequest = HttpRequestWrapper.wrap(redirect);
                     currentRequest.setHeaders(original.getAllHeaders());
                     if (original instanceof HttpEntityEnclosingRequest) {
-                        ExecProxies.enhanceEntity((HttpEntityEnclosingRequest) request);
+                        Proxies.enhanceEntity((HttpEntityEnclosingRequest) request);
                     }
 
                     URI uri = currentRequest.getURI();

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RetryExec.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RetryExec.java?rev=1418743&r1=1418742&r2=1418743&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RetryExec.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/execchain/RetryExec.java
Sat Dec  8 19:59:24 2012
@@ -98,7 +98,7 @@ public class RetryExec implements Client
                     if (this.log.isDebugEnabled()) {
                         this.log.debug(ex.getMessage(), ex);
                     }
-                    if (!ExecProxies.isRepeatable(request)) {
+                    if (!Proxies.isRepeatable(request)) {
                         this.log.debug("Cannot retry non-repeatable request");
                         throw new NonRepeatableRequestException("Cannot retry request " +
                                 "with a non-repeatable request entity", ex);



Mime
View raw message