hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1776187 [4/21] - in /httpcomponents/httpclient/trunk: ./ httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/ httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ httpclient5-cache/src/test/java/org/apache/hc...
Date Tue, 27 Dec 2016 19:48:10 GMT
Modified: httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAsynchronousValidationRequest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAsynchronousValidationRequest.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAsynchronousValidationRequest.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAsynchronousValidationRequest.java Tue Dec 27 19:48:07 2016
@@ -35,15 +35,14 @@ import java.io.IOException;
 import org.apache.hc.client5.http.HttpRoute;
 import org.apache.hc.client5.http.cache.HeaderConstants;
 import org.apache.hc.client5.http.cache.HttpCacheEntry;
-import org.apache.hc.client5.http.methods.CloseableHttpResponse;
 import org.apache.hc.client5.http.methods.HttpExecutionAware;
 import org.apache.hc.client5.http.methods.HttpGet;
-import org.apache.hc.client5.http.methods.HttpRequestWrapper;
+import org.apache.hc.client5.http.methods.RoutedHttpRequest;
 import org.apache.hc.client5.http.protocol.HttpClientContext;
+import org.apache.hc.core5.http.ClassicHttpResponse;
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.http.ProtocolException;
-import org.apache.hc.core5.http.StatusLine;
 import org.apache.hc.core5.http.message.BasicHeader;
 import org.junit.Before;
 import org.junit.Test;
@@ -55,12 +54,11 @@ public class TestAsynchronousValidationR
     private CachingExec mockClient;
     private HttpHost host;
     private HttpRoute route;
-    private HttpRequestWrapper request;
+    private RoutedHttpRequest request;
     private HttpClientContext context;
     private HttpExecutionAware mockExecAware;
     private HttpCacheEntry mockCacheEntry;
-    private CloseableHttpResponse mockResponse;
-    private StatusLine mockStatusLine;
+    private ClassicHttpResponse mockResponse;
 
     @Before
     public void setUp() {
@@ -68,12 +66,11 @@ public class TestAsynchronousValidationR
         mockClient = mock(CachingExec.class);
         host = new HttpHost("foo.example.com", 80);
         route = new HttpRoute(host);
-        request = HttpRequestWrapper.wrap(new HttpGet("/"), host);
+        request = RoutedHttpRequest.adapt(new HttpGet("/"), route);
         context = HttpClientContext.create();
         mockExecAware = mock(HttpExecutionAware.class);
         mockCacheEntry = mock(HttpCacheEntry.class);
-        mockResponse = mock(CloseableHttpResponse.class);
-        mockStatusLine = mock(StatusLine.class);
+        mockResponse = mock(ClassicHttpResponse.class);
     }
 
     @Test
@@ -81,20 +78,18 @@ public class TestAsynchronousValidationR
         final String identifier = "foo";
 
         final AsynchronousValidationRequest impl = new AsynchronousValidationRequest(
-                mockParent, mockClient, route, request, context, mockExecAware, mockCacheEntry,
+                mockParent, mockClient, request, context, mockExecAware, mockCacheEntry,
                 identifier, 0);
 
         when(
                 mockClient.revalidateCacheEntry(
-                        route, request, context, mockExecAware, mockCacheEntry)).thenReturn(mockResponse);
-        when(mockResponse.getStatusLine()).thenReturn(mockStatusLine);
-        when(mockStatusLine.getStatusCode()).thenReturn(200);
+                        request, context, mockExecAware, mockCacheEntry)).thenReturn(mockResponse);
+        when(mockResponse.getCode()).thenReturn(200);
 
         impl.run();
 
         verify(mockClient).revalidateCacheEntry(
-                route, request, context, mockExecAware, mockCacheEntry);
-        verify(mockResponse).getStatusLine();
+                request, context, mockExecAware, mockCacheEntry);
         verify(mockParent).markComplete(identifier);
         verify(mockParent).jobSuccessful(identifier);
     }
@@ -104,21 +99,18 @@ public class TestAsynchronousValidationR
         final String identifier = "foo";
 
         final AsynchronousValidationRequest impl = new AsynchronousValidationRequest(
-                mockParent, mockClient, route, request, context, mockExecAware, mockCacheEntry,
+                mockParent, mockClient, request, context, mockExecAware, mockCacheEntry,
                 identifier, 0);
 
         when(
                 mockClient.revalidateCacheEntry(
-                        route, request, context, mockExecAware, mockCacheEntry)).thenReturn(mockResponse);
-        when(mockResponse.getStatusLine()).thenReturn(mockStatusLine);
-        when(mockStatusLine.getStatusCode()).thenReturn(200);
+                        request, context, mockExecAware, mockCacheEntry)).thenReturn(mockResponse);
+        when(mockResponse.getCode()).thenReturn(200);
 
         impl.run();
 
         verify(mockClient).revalidateCacheEntry(
-                route, request, context, mockExecAware, mockCacheEntry);
-        verify(mockResponse).getStatusLine();
-        verify(mockStatusLine).getStatusCode();
+                request, context, mockExecAware, mockCacheEntry);
         verify(mockParent).markComplete(identifier);
         verify(mockParent).jobSuccessful(identifier);
     }
@@ -129,22 +121,19 @@ public class TestAsynchronousValidationR
         final Header[] warning = new Header[] {new BasicHeader(HeaderConstants.WARNING, "110 localhost \"Response is stale\"")};
 
         final AsynchronousValidationRequest impl = new AsynchronousValidationRequest(
-                mockParent, mockClient, route, request, context, mockExecAware, mockCacheEntry,
+                mockParent, mockClient, request, context, mockExecAware, mockCacheEntry,
                 identifier, 0);
 
         when(
                 mockClient.revalidateCacheEntry(
-                        route, request, context, mockExecAware, mockCacheEntry)).thenReturn(mockResponse);
-        when(mockResponse.getStatusLine()).thenReturn(mockStatusLine);
-        when(mockStatusLine.getStatusCode()).thenReturn(200);
+                        request, context, mockExecAware, mockCacheEntry)).thenReturn(mockResponse);
+        when(mockResponse.getCode()).thenReturn(200);
         when(mockResponse.getHeaders(HeaderConstants.WARNING)).thenReturn(warning);
 
         impl.run();
 
         verify(mockClient).revalidateCacheEntry(
-                route, request, context, mockExecAware, mockCacheEntry);
-        verify(mockResponse).getStatusLine();
-        verify(mockStatusLine).getStatusCode();
+                request, context, mockExecAware, mockCacheEntry);
         verify(mockResponse).getHeaders(HeaderConstants.WARNING);
         verify(mockParent).markComplete(identifier);
         verify(mockParent).jobFailed(identifier);
@@ -155,18 +144,18 @@ public class TestAsynchronousValidationR
         final String identifier = "foo";
 
         final AsynchronousValidationRequest impl = new AsynchronousValidationRequest(
-                mockParent, mockClient, route, request, context, mockExecAware, mockCacheEntry,
+                mockParent, mockClient, request, context, mockExecAware, mockCacheEntry,
                 identifier, 0);
 
         when(
                 mockClient.revalidateCacheEntry(
-                        route, request, context, mockExecAware, mockCacheEntry)).thenThrow(
+                        request, context, mockExecAware, mockCacheEntry)).thenThrow(
                 new ProtocolException());
 
         impl.run();
 
         verify(mockClient).revalidateCacheEntry(
-                route, request, context, mockExecAware, mockCacheEntry);
+                request, context, mockExecAware, mockCacheEntry);
         verify(mockParent).markComplete(identifier);
         verify(mockParent).jobFailed(identifier);
     }
@@ -176,18 +165,18 @@ public class TestAsynchronousValidationR
         final String identifier = "foo";
 
         final AsynchronousValidationRequest impl = new AsynchronousValidationRequest(
-                mockParent, mockClient, route, request, context, mockExecAware, mockCacheEntry,
+                mockParent, mockClient, request, context, mockExecAware, mockCacheEntry,
                 identifier, 0);
 
         when(
                 mockClient.revalidateCacheEntry(
-                        route, request, context, mockExecAware, mockCacheEntry)).thenThrow(
+                        request, context, mockExecAware, mockCacheEntry)).thenThrow(
                                 new IOException());
 
         impl.run();
 
         verify(mockClient).revalidateCacheEntry(
-                route, request, context, mockExecAware, mockCacheEntry);
+                request, context, mockExecAware, mockCacheEntry);
         verify(mockParent).markComplete(identifier);
         verify(mockParent).jobFailed(identifier);
     }
@@ -197,18 +186,18 @@ public class TestAsynchronousValidationR
         final String identifier = "foo";
 
         final AsynchronousValidationRequest impl = new AsynchronousValidationRequest(
-                mockParent, mockClient, route, request, context, mockExecAware, mockCacheEntry,
+                mockParent, mockClient, request, context, mockExecAware, mockCacheEntry,
                 identifier, 0);
 
         when(
                 mockClient.revalidateCacheEntry(
-                        route, request, context, mockExecAware, mockCacheEntry)).thenThrow(
+                        request, context, mockExecAware, mockCacheEntry)).thenThrow(
                                 new RuntimeException());
 
         impl.run();
 
         verify(mockClient).revalidateCacheEntry(
-                route, request, context, mockExecAware, mockCacheEntry);
+                request, context, mockExecAware, mockCacheEntry);
         verify(mockParent).markComplete(identifier);
         verify(mockParent).jobFailed(identifier);
     }

Modified: httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAsynchronousValidator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAsynchronousValidator.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAsynchronousValidator.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAsynchronousValidator.java Tue Dec 27 19:48:07 2016
@@ -42,12 +42,13 @@ import org.apache.hc.client5.http.cache.
 import org.apache.hc.client5.http.cache.HttpCacheEntry;
 import org.apache.hc.client5.http.methods.HttpExecutionAware;
 import org.apache.hc.client5.http.methods.HttpGet;
-import org.apache.hc.client5.http.methods.HttpRequestWrapper;
+import org.apache.hc.client5.http.methods.RoutedHttpRequest;
 import org.apache.hc.client5.http.protocol.HttpClientContext;
+import org.apache.hc.core5.http.ClassicHttpRequest;
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.HttpRequest;
 import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.message.BasicHeaderIterator;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -61,7 +62,7 @@ public class TestAsynchronousValidator {
     private CachingExec mockClient;
     private HttpHost host;
     private HttpRoute route;
-    private HttpRequestWrapper request;
+    private RoutedHttpRequest request;
     private HttpClientContext context;
     private HttpExecutionAware mockExecAware;
     private HttpCacheEntry mockCacheEntry;
@@ -73,9 +74,8 @@ public class TestAsynchronousValidator {
         mockClient = mock(CachingExec.class);
         host = new HttpHost("foo.example.com", 80);
         route = new HttpRoute(host);
-        request = HttpRequestWrapper.wrap(new HttpGet("/"), host);
+        request = RoutedHttpRequest.adapt(new HttpGet("/"), route);
         context = HttpClientContext.create();
-        context.setTargetHost(new HttpHost("foo.example.com"));
         mockExecAware = mock(HttpExecutionAware.class);
         mockCacheEntry = mock(HttpCacheEntry.class);
         mockSchedulingStrategy = mock(SchedulingStrategy.class);
@@ -87,7 +87,7 @@ public class TestAsynchronousValidator {
 
         when(mockCacheEntry.hasVariants()).thenReturn(false);
 
-        impl.revalidateCacheEntry(mockClient, route, request, context, mockExecAware, mockCacheEntry);
+        impl.revalidateCacheEntry(mockClient, request, context, mockExecAware, mockCacheEntry);
 
         verify(mockCacheEntry).hasVariants();
         verify(mockSchedulingStrategy).schedule(isA(AsynchronousValidationRequest.class));
@@ -101,7 +101,7 @@ public class TestAsynchronousValidator {
 
         when(mockCacheEntry.hasVariants()).thenReturn(false);
 
-        impl.revalidateCacheEntry(mockClient, route, request, context, mockExecAware, mockCacheEntry);
+        impl.revalidateCacheEntry(mockClient, request, context, mockExecAware, mockCacheEntry);
 
         final ArgumentCaptor<AsynchronousValidationRequest> cap = ArgumentCaptor.forClass(AsynchronousValidationRequest.class);
         verify(mockCacheEntry).hasVariants();
@@ -121,7 +121,7 @@ public class TestAsynchronousValidator {
         when(mockCacheEntry.hasVariants()).thenReturn(false);
         doThrow(new RejectedExecutionException()).when(mockSchedulingStrategy).schedule(isA(AsynchronousValidationRequest.class));
 
-        impl.revalidateCacheEntry(mockClient, route, request, context, mockExecAware, mockCacheEntry);
+        impl.revalidateCacheEntry(mockClient, request, context, mockExecAware, mockCacheEntry);
 
         verify(mockCacheEntry).hasVariants();
 
@@ -135,8 +135,8 @@ public class TestAsynchronousValidator {
 
         when(mockCacheEntry.hasVariants()).thenReturn(false);
 
-        impl.revalidateCacheEntry(mockClient, route, request, context, mockExecAware, mockCacheEntry);
-        impl.revalidateCacheEntry(mockClient, route, request, context, mockExecAware, mockCacheEntry);
+        impl.revalidateCacheEntry(mockClient, request, context, mockExecAware, mockCacheEntry);
+        impl.revalidateCacheEntry(mockClient, request, context, mockExecAware, mockCacheEntry);
 
         verify(mockCacheEntry, times(2)).hasVariants();
         verify(mockSchedulingStrategy).schedule(isA(AsynchronousValidationRequest.class));
@@ -148,10 +148,10 @@ public class TestAsynchronousValidator {
     public void testVariantsBothRevalidated() {
         impl = new AsynchronousValidator(mockSchedulingStrategy);
 
-        final HttpRequest req1 = new HttpGet("/");
+        final ClassicHttpRequest req1 = new HttpGet("/");
         req1.addHeader(new BasicHeader("Accept-Encoding", "identity"));
 
-        final HttpRequest req2 = new HttpGet("/");
+        final ClassicHttpRequest req2 = new HttpGet("/");
         req2.addHeader(new BasicHeader("Accept-Encoding", "gzip"));
 
         final Header[] variantHeaders = new Header[] {
@@ -159,14 +159,15 @@ public class TestAsynchronousValidator {
         };
 
         when(mockCacheEntry.hasVariants()).thenReturn(true);
-        when(mockCacheEntry.getHeaders(HeaderConstants.VARY)).thenReturn(variantHeaders);
+        when(mockCacheEntry.headerIterator(HeaderConstants.VARY)).thenReturn(
+                new BasicHeaderIterator(variantHeaders, HeaderConstants.VARY));
         mockSchedulingStrategy.schedule(isA(AsynchronousValidationRequest.class));
 
-        impl.revalidateCacheEntry(mockClient, route, HttpRequestWrapper.wrap(req1, host), context, mockExecAware, mockCacheEntry);
-        impl.revalidateCacheEntry(mockClient, route, HttpRequestWrapper.wrap(req2, host), context, mockExecAware, mockCacheEntry);
+        impl.revalidateCacheEntry(mockClient, RoutedHttpRequest.adapt(req1, route), context, mockExecAware, mockCacheEntry);
+        impl.revalidateCacheEntry(mockClient, RoutedHttpRequest.adapt(req2, route), context, mockExecAware, mockCacheEntry);
 
         verify(mockCacheEntry, times(2)).hasVariants();
-        verify(mockCacheEntry, times(2)).getHeaders(HeaderConstants.VARY);
+        verify(mockCacheEntry, times(2)).headerIterator(HeaderConstants.VARY);
         verify(mockSchedulingStrategy, times(2)).schedule(isA(AsynchronousValidationRequest.class));
 
         Assert.assertEquals(2, impl.getScheduledIdentifiers().size());
@@ -183,9 +184,9 @@ public class TestAsynchronousValidator {
 
         when(mockCacheEntry.hasVariants()).thenReturn(false);
         when(mockClient.revalidateCacheEntry(
-                route, request, context, mockExecAware, mockCacheEntry)).thenReturn(null);
+                request, context, mockExecAware, mockCacheEntry)).thenReturn(null);
 
-        impl.revalidateCacheEntry(mockClient, route, request, context, mockExecAware, mockCacheEntry);
+        impl.revalidateCacheEntry(mockClient, request, context, mockExecAware, mockCacheEntry);
 
         try {
             // shut down backend executor and make sure all finishes properly, 1 second should be sufficient
@@ -195,7 +196,7 @@ public class TestAsynchronousValidator {
 
         } finally {
             verify(mockCacheEntry).hasVariants();
-            verify(mockClient).revalidateCacheEntry(route, request, context, mockExecAware, mockCacheEntry);
+            verify(mockClient).revalidateCacheEntry(request, context, mockExecAware, mockCacheEntry);
 
             Assert.assertEquals(0, impl.getScheduledIdentifiers().size());
         }

Modified: httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestBasicHttpCache.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestBasicHttpCache.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestBasicHttpCache.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestBasicHttpCache.java Tue Dec 27 19:48:07 2016
@@ -51,17 +51,16 @@ import org.apache.hc.client5.http.method
 import org.apache.hc.client5.http.methods.HttpPost;
 import org.apache.hc.client5.http.methods.HttpTrace;
 import org.apache.hc.client5.http.utils.DateUtils;
+import org.apache.hc.core5.http.ClassicHttpResponse;
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpEntity;
 import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.http.HttpRequest;
-import org.apache.hc.core5.http.HttpResponse;
 import org.apache.hc.core5.http.HttpStatus;
-import org.apache.hc.core5.http.HttpVersion;
-import org.apache.hc.core5.http.entity.BasicHttpEntity;
-import org.apache.hc.core5.http.entity.ByteArrayEntity;
+import org.apache.hc.core5.http.io.entity.BasicHttpEntity;
+import org.apache.hc.core5.http.io.entity.ByteArrayEntity;
+import org.apache.hc.core5.http.message.BasicClassicHttpResponse;
 import org.apache.hc.core5.http.message.BasicHeader;
-import org.apache.hc.core5.http.message.BasicHttpResponse;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -81,7 +80,7 @@ public class TestBasicHttpCache {
     public void testDoNotFlushCacheEntriesOnGet() throws Exception {
         final HttpHost host = new HttpHost("foo.example.com");
         final HttpRequest req = new HttpGet("/bar");
-        final String key = (new CacheKeyGenerator()).getURI(host, req);
+        final String key = (new CacheKeyGenerator()).generateKey(host, req);
         final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry();
 
         backing.map.put(key, entry);
@@ -95,7 +94,7 @@ public class TestBasicHttpCache {
     public void testDoNotFlushCacheEntriesOnHead() throws Exception {
         final HttpHost host = new HttpHost("foo.example.com");
         final HttpRequest req = new HttpHead("/bar");
-        final String key = (new CacheKeyGenerator()).getURI(host, req);
+        final String key = (new CacheKeyGenerator()).generateKey(host, req);
         final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry();
 
         backing.map.put(key, entry);
@@ -109,7 +108,7 @@ public class TestBasicHttpCache {
     public void testDoNotFlushCacheEntriesOnOptions() throws Exception {
         final HttpHost host = new HttpHost("foo.example.com");
         final HttpRequest req = new HttpOptions("/bar");
-        final String key = (new CacheKeyGenerator()).getURI(host, req);
+        final String key = (new CacheKeyGenerator()).generateKey(host, req);
         final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry();
 
         backing.map.put(key, entry);
@@ -123,7 +122,7 @@ public class TestBasicHttpCache {
     public void testDoNotFlushCacheEntriesOnTrace() throws Exception {
         final HttpHost host = new HttpHost("foo.example.com");
         final HttpRequest req = new HttpTrace("/bar");
-        final String key = (new CacheKeyGenerator()).getURI(host, req);
+        final String key = (new CacheKeyGenerator()).generateKey(host, req);
         final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry();
 
         backing.map.put(key, entry);
@@ -138,10 +137,10 @@ public class TestBasicHttpCache {
             throws Exception {
         final HttpHost host = new HttpHost("foo.example.com");
         final HttpRequest req = new HttpPost("/foo");
-        final HttpResponse resp = HttpTestUtils.make200Response();
+        final ClassicHttpResponse resp = HttpTestUtils.make200Response();
         resp.setHeader("Content-Location", "/bar");
         resp.setHeader(HeaderConstants.ETAG, "\"etag\"");
-        final String key = (new CacheKeyGenerator()).getURI(host, new HttpGet("/bar"));
+        final String key = (new CacheKeyGenerator()).generateKey(host, new HttpGet("/bar"));
 
         final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(new Header[] {
            new BasicHeader("Date", DateUtils.formatDate(new Date())),
@@ -160,9 +159,9 @@ public class TestBasicHttpCache {
             throws Exception {
         final HttpHost host = new HttpHost("foo.example.com");
         final HttpRequest req = new HttpGet("/foo");
-        final HttpResponse resp = HttpTestUtils.make200Response();
+        final ClassicHttpResponse resp = HttpTestUtils.make200Response();
         resp.setHeader("Content-Location", "/bar");
-        final String key = (new CacheKeyGenerator()).getURI(host, new HttpGet("/bar"));
+        final String key = (new CacheKeyGenerator()).generateKey(host, new HttpGet("/bar"));
 
         final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(new Header[] {
            new BasicHeader("Date", DateUtils.formatDate(new Date())),
@@ -180,7 +179,7 @@ public class TestBasicHttpCache {
     public void testCanFlushCacheEntriesAtUri() throws Exception {
         final HttpHost host = new HttpHost("foo.example.com");
         final HttpRequest req = new HttpDelete("/bar");
-        final String key = (new CacheKeyGenerator()).getURI(host, req);
+        final String key = (new CacheKeyGenerator()).generateKey(host, req);
         final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry();
 
         backing.map.put(key, entry);
@@ -193,7 +192,7 @@ public class TestBasicHttpCache {
     @Test
     public void testRecognizesComplete200Response()
         throws Exception {
-        final HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
+        final ClassicHttpResponse resp = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
         final byte[] bytes = HttpTestUtils.getRandomBytes(128);
         resp.setEntity(new ByteArrayEntity(bytes));
         resp.setHeader("Content-Length","128");
@@ -205,7 +204,7 @@ public class TestBasicHttpCache {
     @Test
     public void testRecognizesComplete206Response()
         throws Exception {
-        final HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_PARTIAL_CONTENT, "Partial Content");
+        final ClassicHttpResponse resp = new BasicClassicHttpResponse(HttpStatus.SC_PARTIAL_CONTENT, "Partial Content");
         final byte[] bytes = HttpTestUtils.getRandomBytes(128);
         final Resource resource = new HeapResource(bytes);
         resp.setEntity(new ByteArrayEntity(bytes));
@@ -218,7 +217,7 @@ public class TestBasicHttpCache {
     @Test
     public void testRecognizesIncomplete200Response()
         throws Exception {
-        final HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
+        final ClassicHttpResponse resp = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
         final byte[] bytes = HttpTestUtils.getRandomBytes(128);
         final Resource resource = new HeapResource(bytes);
         resp.setEntity(new ByteArrayEntity(bytes));
@@ -230,7 +229,7 @@ public class TestBasicHttpCache {
     @Test
     public void testIgnoresIncompleteNon200Or206Responses()
         throws Exception {
-        final HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_FORBIDDEN, "Forbidden");
+        final ClassicHttpResponse resp = new BasicClassicHttpResponse(HttpStatus.SC_FORBIDDEN, "Forbidden");
         final byte[] bytes = HttpTestUtils.getRandomBytes(128);
         final Resource resource = new HeapResource(bytes);
         resp.setEntity(new ByteArrayEntity(bytes));
@@ -242,7 +241,7 @@ public class TestBasicHttpCache {
     @Test
     public void testResponsesWithoutExplicitContentLengthAreComplete()
         throws Exception {
-        final HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
+        final ClassicHttpResponse resp = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
         final byte[] bytes = HttpTestUtils.getRandomBytes(128);
         final Resource resource = new HeapResource(bytes);
         resp.setEntity(new ByteArrayEntity(bytes));
@@ -253,7 +252,7 @@ public class TestBasicHttpCache {
     @Test
     public void testResponsesWithUnparseableContentLengthHeaderAreComplete()
         throws Exception {
-        final HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
+        final ClassicHttpResponse resp = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
         final byte[] bytes = HttpTestUtils.getRandomBytes(128);
         final Resource resource = new HeapResource(bytes);
         resp.setHeader("Content-Length","foo");
@@ -265,7 +264,7 @@ public class TestBasicHttpCache {
     @Test
     public void testNullResourcesAreComplete()
         throws Exception {
-        final HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
+        final ClassicHttpResponse resp = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
         resp.setHeader("Content-Length","256");
 
         assertFalse(impl.isIncompleteResponse(resp, null));
@@ -274,13 +273,13 @@ public class TestBasicHttpCache {
     @Test
     public void testIncompleteResponseErrorProvidesPlainTextErrorMessage()
         throws Exception {
-        final HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
+        final ClassicHttpResponse resp = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
         final byte[] bytes = HttpTestUtils.getRandomBytes(128);
         final Resource resource = new HeapResource(bytes);
         resp.setEntity(new ByteArrayEntity(bytes));
         resp.setHeader("Content-Length","256");
 
-        final HttpResponse result = impl.generateIncompleteResponseError(resp, resource);
+        final ClassicHttpResponse result = impl.generateIncompleteResponseError(resp, resource);
         final Header ctype = result.getFirstHeader("Content-Type");
         assertEquals("text/plain;charset=UTF-8", ctype.getValue());
     }
@@ -288,13 +287,13 @@ public class TestBasicHttpCache {
     @Test
     public void testIncompleteResponseErrorProvidesNonEmptyErrorMessage()
         throws Exception {
-        final HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
+        final ClassicHttpResponse resp = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
         final byte[] bytes = HttpTestUtils.getRandomBytes(128);
         final Resource resource = new HeapResource(bytes);
         resp.setEntity(new ByteArrayEntity(bytes));
         resp.setHeader("Content-Length","256");
 
-        final HttpResponse result = impl.generateIncompleteResponseError(resp, resource);
+        final ClassicHttpResponse result = impl.generateIncompleteResponseError(resp, resource);
         final int clen = Integer.parseInt(result.getFirstHeader("Content-Length").getValue());
         assertTrue(clen > 0);
         final HttpEntity body = result.getEntity();
@@ -336,7 +335,7 @@ public class TestBasicHttpCache {
         assertFalse(entry.hasVariants());
         final HttpHost host = new HttpHost("foo.example.com");
         final HttpRequest req = new HttpGet("http://foo.example.com/bar");
-        final String key = (new CacheKeyGenerator()).getURI(host, req);
+        final String key = (new CacheKeyGenerator()).generateKey(host, req);
 
         impl.storeInCache(host, req, entry);
         assertSame(entry, backing.map.get(key));
@@ -352,13 +351,13 @@ public class TestBasicHttpCache {
         final Date responseGenerated = new Date(now.getTime() - 2 * 1000L);
         final Date responseReceived = new Date(now.getTime() - 1 * 1000L);
 
-        final HttpResponse originResponse = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
+        final ClassicHttpResponse originResponse = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
         originResponse.setEntity(HttpTestUtils.makeBody(CacheConfig.DEFAULT_MAX_OBJECT_SIZE_BYTES + 1));
         originResponse.setHeader("Cache-Control","public, max-age=3600");
         originResponse.setHeader("Date", DateUtils.formatDate(responseGenerated));
         originResponse.setHeader("ETag", "\"etag\"");
 
-        final HttpResponse result = impl.cacheAndReturnResponse(host, request, originResponse, requestSent, responseReceived);
+        final ClassicHttpResponse result = impl.cacheAndReturnResponse(host, request, originResponse, requestSent, responseReceived);
         assertEquals(0, backing.map.size());
         assertTrue(HttpTestUtils.semanticallyTransparent(originResponse, result));
     }
@@ -374,15 +373,15 @@ public class TestBasicHttpCache {
         final Date responseGenerated = new Date(now.getTime() - 2 * 1000L);
         final Date responseReceived = new Date(now.getTime() - 1 * 1000L);
 
-        final HttpResponse originResponse = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
+        final ClassicHttpResponse originResponse = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
         originResponse.setEntity(HttpTestUtils.makeBody(CacheConfig.DEFAULT_MAX_OBJECT_SIZE_BYTES - 1));
         originResponse.setHeader("Cache-Control","public, max-age=3600");
         originResponse.setHeader("Date", DateUtils.formatDate(responseGenerated));
         originResponse.setHeader("ETag", "\"etag\"");
 
-        final HttpResponse result = impl.cacheAndReturnResponse(host, request, originResponse, requestSent, responseReceived);
+        final ClassicHttpResponse result = impl.cacheAndReturnResponse(host, request, originResponse, requestSent, responseReceived);
         assertEquals(1, backing.map.size());
-        assertTrue(backing.map.containsKey((new CacheKeyGenerator()).getURI(host, request)));
+        assertTrue(backing.map.containsKey((new CacheKeyGenerator()).generateKey(host, request)));
         assertTrue(HttpTestUtils.semanticallyTransparent(originResponse, result));
     }
 
@@ -401,7 +400,7 @@ public class TestBasicHttpCache {
         final HttpHost host = new HttpHost("foo.example.com");
         final HttpRequest request = new HttpGet("http://foo.example.com/bar");
 
-        final String key = (new CacheKeyGenerator()).getURI(host, request);
+        final String key = (new CacheKeyGenerator()).generateKey(host, request);
 
         backing.map.put(key,entry);
 
@@ -417,7 +416,7 @@ public class TestBasicHttpCache {
         final HttpRequest origRequest = new HttpGet("http://foo.example.com/bar");
         origRequest.setHeader("Accept-Encoding","gzip");
 
-        final HttpResponse origResponse = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
+        final ClassicHttpResponse origResponse = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
         origResponse.setEntity(HttpTestUtils.makeBody(128));
         origResponse.setHeader("Date", DateUtils.formatDate(new Date()));
         origResponse.setHeader("Cache-Control", "max-age=3600, public");
@@ -439,7 +438,7 @@ public class TestBasicHttpCache {
         final HttpRequest origRequest = new HttpGet("http://foo.example.com/bar");
         origRequest.setHeader("Accept-Encoding","gzip");
 
-        final HttpResponse origResponse = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
+        final ClassicHttpResponse origResponse = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
         origResponse.setEntity(HttpTestUtils.makeBody(128));
         origResponse.setHeader("Date", DateUtils.formatDate(new Date()));
         origResponse.setHeader("Cache-Control", "max-age=3600, public");
@@ -469,7 +468,7 @@ public class TestBasicHttpCache {
         final HttpRequest req1 = new HttpGet("http://foo.example.com/bar");
         req1.setHeader("Accept-Encoding", "gzip");
 
-        final HttpResponse resp1 = HttpTestUtils.make200Response();
+        final ClassicHttpResponse resp1 = HttpTestUtils.make200Response();
         resp1.setHeader("Date", DateUtils.formatDate(new Date()));
         resp1.setHeader("Cache-Control", "max-age=3600, public");
         resp1.setHeader("ETag", "\"etag1\"");
@@ -480,7 +479,7 @@ public class TestBasicHttpCache {
         final HttpRequest req2 = new HttpGet("http://foo.example.com/bar");
         req2.setHeader("Accept-Encoding", "identity");
 
-        final HttpResponse resp2 = HttpTestUtils.make200Response();
+        final ClassicHttpResponse resp2 = HttpTestUtils.make200Response();
         resp2.setHeader("Date", DateUtils.formatDate(new Date()));
         resp2.setHeader("Cache-Control", "max-age=3600, public");
         resp2.setHeader("ETag", "\"etag2\"");
@@ -508,7 +507,7 @@ public class TestBasicHttpCache {
         final Date responseGenerated = new Date(now.getTime() - 2 * 1000L);
         final Date responseReceived = new Date(now.getTime() - 1 * 1000L);
 
-        final HttpResponse originResponse = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
+        final ClassicHttpResponse originResponse = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
         final BasicHttpEntity entity = new BasicHttpEntity();
         final ConsumableInputStream inputStream = new ConsumableInputStream(new ByteArrayInputStream(HttpTestUtils.getRandomBytes(CacheConfig.DEFAULT_MAX_OBJECT_SIZE_BYTES - 1)));
         entity.setContent(inputStream);
@@ -517,7 +516,7 @@ public class TestBasicHttpCache {
         originResponse.setHeader("Date", DateUtils.formatDate(responseGenerated));
         originResponse.setHeader("ETag", "\"etag\"");
 
-        final HttpResponse result = impl.cacheAndReturnResponse(host, request, originResponse, requestSent, responseReceived);
+        final ClassicHttpResponse result = impl.cacheAndReturnResponse(host, request, originResponse, requestSent, responseReceived);
         IOUtils.consume(result.getEntity());
         assertTrue(inputStream.wasClosed());
     }
@@ -577,7 +576,7 @@ public class TestBasicHttpCache {
         final HttpRequest origRequest = new HttpGet("http://foo.example.com/bar");
         origRequest.setHeader("Accept-Encoding","gzip");
 
-        final HttpResponse origResponse = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_OK, "OK");
+        final ClassicHttpResponse origResponse = new BasicClassicHttpResponse(HttpStatus.SC_OK, "OK");
         origResponse.setEntity(HttpTestUtils.makeBody(128));
         origResponse.setHeader("Date", DateUtils.formatDate(new Date()));
         origResponse.setHeader("Cache-Control", "max-age=3600, public");
@@ -585,7 +584,7 @@ public class TestBasicHttpCache {
         origResponse.setHeader("Vary", "Accept-Encoding");
         origResponse.setHeader("Content-Encoding","gzip");
 
-        final HttpResponse response = impl.cacheAndReturnResponse(
+        final ClassicHttpResponse response = impl.cacheAndReturnResponse(
                 host, origRequest, origResponse, new Date(), new Date());
         final HttpEntity entity = response.getEntity();
         Assert.assertNotNull(entity);

Modified: httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheEntryUpdater.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheEntryUpdater.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheEntryUpdater.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheEntryUpdater.java Tue Dec 27 19:48:07 2016
@@ -38,7 +38,6 @@ import org.apache.hc.client5.http.utils.
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpResponse;
 import org.apache.hc.core5.http.HttpStatus;
-import org.apache.hc.core5.http.HttpVersion;
 import org.apache.hc.core5.http.message.BasicHeader;
 import org.apache.hc.core5.http.message.BasicHttpResponse;
 import org.junit.Before;
@@ -69,8 +68,7 @@ public class TestCacheEntryUpdater {
         eightSecondsAgo = new Date(now.getTime() - 8000L);
         tenSecondsAgo = new Date(now.getTime() - 10000L);
 
-        response = new BasicHttpResponse(HttpVersion.HTTP_1_1,
-                HttpStatus.SC_NOT_MODIFIED, "Not Modified");
+        response = new BasicHttpResponse(HttpStatus.SC_NOT_MODIFIED, "Not Modified");
 
         impl = new CacheEntryUpdater();
     }
@@ -227,8 +225,7 @@ public class TestCacheEntryUpdater {
     @Test
     public void cannotUpdateFromANon304OriginResponse() throws Exception {
         entry = HttpTestUtils.makeCacheEntry();
-        response = new BasicHttpResponse(HttpVersion.HTTP_1_1,
-                HttpStatus.SC_OK, "OK");
+        response = new BasicHttpResponse(HttpStatus.SC_OK, "OK");
         try {
             impl.updateCacheEntry("A", entry, new Date(), new Date(),
                     response);

Modified: httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheInvalidator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheInvalidator.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheInvalidator.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheInvalidator.java Tue Dec 27 19:48:07 2016
@@ -32,6 +32,7 @@ import static org.mockito.Mockito.verify
 import static org.mockito.Mockito.when;
 
 import java.io.IOException;
+import java.net.URL;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
@@ -39,16 +40,15 @@ import java.util.Map;
 import org.apache.hc.client5.http.cache.HttpCacheEntry;
 import org.apache.hc.client5.http.cache.HttpCacheStorage;
 import org.apache.hc.client5.http.utils.DateUtils;
+import org.apache.hc.core5.http.ClassicHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.HttpRequest;
-import org.apache.hc.core5.http.HttpResponse;
 import org.apache.hc.core5.http.HttpStatus;
-import org.apache.hc.core5.http.HttpVersion;
 import org.apache.hc.core5.http.ProtocolVersion;
+import org.apache.hc.core5.http.message.BasicClassicHttpRequest;
+import org.apache.hc.core5.http.message.BasicClassicHttpResponse;
 import org.apache.hc.core5.http.message.BasicHeader;
-import org.apache.hc.core5.http.message.BasicHttpRequest;
-import org.apache.hc.core5.http.message.BasicHttpResponse;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -61,8 +61,8 @@ public class TestCacheInvalidator {
     private HttpHost host;
     private CacheKeyGenerator cacheKeyGenerator;
     private HttpCacheEntry mockEntry;
-    private HttpRequest request;
-    private HttpResponse response;
+    private ClassicHttpRequest request;
+    private ClassicHttpResponse response;
 
     private Date now;
     private Date tenSecondsAgo;
@@ -85,7 +85,7 @@ public class TestCacheInvalidator {
     // Tests
     @Test
     public void testInvalidatesRequestsThatArentGETorHEAD() throws Exception {
-        request = new BasicHttpRequest("POST","/path", HTTP_1_1);
+        request = new BasicClassicHttpRequest("POST","/path");
         final String theUri = "http://foo.example.com:80/path";
         final Map<String,String> variantMap = new HashMap<>();
         cacheEntryHasVariantMap(variantMap);
@@ -101,7 +101,7 @@ public class TestCacheInvalidator {
 
     @Test
     public void testInvalidatesUrisInContentLocationHeadersOnPUTs() throws Exception {
-        final HttpRequest putRequest = new BasicHttpRequest("PUT","/",HTTP_1_1);
+        final ClassicHttpRequest putRequest = new BasicClassicHttpRequest("PUT","/");
         putRequest.setEntity(HttpTestUtils.makeBody(128));
         putRequest.setHeader("Content-Length","128");
 
@@ -123,7 +123,7 @@ public class TestCacheInvalidator {
 
     @Test
     public void testInvalidatesUrisInLocationHeadersOnPUTs() throws Exception {
-        final HttpRequest putRequest = new BasicHttpRequest("PUT","/",HTTP_1_1);
+        final ClassicHttpRequest putRequest = new BasicClassicHttpRequest("PUT","/");
         putRequest.setEntity(HttpTestUtils.makeBody(128));
         putRequest.setHeader("Content-Length","128");
 
@@ -140,12 +140,12 @@ public class TestCacheInvalidator {
         verify(mockEntry).getVariantMap();
         verify(mockStorage).getEntry(theUri);
         verify(mockStorage).removeEntry(theUri);
-        verify(mockStorage).removeEntry(cacheKeyGenerator.canonicalizeUri(contentLocation));
+        verify(mockStorage).removeEntry(cacheKeyGenerator.generateKey(new URL(contentLocation)));
     }
 
     @Test
     public void testInvalidatesRelativeUrisInContentLocationHeadersOnPUTs() throws Exception {
-        final HttpRequest putRequest = new BasicHttpRequest("PUT","/",HTTP_1_1);
+        final ClassicHttpRequest putRequest = new BasicClassicHttpRequest("PUT","/");
         putRequest.setEntity(HttpTestUtils.makeBody(128));
         putRequest.setHeader("Content-Length","128");
 
@@ -167,7 +167,7 @@ public class TestCacheInvalidator {
 
     @Test
     public void testDoesNotInvalidateUrisInContentLocationHeadersOnPUTsToDifferentHosts() throws Exception {
-        final HttpRequest putRequest = new BasicHttpRequest("PUT","/",HTTP_1_1);
+        final ClassicHttpRequest putRequest = new BasicClassicHttpRequest("PUT","/");
         putRequest.setEntity(HttpTestUtils.makeBody(128));
         putRequest.setHeader("Content-Length","128");
 
@@ -188,7 +188,7 @@ public class TestCacheInvalidator {
 
     @Test
     public void testDoesNotInvalidateGETRequest() throws Exception {
-        request = new BasicHttpRequest("GET","/",HTTP_1_1);
+        request = new BasicClassicHttpRequest("GET","/");
         impl.flushInvalidatedCacheEntries(host, request);
 
         verify(mockStorage).getEntry("http://foo.example.com:80/");
@@ -197,7 +197,7 @@ public class TestCacheInvalidator {
 
     @Test
     public void testDoesNotInvalidateHEADRequest() throws Exception {
-        request = new BasicHttpRequest("HEAD","/",HTTP_1_1);
+        request = new BasicClassicHttpRequest("HEAD","/");
         impl.flushInvalidatedCacheEntries(host, request);
 
         verify(mockStorage).getEntry("http://foo.example.com:80/");
@@ -208,7 +208,7 @@ public class TestCacheInvalidator {
     public void testInvalidatesHEADCacheEntryIfSubsequentGETRequestsAreMadeToTheSameURI() throws Exception {
         impl = new CacheInvalidator(cacheKeyGenerator, mockStorage);
         final String theURI = "http://foo.example.com:80/";
-        request = new BasicHttpRequest("GET", theURI,HTTP_1_1);
+        request = new BasicClassicHttpRequest("GET", theURI);
 
         cacheEntryisForMethod("HEAD");
         cacheEntryHasVariantMap(new HashMap<String, String>());
@@ -226,7 +226,7 @@ public class TestCacheInvalidator {
     public void testInvalidatesVariantHEADCacheEntriesIfSubsequentGETRequestsAreMadeToTheSameURI() throws Exception {
         impl = new CacheInvalidator(cacheKeyGenerator, mockStorage);
         final String theURI = "http://foo.example.com:80/";
-        request = new BasicHttpRequest("GET", theURI,HTTP_1_1);
+        request = new BasicClassicHttpRequest("GET", theURI);
         final String theVariantKey = "{Accept-Encoding=gzip%2Cdeflate&User-Agent=Apache-HttpClient}";
         final String theVariantURI = "{Accept-Encoding=gzip%2Cdeflate&User-Agent=Apache-HttpClient}http://foo.example.com:80/";
         final Map<String, String> variants = HttpTestUtils.makeDefaultVariantMap(theVariantKey, theVariantURI);
@@ -247,7 +247,7 @@ public class TestCacheInvalidator {
     @Test
     public void testDoesNotInvalidateHEADCacheEntry() throws Exception {
         final String theURI = "http://foo.example.com:80/";
-        request = new BasicHttpRequest("HEAD", theURI,HTTP_1_1);
+        request = new BasicClassicHttpRequest("HEAD", theURI);
 
         cacheReturnsEntryForUri(theURI);
 
@@ -261,7 +261,7 @@ public class TestCacheInvalidator {
     public void testDoesNotInvalidateHEADCacheEntryIfSubsequentHEADRequestsAreMadeToTheSameURI() throws Exception {
         impl = new CacheInvalidator(cacheKeyGenerator, mockStorage);
         final String theURI = "http://foo.example.com:80/";
-        request = new BasicHttpRequest("HEAD", theURI,HTTP_1_1);
+        request = new BasicClassicHttpRequest("HEAD", theURI);
 
         cacheReturnsEntryForUri(theURI);
 
@@ -275,7 +275,7 @@ public class TestCacheInvalidator {
     public void testDoesNotInvalidateGETCacheEntryIfSubsequentGETRequestsAreMadeToTheSameURI() throws Exception {
         impl = new CacheInvalidator(cacheKeyGenerator, mockStorage);
         final String theURI = "http://foo.example.com:80/";
-        request = new BasicHttpRequest("GET", theURI,HTTP_1_1);
+        request = new BasicClassicHttpRequest("GET", theURI);
 
         cacheEntryisForMethod("GET");
         cacheReturnsEntryForUri(theURI);
@@ -289,7 +289,7 @@ public class TestCacheInvalidator {
 
     @Test
     public void testDoesNotInvalidateRequestsWithClientCacheControlHeaders() throws Exception {
-        request = new BasicHttpRequest("GET","/",HTTP_1_1);
+        request = new BasicClassicHttpRequest("GET","/");
         request.setHeader("Cache-Control","no-cache");
 
         impl.flushInvalidatedCacheEntries(host, request);
@@ -300,7 +300,7 @@ public class TestCacheInvalidator {
 
     @Test
     public void testDoesNotInvalidateRequestsWithClientPragmaHeaders() throws Exception {
-        request = new BasicHttpRequest("GET","/",HTTP_1_1);
+        request = new BasicClassicHttpRequest("GET","/");
         request.setHeader("Pragma","no-cache");
 
         impl.flushInvalidatedCacheEntries(host, request);
@@ -311,7 +311,7 @@ public class TestCacheInvalidator {
 
     @Test
     public void testVariantURIsAreFlushedAlso() throws Exception {
-        request = new BasicHttpRequest("POST","/",HTTP_1_1);
+        request = new BasicClassicHttpRequest("POST","/");
         final String theUri = "http://foo.example.com:80/";
         final String variantUri = "theVariantURI";
         final Map<String,String> mapOfURIs = HttpTestUtils.makeDefaultVariantMap(variantUri, variantUri);
@@ -329,7 +329,7 @@ public class TestCacheInvalidator {
 
     @Test
     public void testCacheFlushException() throws Exception {
-        request = new BasicHttpRequest("POST","/",HTTP_1_1);
+        request = new BasicClassicHttpRequest("POST","/");
         final String theURI = "http://foo.example.com:80/";
 
         cacheReturnsExceptionForUri(theURI);
@@ -372,7 +372,7 @@ public class TestCacheInvalidator {
     @Test
     public void flushesEntryIfFresherAndSpecifiedByLocation()
             throws Exception {
-        response.setStatusCode(201);
+        response.setCode(201);
         response.setHeader("ETag","\"new-etag\"");
         response.setHeader("Date", DateUtils.formatDate(now));
         final String theURI = "http://foo.example.com:80/bar";
@@ -394,7 +394,7 @@ public class TestCacheInvalidator {
     @Test
     public void doesNotFlushEntryForUnsuccessfulResponse()
             throws Exception {
-        response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_BAD_REQUEST, "Bad Request");
+        response = new BasicClassicHttpResponse(HttpStatus.SC_BAD_REQUEST, "Bad Request");
         response.setHeader("ETag","\"new-etag\"");
         response.setHeader("Date", DateUtils.formatDate(now));
         final String theURI = "http://foo.example.com:80/bar";

Modified: httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheKeyGenerator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheKeyGenerator.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheKeyGenerator.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheKeyGenerator.java Tue Dec 27 19:48:07 2016
@@ -35,8 +35,8 @@ import org.apache.hc.client5.http.method
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.http.HttpRequest;
-import org.apache.hc.core5.http.HttpVersion;
 import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.message.BasicHeaderIterator;
 import org.apache.hc.core5.http.message.BasicHttpRequest;
 import org.junit.Assert;
 import org.junit.Before;
@@ -66,50 +66,50 @@ public class TestCacheKeyGenerator {
     public void testExtractsUriFromAbsoluteUriInRequest() {
         final HttpHost host = new HttpHost("bar.example.com");
         final HttpRequest req = new HttpGet("http://foo.example.com/");
-        Assert.assertEquals("http://foo.example.com:80/", extractor.getURI(host, req));
+        Assert.assertEquals("http://foo.example.com:80/", extractor.generateKey(host, req));
     }
 
     @Test
     public void testGetURIWithDefaultPortAndScheme() {
-        Assert.assertEquals("http://www.comcast.net:80/", extractor.getURI(new HttpHost(
+        Assert.assertEquals("http://www.comcast.net:80/", extractor.generateKey(new HttpHost(
                 "www.comcast.net"), REQUEST_ROOT));
 
-        Assert.assertEquals("http://www.fancast.com:80/full_episodes", extractor.getURI(new HttpHost(
+        Assert.assertEquals("http://www.fancast.com:80/full_episodes", extractor.generateKey(new HttpHost(
                 "www.fancast.com"), REQUEST_FULL_EPISODES));
     }
 
     @Test
     public void testGetURIWithDifferentScheme() {
-        Assert.assertEquals("https://www.comcast.net:443/", extractor.getURI(new HttpHost(
+        Assert.assertEquals("https://www.comcast.net:443/", extractor.generateKey(new HttpHost(
                 "www.comcast.net", -1, "https"), REQUEST_ROOT));
 
-        Assert.assertEquals("myhttp://www.fancast.com/full_episodes", extractor.getURI(
+        Assert.assertEquals("myhttp://www.fancast.com/full_episodes", extractor.generateKey(
                 new HttpHost("www.fancast.com", -1, "myhttp"), REQUEST_FULL_EPISODES));
     }
 
     @Test
     public void testGetURIWithDifferentPort() {
-        Assert.assertEquals("http://www.comcast.net:8080/", extractor.getURI(new HttpHost(
+        Assert.assertEquals("http://www.comcast.net:8080/", extractor.generateKey(new HttpHost(
                 "www.comcast.net", 8080), REQUEST_ROOT));
 
-        Assert.assertEquals("http://www.fancast.com:9999/full_episodes", extractor.getURI(
+        Assert.assertEquals("http://www.fancast.com:9999/full_episodes", extractor.generateKey(
                 new HttpHost("www.fancast.com", 9999), REQUEST_FULL_EPISODES));
     }
 
     @Test
     public void testGetURIWithDifferentPortAndScheme() {
-        Assert.assertEquals("https://www.comcast.net:8080/", extractor.getURI(new HttpHost(
+        Assert.assertEquals("https://www.comcast.net:8080/", extractor.generateKey(new HttpHost(
                 "www.comcast.net", 8080, "https"), REQUEST_ROOT));
 
-        Assert.assertEquals("myhttp://www.fancast.com:9999/full_episodes", extractor.getURI(
+        Assert.assertEquals("myhttp://www.fancast.com:9999/full_episodes", extractor.generateKey(
                 new HttpHost("www.fancast.com", 9999, "myhttp"), REQUEST_FULL_EPISODES));
     }
 
     @Test
     public void testGetURIWithQueryParameters() {
-        Assert.assertEquals("http://www.comcast.net:80/?foo=bar", extractor.getURI(new HttpHost(
+        Assert.assertEquals("http://www.comcast.net:80/?foo=bar", extractor.generateKey(new HttpHost(
                 "www.comcast.net", -1, "http"), new BasicHttpRequest("GET", "/?foo=bar")));
-        Assert.assertEquals("http://www.fancast.com:80/full_episodes?foo=bar", extractor.getURI(
+        Assert.assertEquals("http://www.fancast.com:80/full_episodes?foo=bar", extractor.generateKey(
                 new HttpHost("www.fancast.com", -1, "http"), new BasicHttpRequest("GET",
                         "/full_episodes?foo=bar")));
     }
@@ -120,14 +120,14 @@ public class TestCacheKeyGenerator {
         when(mockEntry.hasVariants()).thenReturn(false);
         extractor = new CacheKeyGenerator() {
             @Override
-            public String getURI(final HttpHost h, final HttpRequest req) {
+            public String generateKey(final HttpHost h, final HttpRequest req) {
                 Assert.assertSame(defaultHost, h);
                 Assert.assertSame(mockRequest, req);
                 return theURI;
             }
         };
 
-        final String result = extractor.getVariantURI(defaultHost, mockRequest, mockEntry);
+        final String result = extractor.generateVariantURI(defaultHost, mockRequest, mockEntry);
         verify(mockEntry).hasVariants();
         Assert.assertSame(theURI, result);
     }
@@ -140,21 +140,20 @@ public class TestCacheKeyGenerator {
 
         extractor = new CacheKeyGenerator() {
             @Override
-            public String getURI(final HttpHost h, final HttpRequest req) {
+            public String generateKey(final HttpHost h, final HttpRequest req) {
                 Assert.assertSame(defaultHost, h);
                 Assert.assertSame(mockRequest, req);
                 return theURI;
             }
         };
         when(mockEntry.hasVariants()).thenReturn(true);
-        when(mockEntry.getHeaders("Vary")).thenReturn(varyHeaders);
-        when(mockRequest.getHeaders("Accept-Encoding")).thenReturn(
-                encHeaders);
+        when(mockEntry.headerIterator("Vary")).thenReturn(new BasicHeaderIterator(varyHeaders, "Vary"));
+        when(mockRequest.getHeaders("Accept-Encoding")).thenReturn(encHeaders);
 
-        final String result = extractor.getVariantURI(defaultHost, mockRequest, mockEntry);
+        final String result = extractor.generateVariantURI(defaultHost, mockRequest, mockEntry);
 
         verify(mockEntry).hasVariants();
-        verify(mockEntry).getHeaders("Vary");
+        verify(mockEntry).headerIterator("Vary");
         verify(mockRequest).getHeaders("Accept-Encoding");
         Assert.assertEquals("{Accept-Encoding=gzip}" + theURI, result);
     }
@@ -166,21 +165,21 @@ public class TestCacheKeyGenerator {
         final Header[] varyHeaders = { new BasicHeader("Vary", "Accept-Encoding") };
         extractor = new CacheKeyGenerator() {
             @Override
-            public String getURI(final HttpHost h, final HttpRequest req) {
+            public String generateKey(final HttpHost h, final HttpRequest req) {
                 Assert.assertSame(defaultHost, h);
                 Assert.assertSame(mockRequest, req);
                 return theURI;
             }
         };
         when(mockEntry.hasVariants()).thenReturn(true);
-        when(mockEntry.getHeaders("Vary")).thenReturn(varyHeaders);
+        when(mockEntry.headerIterator("Vary")).thenReturn(new BasicHeaderIterator(varyHeaders, "Vary"));
         when(mockRequest.getHeaders("Accept-Encoding"))
                 .thenReturn(noHeaders);
 
-        final String result = extractor.getVariantURI(defaultHost, mockRequest, mockEntry);
+        final String result = extractor.generateVariantURI(defaultHost, mockRequest, mockEntry);
 
         verify(mockEntry).hasVariants();
-        verify(mockEntry).getHeaders("Vary");
+        verify(mockEntry).headerIterator("Vary");
         verify(mockRequest).getHeaders("Accept-Encoding");
         Assert.assertEquals("{Accept-Encoding=}" + theURI, result);
     }
@@ -193,22 +192,21 @@ public class TestCacheKeyGenerator {
         final Header[] uaHeaders = { new BasicHeader("User-Agent", "browser") };
         extractor = new CacheKeyGenerator() {
             @Override
-            public String getURI(final HttpHost h, final HttpRequest req) {
+            public String generateKey(final HttpHost h, final HttpRequest req) {
                 Assert.assertSame(defaultHost, h);
                 Assert.assertSame(mockRequest, req);
                 return theURI;
             }
         };
         when(mockEntry.hasVariants()).thenReturn(true);
-        when(mockEntry.getHeaders("Vary")).thenReturn(varyHeaders);
-        when(mockRequest.getHeaders("Accept-Encoding")).thenReturn(
-                encHeaders);
+        when(mockEntry.headerIterator("Vary")).thenReturn(new BasicHeaderIterator(varyHeaders, "Vary"));
+        when(mockRequest.getHeaders("Accept-Encoding")).thenReturn(encHeaders);
         when(mockRequest.getHeaders("User-Agent")).thenReturn(uaHeaders);
 
-        final String result = extractor.getVariantURI(defaultHost, mockRequest, mockEntry);
+        final String result = extractor.generateVariantURI(defaultHost, mockRequest, mockEntry);
 
         verify(mockEntry).hasVariants();
-        verify(mockEntry).getHeaders("Vary");
+        verify(mockEntry).headerIterator("Vary");
         verify(mockRequest).getHeaders("Accept-Encoding");
         verify(mockRequest).getHeaders("User-Agent");
         Assert.assertEquals("{Accept-Encoding=gzip&User-Agent=browser}" + theURI, result);
@@ -223,21 +221,21 @@ public class TestCacheKeyGenerator {
         final Header[] uaHeaders = { new BasicHeader("User-Agent", "browser") };
         extractor = new CacheKeyGenerator() {
             @Override
-            public String getURI(final HttpHost h, final HttpRequest req) {
+            public String generateKey(final HttpHost h, final HttpRequest req) {
                 Assert.assertSame(defaultHost, h);
                 Assert.assertSame(mockRequest, req);
                 return theURI;
             }
         };
         when(mockEntry.hasVariants()).thenReturn(true);
-        when(mockEntry.getHeaders("Vary")).thenReturn(varyHeaders);
+        when(mockEntry.headerIterator("Vary")).thenReturn(new BasicHeaderIterator(varyHeaders, "Vary"));
         when(mockRequest.getHeaders("Accept-Encoding")).thenReturn(encHeaders);
         when(mockRequest.getHeaders("User-Agent")).thenReturn(uaHeaders);
 
-        final String result = extractor.getVariantURI(defaultHost, mockRequest, mockEntry);
+        final String result = extractor.generateVariantURI(defaultHost, mockRequest, mockEntry);
 
         verify(mockEntry).hasVariants();
-        verify(mockEntry).getHeaders("Vary");
+        verify(mockEntry).headerIterator("Vary");
         verify(mockRequest).getHeaders("Accept-Encoding");
         verify(mockRequest).getHeaders("User-Agent");
         Assert.assertEquals("{Accept-Encoding=gzip&User-Agent=browser}" + theURI, result);
@@ -252,26 +250,24 @@ public class TestCacheKeyGenerator {
         final Header[] uaHeaders = { new BasicHeader("User-Agent", "browser") };
         extractor = new CacheKeyGenerator() {
             @Override
-            public String getURI(final HttpHost h, final HttpRequest req) {
+            public String generateKey(final HttpHost h, final HttpRequest req) {
                 Assert.assertSame(defaultHost, h);
                 Assert.assertSame(mockRequest, req);
                 return theURI;
             }
         };
         when(mockEntry.hasVariants()).thenReturn(true);
-        when(mockEntry.getHeaders("Vary")).thenReturn(varyHeaders);
+        when(mockEntry.headerIterator("Vary")).thenReturn(new BasicHeaderIterator(varyHeaders, "Vary"));
         when(mockRequest.getHeaders("Accept-Encoding")).thenReturn(encHeaders);
         when(mockRequest.getHeaders("User-Agent")).thenReturn(uaHeaders);
 
-        final String result = extractor.getVariantURI(defaultHost, mockRequest, mockEntry);
+        final String result = extractor.generateVariantURI(defaultHost, mockRequest, mockEntry);
 
         verify(mockEntry).hasVariants();
-        verify(mockEntry).getHeaders("Vary");
+        verify(mockEntry).headerIterator("Vary");
         verify(mockRequest).getHeaders("Accept-Encoding");
         verify(mockRequest).getHeaders("User-Agent");
-        Assert
-                .assertEquals("{Accept-Encoding=gzip%2C+deflate&User-Agent=browser}" + theURI,
-                        result);
+        Assert.assertEquals("{Accept-Encoding=gzip%2C+deflate&User-Agent=browser}" + theURI, result);
     }
 
     /*
@@ -292,17 +288,17 @@ public class TestCacheKeyGenerator {
     public void testEmptyPortEquivalentToDefaultPortForHttp() {
         final HttpHost host1 = new HttpHost("foo.example.com:");
         final HttpHost host2 = new HttpHost("foo.example.com:80");
-        final HttpRequest req = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
-        Assert.assertEquals(extractor.getURI(host1, req), extractor.getURI(host2, req));
+        final HttpRequest req = new BasicHttpRequest("GET", "/");
+        Assert.assertEquals(extractor.generateKey(host1, req), extractor.generateKey(host2, req));
     }
 
     @Test
     public void testEmptyPortEquivalentToDefaultPortForHttps() {
         final HttpHost host1 = new HttpHost("foo.example.com", -1, "https");
         final HttpHost host2 = new HttpHost("foo.example.com", 443, "https");
-        final HttpRequest req = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
-        final String uri1 = extractor.getURI(host1, req);
-        final String uri2 = extractor.getURI(host2, req);
+        final HttpRequest req = new BasicHttpRequest("GET", "/");
+        final String uri1 = extractor.generateKey(host1, req);
+        final String uri2 = extractor.generateKey(host2, req);
         Assert.assertEquals(uri1, uri2);
     }
 
@@ -311,8 +307,8 @@ public class TestCacheKeyGenerator {
         final HttpHost host = new HttpHost("foo.example.com", -1, "https");
         final HttpGet get1 = new HttpGet("https://bar.example.com:/");
         final HttpGet get2 = new HttpGet("https://bar.example.com:443/");
-        final String uri1 = extractor.getURI(host, get1);
-        final String uri2 = extractor.getURI(host, get2);
+        final String uri1 = extractor.generateKey(host, get1);
+        final String uri2 = extractor.generateKey(host, get2);
         Assert.assertEquals(uri1, uri2);
     }
 
@@ -321,8 +317,8 @@ public class TestCacheKeyGenerator {
         final HttpHost host = new HttpHost("foo.example.com", -1, "https");
         final HttpGet get1 = new HttpGet("https://bar.example.com/");
         final HttpGet get2 = new HttpGet("https://bar.example.com:443/");
-        final String uri1 = extractor.getURI(host, get1);
-        final String uri2 = extractor.getURI(host, get2);
+        final String uri1 = extractor.generateKey(host, get1);
+        final String uri2 = extractor.generateKey(host, get2);
         Assert.assertEquals(uri1, uri2);
     }
 
@@ -330,95 +326,95 @@ public class TestCacheKeyGenerator {
     public void testNotProvidedPortEquivalentToDefaultPortForHttp() {
         final HttpHost host1 = new HttpHost("foo.example.com");
         final HttpHost host2 = new HttpHost("foo.example.com:80");
-        final HttpRequest req = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
-        Assert.assertEquals(extractor.getURI(host1, req), extractor.getURI(host2, req));
+        final HttpRequest req = new BasicHttpRequest("GET", "/");
+        Assert.assertEquals(extractor.generateKey(host1, req), extractor.generateKey(host2, req));
     }
 
     @Test
     public void testHostNameComparisonsAreCaseInsensitive() {
         final HttpHost host1 = new HttpHost("foo.example.com");
         final HttpHost host2 = new HttpHost("FOO.EXAMPLE.COM");
-        final HttpRequest req = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
-        Assert.assertEquals(extractor.getURI(host1, req), extractor.getURI(host2, req));
+        final HttpRequest req = new BasicHttpRequest("GET", "/");
+        Assert.assertEquals(extractor.generateKey(host1, req), extractor.generateKey(host2, req));
     }
 
     @Test
     public void testSchemeNameComparisonsAreCaseInsensitive() {
         final HttpHost host1 = new HttpHost("foo.example.com", -1, "http");
         final HttpHost host2 = new HttpHost("foo.example.com", -1, "HTTP");
-        final HttpRequest req = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
-        Assert.assertEquals(extractor.getURI(host1, req), extractor.getURI(host2, req));
+        final HttpRequest req = new BasicHttpRequest("GET", "/");
+        Assert.assertEquals(extractor.generateKey(host1, req), extractor.generateKey(host2, req));
     }
 
     @Test
     public void testEmptyAbsPathIsEquivalentToSlash() {
         final HttpHost host = new HttpHost("foo.example.com");
-        final HttpRequest req1 = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
+        final HttpRequest req1 = new BasicHttpRequest("GET", "/");
         final HttpRequest req2 = new HttpGet("http://foo.example.com");
-        Assert.assertEquals(extractor.getURI(host, req1), extractor.getURI(host, req2));
+        Assert.assertEquals(extractor.generateKey(host, req1), extractor.generateKey(host, req2));
     }
 
     @Test
     public void testExtraDotSegmentsAreIgnored() {
         final HttpHost host = new HttpHost("foo.example.com");
-        final HttpRequest req1 = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
+        final HttpRequest req1 = new BasicHttpRequest("GET", "/");
         final HttpRequest req2 = new HttpGet("http://foo.example.com/./");
-        Assert.assertEquals(extractor.getURI(host, req1), extractor.getURI(host, req2));
+        Assert.assertEquals(extractor.generateKey(host, req1), extractor.generateKey(host, req2));
     }
 
     @Test
     public void testExtraDotDotSegmentsAreIgnored() {
         final HttpHost host = new HttpHost("foo.example.com");
-        final HttpRequest req1 = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_1);
+        final HttpRequest req1 = new BasicHttpRequest("GET", "/");
         final HttpRequest req2 = new HttpGet("http://foo.example.com/.././../");
-        Assert.assertEquals(extractor.getURI(host, req1), extractor.getURI(host, req2));
+        Assert.assertEquals(extractor.generateKey(host, req1), extractor.generateKey(host, req2));
     }
 
     @Test
     public void testIntermidateDotDotSegementsAreEquivalent() {
         final HttpHost host = new HttpHost("foo.example.com");
-        final HttpRequest req1 = new BasicHttpRequest("GET", "/home.html", HttpVersion.HTTP_1_1);
-        final HttpRequest req2 = new BasicHttpRequest("GET", "/%7Esmith/../home.html", HttpVersion.HTTP_1_1);
-        Assert.assertEquals(extractor.getURI(host, req1), extractor.getURI(host, req2));
+        final HttpRequest req1 = new BasicHttpRequest("GET", "/home.html");
+        final HttpRequest req2 = new BasicHttpRequest("GET", "/%7Esmith/../home.html");
+        Assert.assertEquals(extractor.generateKey(host, req1), extractor.generateKey(host, req2));
     }
 
     @Test
     public void testIntermidateEncodedDotDotSegementsAreEquivalent() {
         final HttpHost host = new HttpHost("foo.example.com");
-        final HttpRequest req1 = new BasicHttpRequest("GET", "/home.html", HttpVersion.HTTP_1_1);
-        final HttpRequest req2 = new BasicHttpRequest("GET", "/%7Esmith%2F../home.html", HttpVersion.HTTP_1_1);
-        Assert.assertEquals(extractor.getURI(host, req1), extractor.getURI(host, req2));
+        final HttpRequest req1 = new BasicHttpRequest("GET", "/home.html");
+        final HttpRequest req2 = new BasicHttpRequest("GET", "/%7Esmith%2F../home.html");
+        Assert.assertEquals(extractor.generateKey(host, req1), extractor.generateKey(host, req2));
     }
 
     @Test
     public void testIntermidateDotSegementsAreEquivalent() {
         final HttpHost host = new HttpHost("foo.example.com");
-        final HttpRequest req1 = new BasicHttpRequest("GET", "/~smith/home.html", HttpVersion.HTTP_1_1);
-        final HttpRequest req2 = new BasicHttpRequest("GET", "/%7Esmith/./home.html", HttpVersion.HTTP_1_1);
-        Assert.assertEquals(extractor.getURI(host, req1), extractor.getURI(host, req2));
+        final HttpRequest req1 = new BasicHttpRequest("GET", "/~smith/home.html");
+        final HttpRequest req2 = new BasicHttpRequest("GET", "/%7Esmith/./home.html");
+        Assert.assertEquals(extractor.generateKey(host, req1), extractor.generateKey(host, req2));
     }
 
     @Test
     public void testEquivalentPathEncodingsAreEquivalent() {
         final HttpHost host = new HttpHost("foo.example.com");
-        final HttpRequest req1 = new BasicHttpRequest("GET", "/~smith/home.html", HttpVersion.HTTP_1_1);
-        final HttpRequest req2 = new BasicHttpRequest("GET", "/%7Esmith/home.html", HttpVersion.HTTP_1_1);
-        Assert.assertEquals(extractor.getURI(host, req1), extractor.getURI(host, req2));
+        final HttpRequest req1 = new BasicHttpRequest("GET", "/~smith/home.html");
+        final HttpRequest req2 = new BasicHttpRequest("GET", "/%7Esmith/home.html");
+        Assert.assertEquals(extractor.generateKey(host, req1), extractor.generateKey(host, req2));
     }
 
     @Test
     public void testEquivalentExtraPathEncodingsAreEquivalent() {
         final HttpHost host = new HttpHost("foo.example.com");
-        final HttpRequest req1 = new BasicHttpRequest("GET", "/~smith/home.html", HttpVersion.HTTP_1_1);
-        final HttpRequest req2 = new BasicHttpRequest("GET", "/%7Esmith%2Fhome.html", HttpVersion.HTTP_1_1);
-        Assert.assertEquals(extractor.getURI(host, req1), extractor.getURI(host, req2));
+        final HttpRequest req1 = new BasicHttpRequest("GET", "/~smith/home.html");
+        final HttpRequest req2 = new BasicHttpRequest("GET", "/%7Esmith%2Fhome.html");
+        Assert.assertEquals(extractor.generateKey(host, req1), extractor.generateKey(host, req2));
     }
 
     @Test
     public void testEquivalentExtraPathEncodingsWithPercentAreEquivalent() {
         final HttpHost host = new HttpHost("foo.example.com");
-        final HttpRequest req1 = new BasicHttpRequest("GET", "/~smith/home%20folder.html", HttpVersion.HTTP_1_1);
-        final HttpRequest req2 = new BasicHttpRequest("GET", "/%7Esmith%2Fhome%20folder.html", HttpVersion.HTTP_1_1);
-        Assert.assertEquals(extractor.getURI(host, req1), extractor.getURI(host, req2));
+        final HttpRequest req1 = new BasicHttpRequest("GET", "/~smith/home%20folder.html");
+        final HttpRequest req2 = new BasicHttpRequest("GET", "/%7Esmith%2Fhome%20folder.html");
+        Assert.assertEquals(extractor.generateKey(host, req1), extractor.generateKey(host, req2));
     }
 }

Modified: httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheValidityPolicy.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheValidityPolicy.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheValidityPolicy.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheValidityPolicy.java Tue Dec 27 19:48:07 2016
@@ -39,7 +39,6 @@ import org.apache.hc.client5.http.utils.
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpHeaders;
 import org.apache.hc.core5.http.HttpRequest;
-import org.apache.hc.core5.http.HttpVersion;
 import org.apache.hc.core5.http.message.BasicHeader;
 import org.apache.hc.core5.http.message.BasicHttpRequest;
 import org.junit.Before;
@@ -432,7 +431,7 @@ public class TestCacheValidityPolicy {
                 new BasicHeader("Cache-Control", "max-age=5, stale-if-error=15")
         };
         final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(now, now, headers);
-        final HttpRequest req = new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1);
+        final HttpRequest req = new BasicHttpRequest("GET","/");
         assertTrue(impl.mayReturnStaleIfError(req, entry, now));
     }
 
@@ -443,7 +442,7 @@ public class TestCacheValidityPolicy {
                 new BasicHeader("Cache-Control", "max-age=5")
         };
         final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(now, now, headers);
-        final HttpRequest req = new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1);
+        final HttpRequest req = new BasicHttpRequest("GET","/");
         req.setHeader("Cache-Control","stale-if-error=15");
         assertTrue(impl.mayReturnStaleIfError(req, entry, now));
     }
@@ -455,7 +454,7 @@ public class TestCacheValidityPolicy {
                 new BasicHeader("Cache-Control", "max-age=5, stale-if-error=1")
         };
         final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(now, now, headers);
-        final HttpRequest req = new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1);
+        final HttpRequest req = new BasicHttpRequest("GET","/");
         assertFalse(impl.mayReturnStaleIfError(req, entry, now));
     }
 
@@ -466,7 +465,7 @@ public class TestCacheValidityPolicy {
                 new BasicHeader("Cache-Control", "max-age=5")
         };
         final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(now, now, headers);
-        final HttpRequest req = new BasicHttpRequest("GET","/",HttpVersion.HTTP_1_1);
+        final HttpRequest req = new BasicHttpRequest("GET","/");
         req.setHeader("Cache-Control","stale-if-error=1");
         assertFalse(impl.mayReturnStaleIfError(req, entry, now));
     }

Modified: httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachedHttpResponseGenerator.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachedHttpResponseGenerator.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachedHttpResponseGenerator.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachedHttpResponseGenerator.java Tue Dec 27 19:48:07 2016
@@ -35,11 +35,12 @@ import static org.mockito.Mockito.when;
 import java.util.Date;
 import java.util.HashMap;
 
+import org.apache.hc.client5.http.HttpRoute;
 import org.apache.hc.client5.http.cache.HttpCacheEntry;
-import org.apache.hc.client5.http.methods.HttpRequestWrapper;
+import org.apache.hc.client5.http.methods.RoutedHttpRequest;
+import org.apache.hc.core5.http.ClassicHttpResponse;
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpHost;
-import org.apache.hc.core5.http.HttpResponse;
 import org.apache.hc.core5.http.message.BasicHeader;
 import org.junit.Assert;
 import org.junit.Before;
@@ -49,16 +50,18 @@ import org.junit.Test;
 public class TestCachedHttpResponseGenerator {
 
     private HttpHost host;
+    private HttpRoute route;
     private HttpCacheEntry entry;
-    private HttpRequestWrapper request;
+    private RoutedHttpRequest request;
     private CacheValidityPolicy mockValidityPolicy;
     private CachedHttpResponseGenerator impl;
 
     @Before
     public void setUp() {
         host = new HttpHost("foo.example.com", 80);
+        route = new HttpRoute(host);
         entry = HttpTestUtils.makeCacheEntry(new HashMap<String, String>());
-        request = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultRequest(), host);
+        request = RoutedHttpRequest.adapt(HttpTestUtils.makeDefaultRequest(), route);
         mockValidityPolicy = mock(CacheValidityPolicy.class);
         impl = new CachedHttpResponseGenerator(mockValidityPolicy);
     }
@@ -68,7 +71,7 @@ public class TestCachedHttpResponseGener
         final byte[] buf = new byte[] { 1, 2, 3, 4, 5 };
         final HttpCacheEntry entry1 = HttpTestUtils.makeCacheEntry(buf);
 
-        final HttpResponse response = impl.generateResponse(request, entry1);
+        final ClassicHttpResponse response = impl.generateResponse(request, entry1);
 
         final Header length = response.getFirstHeader("Content-Length");
         Assert.assertNotNull("Content-Length Header is missing", length);
@@ -84,7 +87,7 @@ public class TestCachedHttpResponseGener
         final byte[] buf = new byte[] { 1, 2, 3, 4, 5 };
         final HttpCacheEntry entry1 = HttpTestUtils.makeCacheEntry(hdrs, buf);
 
-        final HttpResponse response = impl.generateResponse(request, entry1);
+        final ClassicHttpResponse response = impl.generateResponse(request, entry1);
 
         final Header length = response.getFirstHeader("Content-Length");
 
@@ -93,27 +96,27 @@ public class TestCachedHttpResponseGener
 
     @Test
     public void testResponseMatchesCacheEntry() {
-        final HttpResponse response = impl.generateResponse(request, entry);
+        final ClassicHttpResponse response = impl.generateResponse(request, entry);
 
         Assert.assertTrue(response.containsHeader("Content-Length"));
 
-        Assert.assertSame("HTTP", response.getProtocolVersion().getProtocol());
-        Assert.assertEquals(1, response.getProtocolVersion().getMajor());
-        Assert.assertEquals(1, response.getProtocolVersion().getMinor());
+        Assert.assertSame("HTTP", response.getVersion().getProtocol());
+        Assert.assertEquals(1, response.getVersion().getMajor());
+        Assert.assertEquals(1, response.getVersion().getMinor());
     }
 
     @Test
     public void testResponseStatusCodeMatchesCacheEntry() {
-        final HttpResponse response = impl.generateResponse(request, entry);
+        final ClassicHttpResponse response = impl.generateResponse(request, entry);
 
-        Assert.assertEquals(entry.getStatusCode(), response.getStatusLine().getStatusCode());
+        Assert.assertEquals(entry.getStatus(), response.getCode());
     }
 
     @Test
     public void testAgeHeaderIsPopulatedWithCurrentAgeOfCacheEntryIfNonZero() {
         currentAge(10L);
 
-        final HttpResponse response = impl.generateResponse(request, entry);
+        final ClassicHttpResponse response = impl.generateResponse(request, entry);
 
         verify(mockValidityPolicy).getCurrentAgeSecs(same(entry), isA(Date.class));
 
@@ -126,7 +129,7 @@ public class TestCachedHttpResponseGener
     public void testAgeHeaderIsNotPopulatedIfCurrentAgeOfCacheEntryIsZero() {
         currentAge(0L);
 
-        final HttpResponse response = impl.generateResponse(request, entry);
+        final ClassicHttpResponse response = impl.generateResponse(request, entry);
 
         verify(mockValidityPolicy).getCurrentAgeSecs(same(entry), isA(Date.class));
 
@@ -138,7 +141,7 @@ public class TestCachedHttpResponseGener
     public void testAgeHeaderIsPopulatedWithMaxAgeIfCurrentAgeTooBig() {
         currentAge(CacheValidityPolicy.MAX_AGE + 1L);
 
-        final HttpResponse response = impl.generateResponse(request, entry);
+        final ClassicHttpResponse response = impl.generateResponse(request, entry);
 
         verify(mockValidityPolicy).getCurrentAgeSecs(same(entry), isA(Date.class));
 
@@ -155,15 +158,15 @@ public class TestCachedHttpResponseGener
 
     @Test
     public void testResponseContainsEntityToServeGETRequestIfEntryContainsResource() throws Exception {
-        final HttpResponse response = impl.generateResponse(request, entry);
+        final ClassicHttpResponse response = impl.generateResponse(request, entry);
 
         Assert.assertNotNull(response.getEntity());
     }
 
     @Test
     public void testResponseDoesNotContainEntityToServeHEADRequestIfEntryContainsResource() throws Exception {
-        final HttpRequestWrapper headRequest = HttpRequestWrapper.wrap(HttpTestUtils.makeDefaultHEADRequest(), host);
-        final HttpResponse response = impl.generateResponse(headRequest, entry);
+        final RoutedHttpRequest headRequest = RoutedHttpRequest.adapt(HttpTestUtils.makeDefaultHEADRequest(), route);
+        final ClassicHttpResponse response = impl.generateResponse(headRequest, entry);
 
         Assert.assertNull(response.getEntity());
     }

Modified: httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachedResponseSuitabilityChecker.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachedResponseSuitabilityChecker.java?rev=1776187&r1=1776186&r2=1776187&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachedResponseSuitabilityChecker.java (original)
+++ httpcomponents/httpclient/trunk/httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCachedResponseSuitabilityChecker.java Tue Dec 27 19:48:07 2016
@@ -33,7 +33,6 @@ import org.apache.hc.client5.http.utils.
 import org.apache.hc.core5.http.Header;
 import org.apache.hc.core5.http.HttpHost;
 import org.apache.hc.core5.http.HttpRequest;
-import org.apache.hc.core5.http.HttpVersion;
 import org.apache.hc.core5.http.message.BasicHeader;
 import org.apache.hc.core5.http.message.BasicHttpRequest;
 import org.junit.Assert;
@@ -60,7 +59,7 @@ public class TestCachedResponseSuitabili
         nineSecondsAgo = new Date(now.getTime() - 9 * 1000L);
 
         host = new HttpHost("foo.example.com");
-        request = new BasicHttpRequest("GET", "/foo", HttpVersion.HTTP_1_1);
+        request = new BasicHttpRequest("GET", "/foo");
         entry = HttpTestUtils.makeCacheEntry();
 
         impl = new CachedResponseSuitabilityChecker(CacheConfig.DEFAULT);
@@ -253,7 +252,7 @@ public class TestCachedResponseSuitabili
 
     @Test
     public void testSuitableIfRequestMethodisHEAD() {
-        final HttpRequest headRequest = new BasicHttpRequest("HEAD", "/foo", HttpVersion.HTTP_1_1);
+        final HttpRequest headRequest = new BasicHttpRequest("HEAD", "/foo");
         final Header[] headers = {
                 new BasicHeader("Date", DateUtils.formatDate(tenSecondsAgo)),
                 new BasicHeader("Cache-Control", "max-age=3600"),
@@ -316,7 +315,7 @@ public class TestCachedResponseSuitabili
 
     @Test
     public void testSuitableForHEADIfHeadResponseCachingEnabledAndEntryDoesNotSpecifyARequestMethod() {
-        final HttpRequest headRequest = new BasicHttpRequest("HEAD", "/foo", HttpVersion.HTTP_1_1);
+        final HttpRequest headRequest = new BasicHttpRequest("HEAD", "/foo");
         impl = new CachedResponseSuitabilityChecker(CacheConfig.custom().build());
         final Header[] headers = {
                 new BasicHeader("Date", DateUtils.formatDate(tenSecondsAgo)),



Mime
View raw message