Upgraded HttpCore to version 5.0-beta11

This commit is contained in:
Ryan Schmitt 2019-12-11 15:11:29 -08:00 committed by Oleg Kalnichevski
parent a8fc99f4a2
commit 3aec96d3db
68 changed files with 246 additions and 238 deletions

View File

@ -47,7 +47,7 @@ import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequest; import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.Methods; import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.http.message.RequestLine; import org.apache.hc.core5.http.message.RequestLine;
import org.apache.hc.core5.http.message.StatusLine; import org.apache.hc.core5.http.message.StatusLine;
import org.apache.hc.core5.util.ByteArrayBuffer; import org.apache.hc.core5.util.ByteArrayBuffer;
@ -100,7 +100,7 @@ class BasicHttpAsyncCache implements HttpAsyncCache {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Flush cache entries: " + host + "; " + new RequestLine(request)); log.debug("Flush cache entries: " + host + "; " + new RequestLine(request));
} }
if (!Methods.isSafe(request.getMethod())) { if (!Method.isSafe(request.getMethod())) {
final String cacheKey = cacheKeyGenerator.generateKey(host, request); final String cacheKey = cacheKeyGenerator.generateKey(host, request);
return storage.removeEntry(cacheKey, new FutureCallback<Boolean>() { return storage.removeEntry(cacheKey, new FutureCallback<Boolean>() {
@ -147,7 +147,7 @@ class BasicHttpAsyncCache implements HttpAsyncCache {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Flush cache entries invalidated by exchange: " + host + "; " + new RequestLine(request) + " -> " + new StatusLine(response)); log.debug("Flush cache entries invalidated by exchange: " + host + "; " + new RequestLine(request) + " -> " + new StatusLine(response));
} }
if (!Methods.isSafe(request.getMethod())) { if (!Method.isSafe(request.getMethod())) {
return cacheInvalidator.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyGenerator, storage, callback); return cacheInvalidator.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyGenerator, storage, callback);
} }
callback.completed(Boolean.TRUE); callback.completed(Boolean.TRUE);

View File

@ -42,7 +42,7 @@ import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequest; import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.Methods; import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.http.message.RequestLine; import org.apache.hc.core5.http.message.RequestLine;
import org.apache.hc.core5.http.message.StatusLine; import org.apache.hc.core5.http.message.StatusLine;
import org.apache.hc.core5.util.ByteArrayBuffer; import org.apache.hc.core5.util.ByteArrayBuffer;
@ -102,7 +102,7 @@ class BasicHttpCache implements HttpCache {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Flush cache entries: " + host + "; " + new RequestLine(request)); log.debug("Flush cache entries: " + host + "; " + new RequestLine(request));
} }
if (!Methods.isSafe(request.getMethod())) { if (!Method.isSafe(request.getMethod())) {
final String cacheKey = cacheKeyGenerator.generateKey(host, request); final String cacheKey = cacheKeyGenerator.generateKey(host, request);
try { try {
storage.removeEntry(cacheKey); storage.removeEntry(cacheKey);
@ -127,7 +127,7 @@ class BasicHttpCache implements HttpCache {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Flush cache entries invalidated by exchange: " + host + "; " + new RequestLine(request) + " -> " + new StatusLine(response)); log.debug("Flush cache entries invalidated by exchange: " + host + "; " + new RequestLine(request) + " -> " + new StatusLine(response));
} }
if (!Methods.isSafe(request.getMethod())) { if (!Method.isSafe(request.getMethod())) {
cacheInvalidator.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyGenerator, storage); cacheInvalidator.flushCacheEntriesInvalidatedByExchange(host, request, response, cacheKeyGenerator, storage);
} }
} }

View File

@ -64,7 +64,7 @@ class DefaultAsyncCacheRevalidator extends CacheRevalidatorBase {
@Override @Override
public Future<?> schedule(final Runnable command, final TimeValue timeValue) throws RejectedExecutionException { public Future<?> schedule(final Runnable command, final TimeValue timeValue) throws RejectedExecutionException {
if (timeValue.toMillis() <= 0) { if (timeValue.toMilliseconds() <= 0) {
command.run(); command.run();
return new Operations.CompletedFuture<Void>(null); return new Operations.CompletedFuture<Void>(null);
} }

View File

@ -108,8 +108,8 @@ public class ExponentialBackOffSchedulingStrategy implements SchedulingStrategy
protected TimeValue calculateDelay(final int consecutiveFailedAttempts) { protected TimeValue calculateDelay(final int consecutiveFailedAttempts) {
if (consecutiveFailedAttempts > 0) { if (consecutiveFailedAttempts > 0) {
final long delay = (long) (initialExpiry.toMillis() * Math.pow(backOffRate, consecutiveFailedAttempts - 1)); final long delay = (long) (initialExpiry.toMilliseconds() * Math.pow(backOffRate, consecutiveFailedAttempts - 1));
return TimeValue.ofMilliseconds(Math.min(delay, maxExpiry.toMillis())); return TimeValue.ofMilliseconds(Math.min(delay, maxExpiry.toMilliseconds()));
} }
return TimeValue.ZERO_MILLISECONDS; return TimeValue.ZERO_MILLISECONDS;
} }

View File

@ -142,7 +142,7 @@ public class TestHttpCacheEntry {
try { try {
new HttpCacheEntry(null, new Date(), HttpStatus.SC_OK, new Header[]{}, mockResource); new HttpCacheEntry(null, new Date(), HttpStatus.SC_OK, new Header[]{}, mockResource);
fail("Should have thrown exception"); fail("Should have thrown exception");
} catch (final IllegalArgumentException expected) { } catch (final NullPointerException expected) {
} }
} }
@ -152,7 +152,7 @@ public class TestHttpCacheEntry {
try { try {
new HttpCacheEntry(new Date(), null, HttpStatus.SC_OK, new Header[]{}, mockResource); new HttpCacheEntry(new Date(), null, HttpStatus.SC_OK, new Header[]{}, mockResource);
fail("Should have thrown exception"); fail("Should have thrown exception");
} catch (final IllegalArgumentException expected) { } catch (final NullPointerException expected) {
} }
} }
@ -162,7 +162,7 @@ public class TestHttpCacheEntry {
try { try {
new HttpCacheEntry(new Date(), new Date(), HttpStatus.SC_OK, null, mockResource); new HttpCacheEntry(new Date(), new Date(), HttpStatus.SC_OK, null, mockResource);
fail("Should have thrown exception"); fail("Should have thrown exception");
} catch (final IllegalArgumentException expected) { } catch (final NullPointerException expected) {
} }
} }

View File

@ -55,7 +55,7 @@ import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpHeaders; import org.apache.hc.core5.http.HttpHeaders;
import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpVersion; import org.apache.hc.core5.http.HttpVersion;
import org.apache.hc.core5.http.Methods; import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.http.NameValuePair; import org.apache.hc.core5.http.NameValuePair;
import org.apache.hc.core5.http.io.entity.ByteArrayEntity; import org.apache.hc.core5.http.io.entity.ByteArrayEntity;
import org.apache.hc.core5.http.io.entity.FileEntity; import org.apache.hc.core5.http.io.entity.FileEntity;
@ -81,7 +81,7 @@ public class Request {
private SimpleDateFormat dateFormatter; private SimpleDateFormat dateFormatter;
public static Request create(final Methods method, final URI uri) { public static Request create(final Method method, final URI uri) {
return new Request(new HttpUriRequestBase(method.name(), uri)); return new Request(new HttpUriRequestBase(method.name(), uri));
} }

View File

@ -45,7 +45,7 @@ import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.Message; import org.apache.hc.core5.http.Message;
import org.apache.hc.core5.http.Methods; import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.http.URIScheme; import org.apache.hc.core5.http.URIScheme;
import org.apache.hc.core5.http.nio.entity.AsyncEntityProducers; import org.apache.hc.core5.http.nio.entity.AsyncEntityProducers;
import org.apache.hc.core5.http.nio.entity.BasicAsyncEntityConsumer; import org.apache.hc.core5.http.nio.entity.BasicAsyncEntityConsumer;
@ -98,7 +98,7 @@ public abstract class AbstractHttpAsyncFundamentalsTest<T extends CloseableHttpA
final Random rnd = new Random(System.currentTimeMillis()); final Random rnd = new Random(System.currentTimeMillis());
rnd.nextBytes(b1); rnd.nextBytes(b1);
final Future<Message<HttpResponse, byte[]>> future = httpclient.execute( final Future<Message<HttpResponse, byte[]>> future = httpclient.execute(
new BasicRequestProducer(Methods.GET, target, "/echo/", new BasicRequestProducer(Method.GET, target, "/echo/",
AsyncEntityProducers.create(b1, ContentType.APPLICATION_OCTET_STREAM)), AsyncEntityProducers.create(b1, ContentType.APPLICATION_OCTET_STREAM)),
new BasicResponseConsumer<>(new BasicAsyncEntityConsumer()), HttpClientContext.create(), null); new BasicResponseConsumer<>(new BasicAsyncEntityConsumer()), HttpClientContext.create(), null);
final Message<HttpResponse, byte[]> responseMessage = future.get(); final Message<HttpResponse, byte[]> responseMessage = future.get();
@ -122,7 +122,7 @@ public abstract class AbstractHttpAsyncFundamentalsTest<T extends CloseableHttpA
final Queue<Future<Message<HttpResponse, byte[]>>> queue = new LinkedList<>(); final Queue<Future<Message<HttpResponse, byte[]>>> queue = new LinkedList<>();
for (int i = 0; i < reqCount; i++) { for (int i = 0; i < reqCount; i++) {
final Future<Message<HttpResponse, byte[]>> future = httpclient.execute( final Future<Message<HttpResponse, byte[]>> future = httpclient.execute(
new BasicRequestProducer(Methods.POST, target, "/echo/", new BasicRequestProducer(Method.POST, target, "/echo/",
AsyncEntityProducers.create(b1, ContentType.APPLICATION_OCTET_STREAM)), AsyncEntityProducers.create(b1, ContentType.APPLICATION_OCTET_STREAM)),
new BasicResponseConsumer<>(new BasicAsyncEntityConsumer()), HttpClientContext.create(), null); new BasicResponseConsumer<>(new BasicAsyncEntityConsumer()), HttpClientContext.create(), null);
queue.add(future); queue.add(future);

View File

@ -157,7 +157,7 @@ public class TestHttp1AsyncStatefulConnManagement extends AbstractIntegrationTes
worker.start(); worker.start();
} }
for (final HttpWorker worker : workers) { for (final HttpWorker worker : workers) {
worker.join(LONG_TIMEOUT.toMillis()); worker.join(LONG_TIMEOUT.toMilliseconds());
} }
for (final HttpWorker worker : workers) { for (final HttpWorker worker : workers) {
final Exception ex = worker.getException(); final Exception ex = worker.getException();

View File

@ -46,7 +46,7 @@ import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.HttpVersion; import org.apache.hc.core5.http.HttpVersion;
import org.apache.hc.core5.http.Message; import org.apache.hc.core5.http.Message;
import org.apache.hc.core5.http.Methods; import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.http.URIScheme; import org.apache.hc.core5.http.URIScheme;
import org.apache.hc.core5.http.config.Http1Config; import org.apache.hc.core5.http.config.Http1Config;
import org.apache.hc.core5.http.nio.AsyncClientEndpoint; import org.apache.hc.core5.http.nio.AsyncClientEndpoint;
@ -124,7 +124,7 @@ public class TestHttpAsyncMinimal extends AbstractHttpAsyncFundamentalsTest<Mini
final Queue<Future<Message<HttpResponse, byte[]>>> queue = new LinkedList<>(); final Queue<Future<Message<HttpResponse, byte[]>>> queue = new LinkedList<>();
for (int i = 0; i < reqCount; i++) { for (int i = 0; i < reqCount; i++) {
final Future<Message<HttpResponse, byte[]>> future = endpoint.execute( final Future<Message<HttpResponse, byte[]>> future = endpoint.execute(
new BasicRequestProducer(Methods.GET, target, "/echo/", new BasicRequestProducer(Method.GET, target, "/echo/",
AsyncEntityProducers.create(b1, ContentType.APPLICATION_OCTET_STREAM)), AsyncEntityProducers.create(b1, ContentType.APPLICATION_OCTET_STREAM)),
new BasicResponseConsumer<>(new BasicAsyncEntityConsumer()), HttpClientContext.create(), null); new BasicResponseConsumer<>(new BasicAsyncEntityConsumer()), HttpClientContext.create(), null);
queue.add(future); queue.add(future);

View File

@ -150,7 +150,7 @@ public class CachingHttpAsyncClientCompatibilityTest {
} }
// GET with links // GET with links
{ {
connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS); connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND);
final HttpCacheContext context = HttpCacheContext.create(); final HttpCacheContext context = HttpCacheContext.create();
final Pattern linkPattern = Pattern.compile("^<(.*)>;rel=preload$"); final Pattern linkPattern = Pattern.compile("^<(.*)>;rel=preload$");

View File

@ -132,7 +132,7 @@ public class CachingHttpClientCompatibilityTest {
} }
// GET with links // GET with links
{ {
connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS); connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND);
final HttpCacheContext context = HttpCacheContext.create(); final HttpCacheContext context = HttpCacheContext.create();
final Pattern linkPattern = Pattern.compile("^<(.*)>;rel=preload$"); final Pattern linkPattern = Pattern.compile("^<(.*)>;rel=preload$");
final List<String> links = new ArrayList<>(); final List<String> links = new ArrayList<>();

View File

@ -187,7 +187,7 @@ public class HttpAsyncClientCompatibilityTest {
} }
// Basic GET requests // Basic GET requests
{ {
connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS); connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND);
final HttpClientContext context = HttpClientContext.create(); final HttpClientContext context = HttpClientContext.create();
context.setCredentialsProvider(credentialsProvider); context.setCredentialsProvider(credentialsProvider);
@ -213,7 +213,7 @@ public class HttpAsyncClientCompatibilityTest {
} }
// Wrong target auth scope // Wrong target auth scope
{ {
connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS); connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND);
credentialsProvider.setCredentials( credentialsProvider.setCredentials(
new AuthScope("http", "otherhost", -1, "Restricted Files", null), new AuthScope("http", "otherhost", -1, "Restricted Files", null),
new UsernamePasswordCredentials("testuser", "nopassword".toCharArray())); new UsernamePasswordCredentials("testuser", "nopassword".toCharArray()));
@ -239,7 +239,7 @@ public class HttpAsyncClientCompatibilityTest {
} }
// Wrong target credentials // Wrong target credentials
{ {
connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS); connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND);
credentialsProvider.setCredentials( credentialsProvider.setCredentials(
new AuthScope(target), new AuthScope(target),
new UsernamePasswordCredentials("testuser", "wrong password".toCharArray())); new UsernamePasswordCredentials("testuser", "wrong password".toCharArray()));
@ -265,7 +265,7 @@ public class HttpAsyncClientCompatibilityTest {
} }
// Correct target credentials // Correct target credentials
{ {
connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS); connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND);
credentialsProvider.setCredentials( credentialsProvider.setCredentials(
new AuthScope(target), new AuthScope(target),
new UsernamePasswordCredentials("testuser", "nopassword".toCharArray())); new UsernamePasswordCredentials("testuser", "nopassword".toCharArray()));
@ -292,7 +292,7 @@ public class HttpAsyncClientCompatibilityTest {
// Correct target credentials (no keep-alive) // Correct target credentials (no keep-alive)
if (protocolVersion.lessEquals(HttpVersion.HTTP_1_1)) if (protocolVersion.lessEquals(HttpVersion.HTTP_1_1))
{ {
connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS); connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND);
credentialsProvider.setCredentials( credentialsProvider.setCredentials(
new AuthScope(target), new AuthScope(target),
new UsernamePasswordCredentials("testuser", "nopassword".toCharArray())); new UsernamePasswordCredentials("testuser", "nopassword".toCharArray()));

View File

@ -157,7 +157,7 @@ public class HttpClientCompatibilityTest {
} }
// Basic GET requests // Basic GET requests
{ {
connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS); connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND);
final HttpClientContext context = HttpClientContext.create(); final HttpClientContext context = HttpClientContext.create();
context.setCredentialsProvider(credentialsProvider); context.setCredentialsProvider(credentialsProvider);
final String[] requestUris = new String[] {"/", "/news.html", "/status.html"}; final String[] requestUris = new String[] {"/", "/news.html", "/status.html"};
@ -178,7 +178,7 @@ public class HttpClientCompatibilityTest {
} }
// Wrong target auth scope // Wrong target auth scope
{ {
connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS); connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND);
credentialsProvider.setCredentials( credentialsProvider.setCredentials(
new AuthScope("http", "otherhost", -1, "Restricted Files", null), new AuthScope("http", "otherhost", -1, "Restricted Files", null),
new UsernamePasswordCredentials("testuser", "nopassword".toCharArray())); new UsernamePasswordCredentials("testuser", "nopassword".toCharArray()));
@ -200,7 +200,7 @@ public class HttpClientCompatibilityTest {
} }
// Wrong target credentials // Wrong target credentials
{ {
connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS); connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND);
credentialsProvider.setCredentials( credentialsProvider.setCredentials(
new AuthScope(target), new AuthScope(target),
new UsernamePasswordCredentials("testuser", "wrong password".toCharArray())); new UsernamePasswordCredentials("testuser", "wrong password".toCharArray()));
@ -222,7 +222,7 @@ public class HttpClientCompatibilityTest {
} }
// Correct target credentials // Correct target credentials
{ {
connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS); connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND);
credentialsProvider.setCredentials( credentialsProvider.setCredentials(
new AuthScope(target), new AuthScope(target),
new UsernamePasswordCredentials("testuser", "nopassword".toCharArray())); new UsernamePasswordCredentials("testuser", "nopassword".toCharArray()));
@ -244,7 +244,7 @@ public class HttpClientCompatibilityTest {
} }
// Correct target credentials (no keep-alive) // Correct target credentials (no keep-alive)
{ {
connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS); connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND);
credentialsProvider.setCredentials( credentialsProvider.setCredentials(
new AuthScope(target), new AuthScope(target),
new UsernamePasswordCredentials("testuser", "nopassword".toCharArray())); new UsernamePasswordCredentials("testuser", "nopassword".toCharArray()));

View File

@ -39,6 +39,7 @@ import org.apache.hc.client5.testing.classic.RandomHandler;
import org.apache.hc.core5.function.Decorator; import org.apache.hc.core5.function.Decorator;
import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.URIScheme; import org.apache.hc.core5.http.URIScheme;
import org.apache.hc.core5.http.config.Http1Config;
import org.apache.hc.core5.http.io.HttpServerRequestHandler; import org.apache.hc.core5.http.io.HttpServerRequestHandler;
import org.apache.hc.core5.http.io.SocketConfig; import org.apache.hc.core5.http.io.SocketConfig;
import org.apache.hc.core5.http.protocol.HttpProcessor; import org.apache.hc.core5.http.protocol.HttpProcessor;
@ -126,9 +127,10 @@ public abstract class LocalServerTestBase {
}; };
public HttpHost start( public HttpHost start(
final Http1Config http1Config,
final HttpProcessor httpProcessor, final HttpProcessor httpProcessor,
final Decorator<HttpServerRequestHandler> handlerDecorator) throws IOException { final Decorator<HttpServerRequestHandler> handlerDecorator) throws IOException {
this.server.start(httpProcessor, handlerDecorator); this.server.start(http1Config, httpProcessor, handlerDecorator);
if (this.httpclient == null) { if (this.httpclient == null) {
this.httpclient = this.clientBuilder.build(); this.httpclient = this.clientBuilder.build();
@ -137,8 +139,14 @@ public abstract class LocalServerTestBase {
return new HttpHost(this.scheme.name(), "localhost", this.server.getPort()); return new HttpHost(this.scheme.name(), "localhost", this.server.getPort());
} }
public HttpHost start(
final HttpProcessor httpProcessor,
final Decorator<HttpServerRequestHandler> handlerDecorator) throws IOException {
return start(null, httpProcessor, handlerDecorator);
}
public HttpHost start() throws Exception { public HttpHost start() throws Exception {
return start(null, null); return start(null, null, null);
} }
} }

View File

@ -82,7 +82,7 @@ public class TestConnectionManagement extends LocalServerTestBase {
final LeaseRequest leaseRequest1 = this.connManager.lease("id1", route,null); final LeaseRequest leaseRequest1 = this.connManager.lease("id1", route,null);
final ConnectionEndpoint endpoint1 = leaseRequest1.get(Timeout.ZERO_MILLISECONDS); final ConnectionEndpoint endpoint1 = leaseRequest1.get(Timeout.ZERO_MILLISECONDS);
this.connManager.connect(endpoint1, TimeValue.NEG_ONE_MILLISECONDS, context); this.connManager.connect(endpoint1, TimeValue.NEG_ONE_MILLISECOND, context);
final HttpProcessor httpProcessor = new DefaultHttpProcessor( final HttpProcessor httpProcessor = new DefaultHttpProcessor(
new RequestTargetHost(), new RequestContent(), new RequestConnControl()); new RequestTargetHost(), new RequestContent(), new RequestConnControl());
@ -104,12 +104,12 @@ public class TestConnectionManagement extends LocalServerTestBase {
} }
endpoint1.close(); endpoint1.close();
this.connManager.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECONDS); this.connManager.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECOND);
final LeaseRequest leaseRequest2 = this.connManager.lease("id2", route,null); final LeaseRequest leaseRequest2 = this.connManager.lease("id2", route,null);
final ConnectionEndpoint endpoint2 = leaseRequest2.get(Timeout.ZERO_MILLISECONDS); final ConnectionEndpoint endpoint2 = leaseRequest2.get(Timeout.ZERO_MILLISECONDS);
Assert.assertFalse(endpoint2.isConnected()); Assert.assertFalse(endpoint2.isConnected());
this.connManager.connect(endpoint2, TimeValue.NEG_ONE_MILLISECONDS, context); this.connManager.connect(endpoint2, TimeValue.NEG_ONE_MILLISECOND, context);
try (final ClassicHttpResponse response2 = endpoint2.execute("id2", request, exec, context)) { try (final ClassicHttpResponse response2 = endpoint2.execute("id2", request, exec, context)) {
Assert.assertEquals(HttpStatus.SC_OK, response2.getCode()); Assert.assertEquals(HttpStatus.SC_OK, response2.getCode());
@ -117,7 +117,7 @@ public class TestConnectionManagement extends LocalServerTestBase {
// release connection after marking it for re-use // release connection after marking it for re-use
// expect the next connection obtained to be open // expect the next connection obtained to be open
this.connManager.release(endpoint2, null, TimeValue.NEG_ONE_MILLISECONDS); this.connManager.release(endpoint2, null, TimeValue.NEG_ONE_MILLISECOND);
final LeaseRequest leaseRequest3 = this.connManager.lease("id3", route,null); final LeaseRequest leaseRequest3 = this.connManager.lease("id3", route,null);
final ConnectionEndpoint endpoint3 = leaseRequest3.get(Timeout.ZERO_MILLISECONDS); final ConnectionEndpoint endpoint3 = leaseRequest3.get(Timeout.ZERO_MILLISECONDS);
@ -128,7 +128,7 @@ public class TestConnectionManagement extends LocalServerTestBase {
Assert.assertEquals(HttpStatus.SC_OK, response3.getCode()); Assert.assertEquals(HttpStatus.SC_OK, response3.getCode());
} }
this.connManager.release(endpoint3, null, TimeValue.NEG_ONE_MILLISECONDS); this.connManager.release(endpoint3, null, TimeValue.NEG_ONE_MILLISECOND);
this.connManager.close(); this.connManager.close();
} }
@ -150,7 +150,7 @@ public class TestConnectionManagement extends LocalServerTestBase {
final LeaseRequest leaseRequest1 = this.connManager.lease("id1", route,null); final LeaseRequest leaseRequest1 = this.connManager.lease("id1", route,null);
final ConnectionEndpoint endpoint1 = leaseRequest1.get(Timeout.ZERO_MILLISECONDS); final ConnectionEndpoint endpoint1 = leaseRequest1.get(Timeout.ZERO_MILLISECONDS);
this.connManager.connect(endpoint1, TimeValue.NEG_ONE_MILLISECONDS, context); this.connManager.connect(endpoint1, TimeValue.NEG_ONE_MILLISECOND, context);
final HttpProcessor httpProcessor = new DefaultHttpProcessor( final HttpProcessor httpProcessor = new DefaultHttpProcessor(
new RequestTargetHost(), new RequestContent(), new RequestConnControl()); new RequestTargetHost(), new RequestContent(), new RequestConnControl());
@ -178,7 +178,7 @@ public class TestConnectionManagement extends LocalServerTestBase {
final ConnectionEndpoint endpoint2 = leaseRequest2.get(Timeout.ZERO_MILLISECONDS); final ConnectionEndpoint endpoint2 = leaseRequest2.get(Timeout.ZERO_MILLISECONDS);
Assert.assertFalse(endpoint2.isConnected()); Assert.assertFalse(endpoint2.isConnected());
this.connManager.connect(endpoint2, TimeValue.NEG_ONE_MILLISECONDS, context); this.connManager.connect(endpoint2, TimeValue.NEG_ONE_MILLISECOND, context);
try (final ClassicHttpResponse response2 = endpoint2.execute("id2", request, exec, context)) { try (final ClassicHttpResponse response2 = endpoint2.execute("id2", request, exec, context)) {
Assert.assertEquals(HttpStatus.SC_OK, response2.getCode()); Assert.assertEquals(HttpStatus.SC_OK, response2.getCode());
@ -203,7 +203,7 @@ public class TestConnectionManagement extends LocalServerTestBase {
Assert.assertFalse(endpoint4.isConnected()); Assert.assertFalse(endpoint4.isConnected());
// repeat the communication, no need to prepare the request again // repeat the communication, no need to prepare the request again
this.connManager.connect(endpoint4, TimeValue.NEG_ONE_MILLISECONDS, context); this.connManager.connect(endpoint4, TimeValue.NEG_ONE_MILLISECOND, context);
try (final ClassicHttpResponse response4 = endpoint4.execute("id4", request, exec, context)) { try (final ClassicHttpResponse response4 = endpoint4.execute("id4", request, exec, context)) {
Assert.assertEquals(HttpStatus.SC_OK, response4.getCode()); Assert.assertEquals(HttpStatus.SC_OK, response4.getCode());
@ -223,7 +223,7 @@ public class TestConnectionManagement extends LocalServerTestBase {
final LeaseRequest leaseRequest1 = this.connManager.lease("id1", route,null); final LeaseRequest leaseRequest1 = this.connManager.lease("id1", route,null);
final ConnectionEndpoint endpoint1 = leaseRequest1.get(Timeout.ZERO_MILLISECONDS); final ConnectionEndpoint endpoint1 = leaseRequest1.get(Timeout.ZERO_MILLISECONDS);
this.connManager.connect(endpoint1, TimeValue.NEG_ONE_MILLISECONDS, context); this.connManager.connect(endpoint1, TimeValue.NEG_ONE_MILLISECOND, context);
Assert.assertEquals(1, this.connManager.getTotalStats().getLeased()); Assert.assertEquals(1, this.connManager.getTotalStats().getLeased());
Assert.assertEquals(1, this.connManager.getStats(route).getLeased()); Assert.assertEquals(1, this.connManager.getStats(route).getLeased());
@ -272,12 +272,12 @@ public class TestConnectionManagement extends LocalServerTestBase {
final LeaseRequest leaseRequest1 = this.connManager.lease("id1", route,null); final LeaseRequest leaseRequest1 = this.connManager.lease("id1", route,null);
final ConnectionEndpoint endpoint1 = leaseRequest1.get(Timeout.ZERO_MILLISECONDS); final ConnectionEndpoint endpoint1 = leaseRequest1.get(Timeout.ZERO_MILLISECONDS);
this.connManager.connect(endpoint1, TimeValue.NEG_ONE_MILLISECONDS, context); this.connManager.connect(endpoint1, TimeValue.NEG_ONE_MILLISECOND, context);
Assert.assertEquals(1, this.connManager.getTotalStats().getLeased()); Assert.assertEquals(1, this.connManager.getTotalStats().getLeased());
Assert.assertEquals(1, this.connManager.getStats(route).getLeased()); Assert.assertEquals(1, this.connManager.getStats(route).getLeased());
// Release, let remain idle for forever // Release, let remain idle for forever
this.connManager.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECONDS); this.connManager.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECOND);
// Released, still active. // Released, still active.
Assert.assertEquals(1, this.connManager.getTotalStats().getAvailable()); Assert.assertEquals(1, this.connManager.getTotalStats().getAvailable());

View File

@ -107,7 +107,7 @@ public class TestStatefulConnManagement extends LocalServerTestBase {
worker.start(); worker.start();
} }
for (final HttpWorker worker : workers) { for (final HttpWorker worker : workers) {
worker.join(LONG_TIMEOUT.toMillis()); worker.join(LONG_TIMEOUT.toMilliseconds());
} }
for (final HttpWorker worker : workers) { for (final HttpWorker worker : workers) {
final Exception ex = worker.getException(); final Exception ex = worker.getException();

View File

@ -30,7 +30,7 @@ package org.apache.hc.client5.http.async.methods;
import java.net.URI; import java.net.URI;
import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.Methods; import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.http.message.BasicHttpRequest; import org.apache.hc.core5.http.message.BasicHttpRequest;
/** /**
@ -43,96 +43,96 @@ public enum HttpRequests {
DELETE { DELETE {
@Override @Override
public BasicHttpRequest create(final URI uri) { public BasicHttpRequest create(final URI uri) {
return new BasicHttpRequest(Methods.DELETE, uri); return new BasicHttpRequest(Method.DELETE, uri);
} }
@Override @Override
public BasicHttpRequest create(final HttpHost host, final String path) { public BasicHttpRequest create(final HttpHost host, final String path) {
return new BasicHttpRequest(Methods.DELETE, host, path); return new BasicHttpRequest(Method.DELETE, host, path);
} }
}, },
GET { GET {
@Override @Override
public BasicHttpRequest create(final URI uri) { public BasicHttpRequest create(final URI uri) {
return new BasicHttpRequest(Methods.GET, uri); return new BasicHttpRequest(Method.GET, uri);
} }
@Override @Override
public BasicHttpRequest create(final HttpHost host, final String path) { public BasicHttpRequest create(final HttpHost host, final String path) {
return new BasicHttpRequest(Methods.GET, host, path); return new BasicHttpRequest(Method.GET, host, path);
} }
}, },
HEAD { HEAD {
@Override @Override
public BasicHttpRequest create(final URI uri) { public BasicHttpRequest create(final URI uri) {
return new BasicHttpRequest(Methods.HEAD, uri); return new BasicHttpRequest(Method.HEAD, uri);
} }
@Override @Override
public BasicHttpRequest create(final HttpHost host, final String path) { public BasicHttpRequest create(final HttpHost host, final String path) {
return new BasicHttpRequest(Methods.HEAD, host, path); return new BasicHttpRequest(Method.HEAD, host, path);
} }
}, },
OPTIONS { OPTIONS {
@Override @Override
public BasicHttpRequest create(final URI uri) { public BasicHttpRequest create(final URI uri) {
return new BasicHttpRequest(Methods.OPTIONS, uri); return new BasicHttpRequest(Method.OPTIONS, uri);
} }
@Override @Override
public BasicHttpRequest create(final HttpHost host, final String path) { public BasicHttpRequest create(final HttpHost host, final String path) {
return new BasicHttpRequest(Methods.OPTIONS, host, path); return new BasicHttpRequest(Method.OPTIONS, host, path);
} }
}, },
PATCH { PATCH {
@Override @Override
public BasicHttpRequest create(final URI uri) { public BasicHttpRequest create(final URI uri) {
return new BasicHttpRequest(Methods.PATCH, uri); return new BasicHttpRequest(Method.PATCH, uri);
} }
@Override @Override
public BasicHttpRequest create(final HttpHost host, final String path) { public BasicHttpRequest create(final HttpHost host, final String path) {
return new BasicHttpRequest(Methods.PATCH, host, path); return new BasicHttpRequest(Method.PATCH, host, path);
} }
}, },
POST { POST {
@Override @Override
public BasicHttpRequest create(final URI uri) { public BasicHttpRequest create(final URI uri) {
return new BasicHttpRequest(Methods.POST, uri); return new BasicHttpRequest(Method.POST, uri);
} }
@Override @Override
public BasicHttpRequest create(final HttpHost host, final String path) { public BasicHttpRequest create(final HttpHost host, final String path) {
return new BasicHttpRequest(Methods.POST, host, path); return new BasicHttpRequest(Method.POST, host, path);
} }
}, },
PUT { PUT {
@Override @Override
public BasicHttpRequest create(final URI uri) { public BasicHttpRequest create(final URI uri) {
return new BasicHttpRequest(Methods.PUT, uri); return new BasicHttpRequest(Method.PUT, uri);
} }
@Override @Override
public BasicHttpRequest create(final HttpHost host, final String path) { public BasicHttpRequest create(final HttpHost host, final String path) {
return new BasicHttpRequest(Methods.PUT, host, path); return new BasicHttpRequest(Method.PUT, host, path);
} }
}, },
TRACE { TRACE {
@Override @Override
public BasicHttpRequest create(final URI uri) { public BasicHttpRequest create(final URI uri) {
return new BasicHttpRequest(Methods.TRACE, uri); return new BasicHttpRequest(Method.TRACE, uri);
} }
@Override @Override
public BasicHttpRequest create(final HttpHost host, final String path) { public BasicHttpRequest create(final HttpHost host, final String path) {
return new BasicHttpRequest(Methods.TRACE, host, path); return new BasicHttpRequest(Method.TRACE, host, path);
} }
}; };

View File

@ -34,7 +34,7 @@ import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.Header; import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequest; import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.Methods; import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.util.Args; import org.apache.hc.core5.util.Args;
/** /**
@ -73,11 +73,11 @@ public final class SimpleHttpRequest extends ConfigurableHttpRequest {
super(method, requestUri); super(method, requestUri);
} }
SimpleHttpRequest(final Methods method, final URI requestUri) { SimpleHttpRequest(final Method method, final URI requestUri) {
this(method.name(), requestUri); this(method.name(), requestUri);
} }
SimpleHttpRequest(final Methods method, final HttpHost host, final String path) { SimpleHttpRequest(final Method method, final HttpHost host, final String path) {
this(method.name(), host, path); this(method.name(), host, path);
} }

View File

@ -30,7 +30,7 @@ package org.apache.hc.client5.http.async.methods;
import java.net.URI; import java.net.URI;
import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.Methods; import org.apache.hc.core5.http.Method;
/** /**
* Common HTTP methods using {@link SimpleHttpRequest} as a HTTP request message representation. * Common HTTP methods using {@link SimpleHttpRequest} as a HTTP request message representation.
@ -42,96 +42,96 @@ public enum SimpleHttpRequests {
DELETE { DELETE {
@Override @Override
public SimpleHttpRequest create(final URI uri) { public SimpleHttpRequest create(final URI uri) {
return new SimpleHttpRequest(Methods.DELETE, uri); return new SimpleHttpRequest(Method.DELETE, uri);
} }
@Override @Override
public SimpleHttpRequest create(final HttpHost host, final String path) { public SimpleHttpRequest create(final HttpHost host, final String path) {
return new SimpleHttpRequest(Methods.DELETE, host, path); return new SimpleHttpRequest(Method.DELETE, host, path);
} }
}, },
GET { GET {
@Override @Override
public SimpleHttpRequest create(final URI uri) { public SimpleHttpRequest create(final URI uri) {
return new SimpleHttpRequest(Methods.GET, uri); return new SimpleHttpRequest(Method.GET, uri);
} }
@Override @Override
public SimpleHttpRequest create(final HttpHost host, final String path) { public SimpleHttpRequest create(final HttpHost host, final String path) {
return new SimpleHttpRequest(Methods.GET, host, path); return new SimpleHttpRequest(Method.GET, host, path);
} }
}, },
HEAD { HEAD {
@Override @Override
public SimpleHttpRequest create(final URI uri) { public SimpleHttpRequest create(final URI uri) {
return new SimpleHttpRequest(Methods.HEAD, uri); return new SimpleHttpRequest(Method.HEAD, uri);
} }
@Override @Override
public SimpleHttpRequest create(final HttpHost host, final String path) { public SimpleHttpRequest create(final HttpHost host, final String path) {
return new SimpleHttpRequest(Methods.HEAD, host, path); return new SimpleHttpRequest(Method.HEAD, host, path);
} }
}, },
OPTIONS { OPTIONS {
@Override @Override
public SimpleHttpRequest create(final URI uri) { public SimpleHttpRequest create(final URI uri) {
return new SimpleHttpRequest(Methods.OPTIONS, uri); return new SimpleHttpRequest(Method.OPTIONS, uri);
} }
@Override @Override
public SimpleHttpRequest create(final HttpHost host, final String path) { public SimpleHttpRequest create(final HttpHost host, final String path) {
return new SimpleHttpRequest(Methods.OPTIONS, host, path); return new SimpleHttpRequest(Method.OPTIONS, host, path);
} }
}, },
PATCH { PATCH {
@Override @Override
public SimpleHttpRequest create(final URI uri) { public SimpleHttpRequest create(final URI uri) {
return new SimpleHttpRequest(Methods.PATCH, uri); return new SimpleHttpRequest(Method.PATCH, uri);
} }
@Override @Override
public SimpleHttpRequest create(final HttpHost host, final String path) { public SimpleHttpRequest create(final HttpHost host, final String path) {
return new SimpleHttpRequest(Methods.PATCH, host, path); return new SimpleHttpRequest(Method.PATCH, host, path);
} }
}, },
POST { POST {
@Override @Override
public SimpleHttpRequest create(final URI uri) { public SimpleHttpRequest create(final URI uri) {
return new SimpleHttpRequest(Methods.POST, uri); return new SimpleHttpRequest(Method.POST, uri);
} }
@Override @Override
public SimpleHttpRequest create(final HttpHost host, final String path) { public SimpleHttpRequest create(final HttpHost host, final String path) {
return new SimpleHttpRequest(Methods.POST, host, path); return new SimpleHttpRequest(Method.POST, host, path);
} }
}, },
PUT { PUT {
@Override @Override
public SimpleHttpRequest create(final URI uri) { public SimpleHttpRequest create(final URI uri) {
return new SimpleHttpRequest(Methods.PUT, uri); return new SimpleHttpRequest(Method.PUT, uri);
} }
@Override @Override
public SimpleHttpRequest create(final HttpHost host, final String path) { public SimpleHttpRequest create(final HttpHost host, final String path) {
return new SimpleHttpRequest(Methods.PUT, host, path); return new SimpleHttpRequest(Method.PUT, host, path);
} }
}, },
TRACE { TRACE {
@Override @Override
public SimpleHttpRequest create(final URI uri) { public SimpleHttpRequest create(final URI uri) {
return new SimpleHttpRequest(Methods.TRACE, uri); return new SimpleHttpRequest(Method.TRACE, uri);
} }
@Override @Override
public SimpleHttpRequest create(final HttpHost host, final String path) { public SimpleHttpRequest create(final HttpHost host, final String path) {
return new SimpleHttpRequest(Methods.TRACE, host, path); return new SimpleHttpRequest(Method.TRACE, host, path);
} }
}; };

View File

@ -69,7 +69,7 @@ public class DefaultConnectionKeepAliveStrategy implements ConnectionKeepAliveSt
} }
} }
} }
return TimeValue.NEG_ONE_MILLISECONDS; return TimeValue.NEG_ONE_MILLISECOND;
} }
} }

View File

@ -50,7 +50,7 @@ import org.apache.hc.core5.http.HttpHeaders;
import org.apache.hc.core5.http.HttpRequest; import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.HttpStatus; import org.apache.hc.core5.http.HttpStatus;
import org.apache.hc.core5.http.Methods; import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.http.protocol.HttpContext; import org.apache.hc.core5.http.protocol.HttpContext;
import org.apache.hc.core5.util.Args; import org.apache.hc.core5.util.Args;
import org.apache.hc.core5.util.TimeValue; import org.apache.hc.core5.util.TimeValue;
@ -226,7 +226,7 @@ public class DefaultHttpRequestRetryStrategy implements HttpRequestRetryStrategy
} }
protected boolean handleAsIdempotent(final HttpRequest request) { protected boolean handleAsIdempotent(final HttpRequest request) {
return Methods.isIdempotent(request.getMethod()); return Method.isIdempotent(request.getMethod());
} }
} }

View File

@ -95,7 +95,7 @@ public final class IdleConnectionEvictor {
} }
public void awaitTermination(final Timeout timeout) throws InterruptedException { public void awaitTermination(final Timeout timeout) throws InterruptedException {
thread.join(timeout != null ? timeout.toMillis() : Long.MAX_VALUE); thread.join(timeout != null ? timeout.toMilliseconds() : Long.MAX_VALUE);
} }
} }

View File

@ -57,7 +57,7 @@ import org.apache.hc.core5.http.HttpHeaders;
import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequest; import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.Methods; import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.http.ProtocolException; import org.apache.hc.core5.http.ProtocolException;
import org.apache.hc.core5.http.nio.AsyncDataConsumer; import org.apache.hc.core5.http.nio.AsyncDataConsumer;
import org.apache.hc.core5.http.nio.AsyncEntityProducer; import org.apache.hc.core5.http.nio.AsyncEntityProducer;
@ -181,7 +181,7 @@ public final class AsyncProtocolExec implements AsyncExecChainHandler {
clientContext.setAttribute(HttpCoreContext.HTTP_RESPONSE, response); clientContext.setAttribute(HttpCoreContext.HTTP_RESPONSE, response);
httpProcessor.process(response, entityDetails, clientContext); httpProcessor.process(response, entityDetails, clientContext);
if (Methods.TRACE.isSame(request.getMethod())) { if (Method.TRACE.isSame(request.getMethod())) {
// Do not perform authentication for TRACE request // Do not perform authentication for TRACE request
return asyncExecCallback.handleResponse(response, entityDetails); return asyncExecCallback.handleResponse(response, entityDetails);
} }

View File

@ -51,7 +51,7 @@ import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequest; import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.HttpStatus; import org.apache.hc.core5.http.HttpStatus;
import org.apache.hc.core5.http.Methods; import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.http.ProtocolException; import org.apache.hc.core5.http.ProtocolException;
import org.apache.hc.core5.http.message.BasicHttpRequest; import org.apache.hc.core5.http.message.BasicHttpRequest;
import org.apache.hc.core5.http.nio.AsyncDataConsumer; import org.apache.hc.core5.http.nio.AsyncDataConsumer;
@ -143,8 +143,8 @@ public final class AsyncRedirectExec implements AsyncExecChainHandler {
case HttpStatus.SC_MOVED_PERMANENTLY: case HttpStatus.SC_MOVED_PERMANENTLY:
case HttpStatus.SC_MOVED_TEMPORARILY: case HttpStatus.SC_MOVED_TEMPORARILY:
case HttpStatus.SC_SEE_OTHER: case HttpStatus.SC_SEE_OTHER:
if (!Methods.isSafe(request.getMethod())) { if (!Method.isSafe(request.getMethod())) {
state.currentRequest = new BasicHttpRequest(Methods.GET, redirectUri); state.currentRequest = new BasicHttpRequest(Method.GET, redirectUri);
state.currentEntityProducer = null; state.currentEntityProducer = null;
} }
} }

View File

@ -75,7 +75,7 @@ class InternalHttpAsyncExecRuntime implements AsyncExecRuntime {
this.pushHandlerFactory = pushHandlerFactory; this.pushHandlerFactory = pushHandlerFactory;
this.versionPolicy = versionPolicy; this.versionPolicy = versionPolicy;
this.endpointRef = new AtomicReference<>(null); this.endpointRef = new AtomicReference<>(null);
this.validDuration = TimeValue.NEG_ONE_MILLISECONDS; this.validDuration = TimeValue.NEG_ONE_MILLISECOND;
} }
@Override @Override

View File

@ -162,7 +162,7 @@ class LoggingIOSession implements IOSession {
} }
@Override @Override
public int getStatus() { public Status getStatus() {
return this.session.getStatus(); return this.session.getStatus();
} }

View File

@ -478,7 +478,7 @@ public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClient
@Override @Override
public void releaseAndReuse() { public void releaseAndReuse() {
if (released.compareAndSet(false, true)) { if (released.compareAndSet(false, true)) {
manager.release(connectionEndpoint, null, TimeValue.NEG_ONE_MILLISECONDS); manager.release(connectionEndpoint, null, TimeValue.NEG_ONE_MILLISECOND);
} }
} }

View File

@ -91,7 +91,7 @@ public class AIMDBackoffManager implements BackoffManager {
final int curr = connPerRoute.getMaxPerRoute(route); final int curr = connPerRoute.getMaxPerRoute(route);
final Long lastUpdate = getLastUpdate(lastRouteBackoffs, route); final Long lastUpdate = getLastUpdate(lastRouteBackoffs, route);
final long now = clock.getCurrentTime(); final long now = clock.getCurrentTime();
if (now - lastUpdate.longValue() < coolDown.toMillis()) { if (now - lastUpdate.longValue() < coolDown.toMilliseconds()) {
return; return;
} }
connPerRoute.setMaxPerRoute(route, getBackedOffPoolSize(curr)); connPerRoute.setMaxPerRoute(route, getBackedOffPoolSize(curr));
@ -114,8 +114,8 @@ public class AIMDBackoffManager implements BackoffManager {
final Long lastProbe = getLastUpdate(lastRouteProbes, route); final Long lastProbe = getLastUpdate(lastRouteProbes, route);
final Long lastBackoff = getLastUpdate(lastRouteBackoffs, route); final Long lastBackoff = getLastUpdate(lastRouteBackoffs, route);
final long now = clock.getCurrentTime(); final long now = clock.getCurrentTime();
if (now - lastProbe.longValue() < coolDown.toMillis() if (now - lastProbe.longValue() < coolDown.toMilliseconds()
|| now - lastBackoff.longValue() < coolDown.toMillis()) { || now - lastBackoff.longValue() < coolDown.toMilliseconds()) {
return; return;
} }
connPerRoute.setMaxPerRoute(route, max); connPerRoute.setMaxPerRoute(route, max);

View File

@ -77,7 +77,7 @@ class InternalExecRuntime implements ExecRuntime, Cancellable {
this.requestExecutor = requestExecutor; this.requestExecutor = requestExecutor;
this.cancellableDependency = cancellableDependency; this.cancellableDependency = cancellableDependency;
this.endpointRef = new AtomicReference<>(null); this.endpointRef = new AtomicReference<>(null);
this.validDuration = TimeValue.NEG_ONE_MILLISECONDS; this.validDuration = TimeValue.NEG_ONE_MILLISECOND;
} }
@Override @Override

View File

@ -150,7 +150,7 @@ public class MinimalHttpClient extends CloseableHttpClient {
httpProcessor.process(response, response.getEntity(), context); httpProcessor.process(response, response.getEntity(), context);
if (reuseStrategy.keepAlive(request, response, context)) { if (reuseStrategy.keepAlive(request, response, context)) {
execRuntime.markConnectionReusable(null, TimeValue.NEG_ONE_MILLISECONDS); execRuntime.markConnectionReusable(null, TimeValue.NEG_ONE_MILLISECOND);
} else { } else {
execRuntime.markConnectionNonReusable(); execRuntime.markConnectionNonReusable();
} }

View File

@ -57,7 +57,7 @@ import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpHeaders; import org.apache.hc.core5.http.HttpHeaders;
import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.Methods; import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.http.ProtocolException; import org.apache.hc.core5.http.ProtocolException;
import org.apache.hc.core5.http.io.entity.EntityUtils; import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.protocol.HttpCoreContext; import org.apache.hc.core5.http.protocol.HttpCoreContext;
@ -167,7 +167,7 @@ public final class ProtocolExec implements ExecChainHandler {
context.setAttribute(HttpCoreContext.HTTP_RESPONSE, response); context.setAttribute(HttpCoreContext.HTTP_RESPONSE, response);
httpProcessor.process(response, response.getEntity(), context); httpProcessor.process(response, response.getEntity(), context);
if (Methods.TRACE.isSame(request.getMethod())) { if (Method.TRACE.isSame(request.getMethod())) {
// Do not perform authentication for TRACE request // Do not perform authentication for TRACE request
return response; return response;
} }

View File

@ -52,7 +52,7 @@ import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpStatus; import org.apache.hc.core5.http.HttpStatus;
import org.apache.hc.core5.http.Methods; import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.http.ProtocolException; import org.apache.hc.core5.http.ProtocolException;
import org.apache.hc.core5.http.io.entity.EntityUtils; import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.message.BasicClassicHttpRequest; import org.apache.hc.core5.http.message.BasicClassicHttpRequest;
@ -146,7 +146,7 @@ public final class RedirectExec implements ExecChainHandler {
case HttpStatus.SC_MOVED_PERMANENTLY: case HttpStatus.SC_MOVED_PERMANENTLY:
case HttpStatus.SC_MOVED_TEMPORARILY: case HttpStatus.SC_MOVED_TEMPORARILY:
case HttpStatus.SC_SEE_OTHER: case HttpStatus.SC_SEE_OTHER:
if (!Methods.isSafe(request.getMethod())) { if (!Method.isSafe(request.getMethod())) {
redirect = new HttpGet(redirectUri); redirect = new HttpGet(redirectUri);
} }
} }

View File

@ -280,7 +280,7 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
if (this.log.isDebugEnabled()) { if (this.log.isDebugEnabled()) {
this.log.debug("Connection can be kept alive for " + keepAlive); this.log.debug("Connection can be kept alive for " + keepAlive);
} }
this.expiry = this.updated + keepAlive.toMillis(); this.expiry = this.updated + keepAlive.toMilliseconds();
} else { } else {
if (this.log.isDebugEnabled()) { if (this.log.isDebugEnabled()) {
this.log.debug("Connection can be kept alive indefinitely"); this.log.debug("Connection can be kept alive indefinitely");
@ -345,7 +345,7 @@ public class BasicHttpClientConnectionManager implements HttpClientConnectionMan
return; return;
} }
if (!this.leased) { if (!this.leased) {
long time = idleTime.toMillis(); long time = idleTime.toMilliseconds();
if (time < 0) { if (time < 0) {
time = 0; time = 0;
} }

View File

@ -123,7 +123,7 @@ public class DefaultHttpClientConnectionOperator implements HttpClientConnection
final boolean last = i == addresses.length - 1; final boolean last = i == addresses.length - 1;
Socket sock = sf.createSocket(context); Socket sock = sf.createSocket(context);
sock.setSoTimeout(socketConfig.getSoTimeout().toMillisIntBound()); sock.setSoTimeout(socketConfig.getSoTimeout().toMillisecondsIntBound());
sock.setReuseAddress(socketConfig.isSoReuseAddress()); sock.setReuseAddress(socketConfig.isSoReuseAddress());
sock.setTcpNoDelay(socketConfig.isTcpNoDelay()); sock.setTcpNoDelay(socketConfig.isTcpNoDelay());
sock.setKeepAlive(socketConfig.isSoKeepAlive()); sock.setKeepAlive(socketConfig.isSoKeepAlive());
@ -134,7 +134,7 @@ public class DefaultHttpClientConnectionOperator implements HttpClientConnection
sock.setSendBufferSize(socketConfig.getSndBufSize()); sock.setSendBufferSize(socketConfig.getSndBufSize());
} }
final int linger = socketConfig.getSoLinger().toMillisIntBound(); final int linger = socketConfig.getSoLinger().toMillisecondsIntBound();
if (linger >= 0) { if (linger >= 0) {
sock.setSoLinger(true, linger); sock.setSoLinger(true, linger);
} }

View File

@ -136,7 +136,7 @@ public class PoolingHttpClientConnectionManager
public PoolingHttpClientConnectionManager( public PoolingHttpClientConnectionManager(
final Registry<ConnectionSocketFactory> socketFactoryRegistry, final Registry<ConnectionSocketFactory> socketFactoryRegistry,
final HttpConnectionFactory<ManagedHttpClientConnection> connFactory) { final HttpConnectionFactory<ManagedHttpClientConnection> connFactory) {
this(socketFactoryRegistry, PoolConcurrencyPolicy.STRICT, TimeValue.NEG_ONE_MILLISECONDS, connFactory); this(socketFactoryRegistry, PoolConcurrencyPolicy.STRICT, TimeValue.NEG_ONE_MILLISECOND, connFactory);
} }
public PoolingHttpClientConnectionManager( public PoolingHttpClientConnectionManager(
@ -290,7 +290,7 @@ public class PoolingHttpClientConnectionManager
if (TimeValue.isNonNegative(validateAfterInactivity)) { if (TimeValue.isNonNegative(validateAfterInactivity)) {
final ManagedHttpClientConnection conn = poolEntry.getConnection(); final ManagedHttpClientConnection conn = poolEntry.getConnection();
if (conn != null if (conn != null
&& poolEntry.getUpdated() + validateAfterInactivity.toMillis() <= System.currentTimeMillis()) { && poolEntry.getUpdated() + validateAfterInactivity.toMilliseconds() <= System.currentTimeMillis()) {
boolean stale; boolean stale;
try { try {
stale = conn.isStale(); stale = conn.isStale();

View File

@ -208,7 +208,7 @@ public class PoolingHttpClientConnectionManagerBuilder {
.build(), .build(),
poolConcurrencyPolicy, poolConcurrencyPolicy,
poolReusePolicy, poolReusePolicy,
timeToLive != null ? timeToLive : TimeValue.NEG_ONE_MILLISECONDS, timeToLive != null ? timeToLive : TimeValue.NEG_ONE_MILLISECOND,
schemePortResolver, schemePortResolver,
dnsResolver, dnsResolver,
connectionFactory); connectionFactory);

View File

@ -121,7 +121,7 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
} }
public PoolingAsyncClientConnectionManager(final Lookup<TlsStrategy> tlsStrategyLookup) { public PoolingAsyncClientConnectionManager(final Lookup<TlsStrategy> tlsStrategyLookup) {
this(tlsStrategyLookup, PoolConcurrencyPolicy.STRICT, TimeValue.NEG_ONE_MILLISECONDS); this(tlsStrategyLookup, PoolConcurrencyPolicy.STRICT, TimeValue.NEG_ONE_MILLISECOND);
} }
public PoolingAsyncClientConnectionManager( public PoolingAsyncClientConnectionManager(
@ -246,7 +246,7 @@ public class PoolingAsyncClientConnectionManager implements AsyncClientConnectio
final ManagedAsyncClientConnection connection = poolEntry.getConnection(); final ManagedAsyncClientConnection connection = poolEntry.getConnection();
final TimeValue timeValue = PoolingAsyncClientConnectionManager.this.validateAfterInactivity; final TimeValue timeValue = PoolingAsyncClientConnectionManager.this.validateAfterInactivity;
if (TimeValue.isPositive(timeValue) && connection != null && if (TimeValue.isPositive(timeValue) && connection != null &&
poolEntry.getUpdated() + timeValue.toMillis() <= System.currentTimeMillis()) { poolEntry.getUpdated() + timeValue.toMilliseconds() <= System.currentTimeMillis()) {
final ProtocolVersion protocolVersion = connection.getProtocolVersion(); final ProtocolVersion protocolVersion = connection.getProtocolVersion();
if (HttpVersion.HTTP_2_0.greaterEquals(protocolVersion)) { if (HttpVersion.HTTP_2_0.greaterEquals(protocolVersion)) {
connection.submitCommand(new PingCommand(new BasicPingHandler(new Callback<Boolean>() { connection.submitCommand(new PingCommand(new BasicPingHandler(new Callback<Boolean>() {

View File

@ -84,7 +84,7 @@ public class PlainConnectionSocketFactory implements ConnectionSocketFactory {
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() { AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
@Override @Override
public Object run() throws IOException { public Object run() throws IOException {
sock.connect(remoteAddress, TimeValue.isPositive(connectTimeout) ? connectTimeout.toMillisIntBound() : 0); sock.connect(remoteAddress, TimeValue.isPositive(connectTimeout) ? connectTimeout.toMillisecondsIntBound() : 0);
return null; return null;
} }
}); });

View File

@ -45,7 +45,7 @@ import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
import org.apache.hc.core5.http.ssl.TLS; import org.apache.hc.core5.http.ssl.TLS;
import org.apache.hc.core5.http.ssl.TlsCiphers; import org.apache.hc.core5.http.ssl.TlsCiphers;
import org.apache.hc.core5.http2.HttpVersionPolicy; import org.apache.hc.core5.http2.HttpVersionPolicy;
import org.apache.hc.core5.http2.ssl.ApplicationProtocols; import org.apache.hc.core5.http2.ssl.ApplicationProtocol;
import org.apache.hc.core5.http2.ssl.H2TlsSupport; import org.apache.hc.core5.http2.ssl.H2TlsSupport;
import org.apache.hc.core5.net.NamedEndpoint; import org.apache.hc.core5.net.NamedEndpoint;
import org.apache.hc.core5.reactor.ssl.SSLBufferMode; import org.apache.hc.core5.reactor.ssl.SSLBufferMode;
@ -134,7 +134,7 @@ abstract class AbstractClientTlsStrategy implements TlsStrategy {
verifySession(host.getHostName(), sslEngine.getSession()); verifySession(host.getHostName(), sslEngine.getSession());
final TlsDetails tlsDetails = createTlsDetails(sslEngine); final TlsDetails tlsDetails = createTlsDetails(sslEngine);
final String negotiatedCipherSuite = sslEngine.getSession().getCipherSuite(); final String negotiatedCipherSuite = sslEngine.getSession().getCipherSuite();
if (tlsDetails != null && ApplicationProtocols.HTTP_2.id.equals(tlsDetails.getApplicationProtocol())) { if (tlsDetails != null && ApplicationProtocol.HTTP_2.id.equals(tlsDetails.getApplicationProtocol())) {
if (TlsCiphers.isH2Blacklisted(negotiatedCipherSuite)) { if (TlsCiphers.isH2Blacklisted(negotiatedCipherSuite)) {
throw new SSLHandshakeException("Cipher suite `" + negotiatedCipherSuite throw new SSLHandshakeException("Cipher suite `" + negotiatedCipherSuite
+ "` does not provide adequate security for HTTP/2"); + "` does not provide adequate security for HTTP/2");

View File

@ -102,7 +102,7 @@ public class ClientTlsStrategyBuilder {
public final ClientTlsStrategyBuilder setTlsVersions(final TLS... tlslVersions) { public final ClientTlsStrategyBuilder setTlsVersions(final TLS... tlslVersions) {
this.tlsVersions = new String[tlslVersions.length]; this.tlsVersions = new String[tlslVersions.length];
for (int i = 0; i < tlslVersions.length; i++) { for (int i = 0; i < tlslVersions.length; i++) {
this.tlsVersions[i] = tlslVersions[i].ident; this.tlsVersions[i] = tlslVersions[i].id;
} }
return this; return this;
} }

View File

@ -208,7 +208,7 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor
} }
try { try {
if (TimeValue.isPositive(connectTimeout) && sock.getSoTimeout() == 0) { if (TimeValue.isPositive(connectTimeout) && sock.getSoTimeout() == 0) {
sock.setSoTimeout(connectTimeout.toMillisIntBound()); sock.setSoTimeout(connectTimeout.toMillisecondsIntBound());
} }
if (this.log.isDebugEnabled()) { if (this.log.isDebugEnabled()) {
this.log.debug("Connecting socket to " + remoteAddress + " with timeout " + connectTimeout); this.log.debug("Connecting socket to " + remoteAddress + " with timeout " + connectTimeout);
@ -219,7 +219,7 @@ public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactor
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() { AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
@Override @Override
public Object run() throws IOException { public Object run() throws IOException {
sock.connect(remoteAddress, connectTimeout != null ? connectTimeout.toMillisIntBound() : 0); sock.connect(remoteAddress, connectTimeout != null ? connectTimeout.toMillisecondsIntBound() : 0);
return null; return null;
} }
}); });

View File

@ -93,7 +93,7 @@ public class SSLConnectionSocketFactoryBuilder {
public final SSLConnectionSocketFactoryBuilder setTlsVersions(final TLS... tlslVersions) { public final SSLConnectionSocketFactoryBuilder setTlsVersions(final TLS... tlslVersions) {
this.tlsVersions = new String[tlslVersions.length]; this.tlsVersions = new String[tlslVersions.length];
for (int i = 0; i < tlslVersions.length; i++) { for (int i = 0; i < tlslVersions.length; i++) {
this.tlsVersions[i] = tlslVersions[i].ident; this.tlsVersions[i] = tlslVersions[i].id;
} }
return this; return this;
} }

View File

@ -45,7 +45,7 @@ public class TestCookieOrigin {
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
@Test(expected=IllegalArgumentException.class) @Test(expected=NullPointerException.class)
public void testNullHost() { public void testNullHost() {
new CookieOrigin(null, 80, "/", false); new CookieOrigin(null, 80, "/", false);
} }
@ -63,7 +63,7 @@ public class TestCookieOrigin {
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
@Test(expected=IllegalArgumentException.class) @Test(expected=NullPointerException.class)
public void testNullPath() { public void testNullPath() {
new CookieOrigin("www.apache.org", 80, null, false); new CookieOrigin("www.apache.org", 80, null, false);
} }

View File

@ -41,7 +41,7 @@ import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpRequest; import org.apache.hc.core5.http.HttpRequest;
import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.Methods; import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.http.message.StatusLine; import org.apache.hc.core5.http.message.StatusLine;
import org.apache.hc.core5.http.nio.AsyncPushConsumer; import org.apache.hc.core5.http.nio.AsyncPushConsumer;
import org.apache.hc.core5.http.nio.support.BasicRequestProducer; import org.apache.hc.core5.http.nio.support.BasicRequestProducer;
@ -118,7 +118,7 @@ public class AsyncClientH2ServerPush {
final HttpHost target = new HttpHost("nghttp2.org"); final HttpHost target = new HttpHost("nghttp2.org");
final String requestURI = "/httpbin/"; final String requestURI = "/httpbin/";
final Future<Void> future = client.execute( final Future<Void> future = client.execute(
new BasicRequestProducer(Methods.GET, target, requestURI), new BasicRequestProducer(Method.GET, target, requestURI),
new AbstractCharResponseConsumer<Void>() { new AbstractCharResponseConsumer<Void>() {
@Override @Override

View File

@ -37,7 +37,7 @@ import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.HttpResponse; import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.Methods; import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.http.message.StatusLine; import org.apache.hc.core5.http.message.StatusLine;
import org.apache.hc.core5.http.nio.support.BasicRequestProducer; import org.apache.hc.core5.http.nio.support.BasicRequestProducer;
import org.apache.hc.core5.io.CloseMode; import org.apache.hc.core5.io.CloseMode;
@ -66,7 +66,7 @@ public class AsyncClientHttpExchangeStreaming {
for (final String requestUri: requestUris) { for (final String requestUri: requestUris) {
final Future<Void> future = client.execute( final Future<Void> future = client.execute(
new BasicRequestProducer(Methods.GET, target, requestUri), new BasicRequestProducer(Method.GET, target, requestUri),
new AbstractCharResponseConsumer<Void>() { new AbstractCharResponseConsumer<Void>() {
@Override @Override

View File

@ -104,7 +104,7 @@ public class ClientExecuteSOCKS {
if (localAddress != null) { if (localAddress != null) {
sock.bind(localAddress); sock.bind(localAddress);
} }
sock.connect(remoteAddress, connectTimeout != null ? connectTimeout.toMillisIntBound() : 0); sock.connect(remoteAddress, connectTimeout != null ? connectTimeout.toMillisecondsIntBound() : 0);
return sock; return sock;
} }

View File

@ -64,18 +64,18 @@ public class TestAuthenticationStrategy {
final HttpClientContext context = HttpClientContext.create(); final HttpClientContext context = HttpClientContext.create();
try { try {
authStrategy.select(null, Collections.<String, AuthChallenge>emptyMap(), context); authStrategy.select(null, Collections.<String, AuthChallenge>emptyMap(), context);
Assert.fail("IllegalArgumentException expected"); Assert.fail("NullPointerException expected");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
} }
try { try {
authStrategy.select(ChallengeType.TARGET, null, context); authStrategy.select(ChallengeType.TARGET, null, context);
Assert.fail("IllegalArgumentException expected"); Assert.fail("NullPointerException expected");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
} }
try { try {
authStrategy.select(ChallengeType.TARGET, Collections.<String, AuthChallenge>emptyMap(), null); authStrategy.select(ChallengeType.TARGET, Collections.<String, AuthChallenge>emptyMap(), null);
Assert.fail("IllegalArgumentException expected"); Assert.fail("NullPointerException expected");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
} }
} }

View File

@ -41,7 +41,7 @@ import org.junit.Test;
*/ */
public class TestDefaultConnKeepAliveStrategy { public class TestDefaultConnKeepAliveStrategy {
@Test(expected=IllegalArgumentException.class) @Test(expected=NullPointerException.class)
public void testIllegalResponseArg() throws Exception { public void testIllegalResponseArg() throws Exception {
final HttpContext context = new BasicHttpContext(null); final HttpContext context = new BasicHttpContext(null);
final ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy(); final ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy();
@ -54,7 +54,7 @@ public class TestDefaultConnKeepAliveStrategy {
final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_OK); final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_OK);
final ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy(); final ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy();
final TimeValue d = keepAliveStrat.getKeepAliveDuration(response, context); final TimeValue d = keepAliveStrat.getKeepAliveDuration(response, context);
Assert.assertEquals(TimeValue.NEG_ONE_MILLISECONDS, d); Assert.assertEquals(TimeValue.NEG_ONE_MILLISECOND, d);
} }
@Test @Test
@ -64,7 +64,7 @@ public class TestDefaultConnKeepAliveStrategy {
response.addHeader("Keep-Alive", "timeout, max=20"); response.addHeader("Keep-Alive", "timeout, max=20");
final ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy(); final ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy();
final TimeValue d = keepAliveStrat.getKeepAliveDuration(response, context); final TimeValue d = keepAliveStrat.getKeepAliveDuration(response, context);
Assert.assertEquals(TimeValue.NEG_ONE_MILLISECONDS, d); Assert.assertEquals(TimeValue.NEG_ONE_MILLISECOND, d);
} }
@Test @Test
@ -74,7 +74,7 @@ public class TestDefaultConnKeepAliveStrategy {
response.addHeader("Keep-Alive", "timeout=whatever, max=20"); response.addHeader("Keep-Alive", "timeout=whatever, max=20");
final ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy(); final ConnectionKeepAliveStrategy keepAliveStrat = new DefaultConnectionKeepAliveStrategy();
final TimeValue d = keepAliveStrat.getKeepAliveDuration(response, context); final TimeValue d = keepAliveStrat.getKeepAliveDuration(response, context);
Assert.assertEquals(TimeValue.NEG_ONE_MILLISECONDS, d); Assert.assertEquals(TimeValue.NEG_ONE_MILLISECOND, d);
} }
@Test @Test

View File

@ -114,13 +114,13 @@ public class TestDefaultRedirectStrategy {
final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_SEE_OTHER, "Redirect"); final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_SEE_OTHER, "Redirect");
try { try {
redirectStrategy.isRedirected(null, response, context); redirectStrategy.isRedirected(null, response, context);
Assert.fail("IllegalArgumentException expected"); Assert.fail("NullPointerException expected");
} catch (final IllegalArgumentException expected) { } catch (final NullPointerException expected) {
} }
try { try {
redirectStrategy.isRedirected(httpget, null, context); redirectStrategy.isRedirected(httpget, null, context);
Assert.fail("IllegalArgumentException expected"); Assert.fail("NullPointerException expected");
} catch (final IllegalArgumentException expected) { } catch (final NullPointerException expected) {
} }
} }
@ -207,18 +207,18 @@ public class TestDefaultRedirectStrategy {
response.addHeader("Location", "http://localhost/stuff"); response.addHeader("Location", "http://localhost/stuff");
try { try {
redirectStrategy.getLocationURI(null, response, context); redirectStrategy.getLocationURI(null, response, context);
Assert.fail("IllegalArgumentException expected"); Assert.fail("NullPointerException expected");
} catch (final IllegalArgumentException expected) { } catch (final NullPointerException expected) {
} }
try { try {
redirectStrategy.getLocationURI(httpget, null, context); redirectStrategy.getLocationURI(httpget, null, context);
Assert.fail("IllegalArgumentException expected"); Assert.fail("NullPointerException expected");
} catch (final IllegalArgumentException expected) { } catch (final NullPointerException expected) {
} }
try { try {
redirectStrategy.getLocationURI(httpget, response, null); redirectStrategy.getLocationURI(httpget, response, null);
Assert.fail("IllegalArgumentException expected"); Assert.fail("NullPointerException expected");
} catch (final IllegalArgumentException expected) { } catch (final NullPointerException expected) {
} }
} }

View File

@ -51,7 +51,7 @@ public class TestBasicAuthCache {
Assert.assertNull(cache.get(new HttpHost("localhost", 80))); Assert.assertNull(cache.get(new HttpHost("localhost", 80)));
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = NullPointerException.class)
public void testNullKey() throws Exception { public void testNullKey() throws Exception {
final BasicAuthCache cache = new BasicAuthCache(); final BasicAuthCache cache = new BasicAuthCache();
final AuthScheme authScheme = new BasicScheme(); final AuthScheme authScheme = new BasicScheme();

View File

@ -157,18 +157,18 @@ public class TestDigestScheme {
try { try {
authscheme.isResponseReady(null, credentialsProvider, null); authscheme.isResponseReady(null, credentialsProvider, null);
Assert.fail("IllegalArgumentException should have been thrown"); Assert.fail("NullPointerException should have been thrown");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
} }
try { try {
authscheme.isResponseReady(host, null, null); authscheme.isResponseReady(host, null, null);
Assert.fail("IllegalArgumentException should have been thrown"); Assert.fail("NullPointerException should have been thrown");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
} }
try { try {
authscheme.generateAuthResponse(host, null, null); authscheme.generateAuthResponse(host, null, null);
Assert.fail("IllegalArgumentException should have been thrown"); Assert.fail("NullPointerException should have been thrown");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
} }
} }

View File

@ -71,14 +71,14 @@ public class TestRequestAuthCache {
this.credProvider.setCredentials(this.authscope2, this.creds2); this.credProvider.setCredentials(this.authscope2, this.creds2);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected=NullPointerException.class)
public void testRequestParameterCheck() throws Exception { public void testRequestParameterCheck() throws Exception {
final HttpClientContext context = HttpClientContext.create(); final HttpClientContext context = HttpClientContext.create();
final HttpRequestInterceptor interceptor = new RequestAuthCache(); final HttpRequestInterceptor interceptor = new RequestAuthCache();
interceptor.process(null, null, context); interceptor.process(null, null, context);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected=NullPointerException.class)
public void testContextParameterCheck() throws Exception { public void testContextParameterCheck() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/"); final HttpRequest request = new BasicHttpRequest("GET", "/");
final HttpRequestInterceptor interceptor = new RequestAuthCache(); final HttpRequestInterceptor interceptor = new RequestAuthCache();

View File

@ -39,7 +39,7 @@ import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.HttpEntity; import org.apache.hc.core5.http.HttpEntity;
import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpException;
import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.Methods; import org.apache.hc.core5.http.Method;
import org.apache.hc.core5.http.io.entity.StringEntity; import org.apache.hc.core5.http.io.entity.StringEntity;
import org.apache.hc.core5.http.message.BasicClassicHttpRequest; import org.apache.hc.core5.http.message.BasicClassicHttpRequest;
import org.apache.hc.core5.http.message.BasicClassicHttpResponse; import org.apache.hc.core5.http.message.BasicClassicHttpResponse;
@ -77,7 +77,7 @@ public class TestContentCompressionExec {
@Test @Test
public void testContentEncodingNoEntity() throws Exception { public void testContentEncodingNoEntity() throws Exception {
final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/"); final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/");
final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
Mockito.when(execChain.proceed(request, scope)).thenReturn(response); Mockito.when(execChain.proceed(request, scope)).thenReturn(response);
@ -90,7 +90,7 @@ public class TestContentCompressionExec {
@Test @Test
public void testNoContentEncoding() throws Exception { public void testNoContentEncoding() throws Exception {
final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/"); final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/");
final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
final StringEntity original = new StringEntity("plain stuff"); final StringEntity original = new StringEntity("plain stuff");
response.setEntity(original); response.setEntity(original);
@ -106,7 +106,7 @@ public class TestContentCompressionExec {
@Test @Test
public void testGzipContentEncoding() throws Exception { public void testGzipContentEncoding() throws Exception {
final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/"); final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/");
final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("GZip").build(); final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("GZip").build();
response.setEntity(original); response.setEntity(original);
@ -122,7 +122,7 @@ public class TestContentCompressionExec {
@Test @Test
public void testGzipContentEncodingZeroLength() throws Exception { public void testGzipContentEncodingZeroLength() throws Exception {
final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/"); final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/");
final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
final HttpEntity original = EntityBuilder.create().setText("").setContentEncoding("GZip").build(); final HttpEntity original = EntityBuilder.create().setText("").setContentEncoding("GZip").build();
response.setEntity(original); response.setEntity(original);
@ -138,7 +138,7 @@ public class TestContentCompressionExec {
@Test @Test
public void testXGzipContentEncoding() throws Exception { public void testXGzipContentEncoding() throws Exception {
final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/"); final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/");
final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("x-gzip").build(); final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("x-gzip").build();
response.setEntity(original); response.setEntity(original);
@ -154,7 +154,7 @@ public class TestContentCompressionExec {
@Test @Test
public void testDeflateContentEncoding() throws Exception { public void testDeflateContentEncoding() throws Exception {
final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/"); final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/");
final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("deFlaTe").build(); final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("deFlaTe").build();
response.setEntity(original); response.setEntity(original);
@ -170,7 +170,7 @@ public class TestContentCompressionExec {
@Test @Test
public void testIdentityContentEncoding() throws Exception { public void testIdentityContentEncoding() throws Exception {
final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/"); final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/");
final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("identity").build(); final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("identity").build();
response.setEntity(original); response.setEntity(original);
@ -186,7 +186,7 @@ public class TestContentCompressionExec {
@Test(expected=HttpException.class) @Test(expected=HttpException.class)
public void testUnknownContentEncoding() throws Exception { public void testUnknownContentEncoding() throws Exception {
final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/"); final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/");
final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("whatever").build(); final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("whatever").build();
response.setEntity(original); response.setEntity(original);
@ -200,7 +200,7 @@ public class TestContentCompressionExec {
@Test @Test
public void testContentEncodingRequestParameter() throws Exception { public void testContentEncodingRequestParameter() throws Exception {
final ClassicHttpRequest request = new BasicClassicHttpRequest(Methods.GET, host, "/"); final ClassicHttpRequest request = new BasicClassicHttpRequest(Method.GET, host, "/");
final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK"); final ClassicHttpResponse response = new BasicClassicHttpResponse(200, "OK");
final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("GZip").build(); final HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("GZip").build();
response.setEntity(original); response.setEntity(original);

View File

@ -48,8 +48,8 @@ public class TestBasicClientCookie {
Assert.assertEquals("value", cookie.getValue()); Assert.assertEquals("value", cookie.getValue());
try { try {
new BasicClientCookie(null, null); new BasicClientCookie(null, null);
Assert.fail("IllegalArgumentException should have been thrown"); Assert.fail("NullPointerException should have been thrown");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
//expected //expected
} }
} }

View File

@ -193,32 +193,32 @@ public class TestBasicCookieAttribHandlers {
final CookieAttributeHandler h = new BasicDomainHandler(); final CookieAttributeHandler h = new BasicDomainHandler();
try { try {
h.parse(null, null); h.parse(null, null);
Assert.fail("IllegalArgumentException must have been thrown"); Assert.fail("NullPointerException must have been thrown");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
// expected // expected
} }
try { try {
h.validate(null, null); h.validate(null, null);
Assert.fail("IllegalArgumentException must have been thrown"); Assert.fail("NullPointerException must have been thrown");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
// expected // expected
} }
try { try {
h.validate(new BasicClientCookie("name", "value"), null); h.validate(new BasicClientCookie("name", "value"), null);
Assert.fail("IllegalArgumentException must have been thrown"); Assert.fail("NullPointerException must have been thrown");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
// expected // expected
} }
try { try {
h.match(null, null); h.match(null, null);
Assert.fail("IllegalArgumentException must have been thrown"); Assert.fail("NullPointerException must have been thrown");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
// expected // expected
} }
try { try {
h.match(new BasicClientCookie("name", "value"), null); h.match(new BasicClientCookie("name", "value"), null);
Assert.fail("IllegalArgumentException must have been thrown"); Assert.fail("NullPointerException must have been thrown");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
// expected // expected
} }
} }
@ -302,20 +302,20 @@ public class TestBasicCookieAttribHandlers {
final CookieAttributeHandler h = new BasicPathHandler(); final CookieAttributeHandler h = new BasicPathHandler();
try { try {
h.parse(null, null); h.parse(null, null);
Assert.fail("IllegalArgumentException must have been thrown"); Assert.fail("NullPointerException must have been thrown");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
// expected // expected
} }
try { try {
h.match(null, null); h.match(null, null);
Assert.fail("IllegalArgumentException must have been thrown"); Assert.fail("NullPointerException must have been thrown");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
// expected // expected
} }
try { try {
h.match(new BasicClientCookie("name", "value"), null); h.match(new BasicClientCookie("name", "value"), null);
Assert.fail("IllegalArgumentException must have been thrown"); Assert.fail("NullPointerException must have been thrown");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
// expected // expected
} }
} }
@ -351,8 +351,8 @@ public class TestBasicCookieAttribHandlers {
final CookieAttributeHandler h = new BasicMaxAgeHandler(); final CookieAttributeHandler h = new BasicMaxAgeHandler();
try { try {
h.parse(null, null); h.parse(null, null);
Assert.fail("IllegalArgumentException must have been thrown"); Assert.fail("NullPointerException must have been thrown");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
// expected // expected
} }
} }
@ -390,20 +390,20 @@ public class TestBasicCookieAttribHandlers {
final CookieAttributeHandler h = new BasicSecureHandler(); final CookieAttributeHandler h = new BasicSecureHandler();
try { try {
h.parse(null, null); h.parse(null, null);
Assert.fail("IllegalArgumentException must have been thrown"); Assert.fail("NullPointerException must have been thrown");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
// expected // expected
} }
try { try {
h.match(null, null); h.match(null, null);
Assert.fail("IllegalArgumentException must have been thrown"); Assert.fail("NullPointerException must have been thrown");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
// expected // expected
} }
try { try {
h.match(new BasicClientCookie("name", "value"), null); h.match(new BasicClientCookie("name", "value"), null);
Assert.fail("IllegalArgumentException must have been thrown"); Assert.fail("NullPointerException must have been thrown");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
// expected // expected
} }
} }
@ -445,15 +445,15 @@ public class TestBasicCookieAttribHandlers {
public void testBasicExpiresInvalidInput() throws Exception { public void testBasicExpiresInvalidInput() throws Exception {
try { try {
new BasicExpiresHandler(null); new BasicExpiresHandler(null);
Assert.fail("IllegalArgumentException must have been thrown"); Assert.fail("NullPointerException must have been thrown");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
// expected // expected
} }
final CookieAttributeHandler h = new BasicExpiresHandler(new String[] {DateUtils.PATTERN_RFC1123}); final CookieAttributeHandler h = new BasicExpiresHandler(new String[] {DateUtils.PATTERN_RFC1123});
try { try {
h.parse(null, null); h.parse(null, null);
Assert.fail("IllegalArgumentException must have been thrown"); Assert.fail("NullPointerException must have been thrown");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
// expected // expected
} }
} }

View File

@ -82,8 +82,8 @@ public class TestLaxCookieAttribHandlers {
final CookieAttributeHandler h = new LaxMaxAgeHandler(); final CookieAttributeHandler h = new LaxMaxAgeHandler();
try { try {
h.parse(null, "stuff"); h.parse(null, "stuff");
Assert.fail("IllegalArgumentException must have been thrown"); Assert.fail("NullPointerException must have been thrown");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
// expected // expected
} }
} }

View File

@ -180,7 +180,7 @@ public class TestBasicHttpClientConnectionManager {
Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE, Boolean.FALSE); Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE, Boolean.FALSE);
mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECONDS); mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECOND);
Assert.assertEquals(route1, mgr.getRoute()); Assert.assertEquals(route1, mgr.getRoute());
Assert.assertEquals(null, mgr.getState()); Assert.assertEquals(null, mgr.getState());
@ -227,15 +227,15 @@ public class TestBasicHttpClientConnectionManager {
Mockito.verify(connFactory, Mockito.times(2)).createConnection(Mockito.<Socket>any()); Mockito.verify(connFactory, Mockito.times(2)).createConnection(Mockito.<Socket>any());
} }
@Test(expected=IllegalArgumentException.class) @Test(expected=NullPointerException.class)
public void testReleaseInvalidArg() throws Exception { public void testReleaseInvalidArg() throws Exception {
mgr.release(null, null, TimeValue.NEG_ONE_MILLISECONDS); mgr.release(null, null, TimeValue.NEG_ONE_MILLISECOND);
} }
@Test(expected=IllegalStateException.class) @Test(expected=IllegalStateException.class)
public void testReleaseAnotherConnection() throws Exception { public void testReleaseAnotherConnection() throws Exception {
final ConnectionEndpoint wrongCon = Mockito.mock(ConnectionEndpoint.class); final ConnectionEndpoint wrongCon = Mockito.mock(ConnectionEndpoint.class);
mgr.release(wrongCon, null, TimeValue.NEG_ONE_MILLISECONDS); mgr.release(wrongCon, null, TimeValue.NEG_ONE_MILLISECOND);
} }
@Test @Test
@ -253,7 +253,7 @@ public class TestBasicHttpClientConnectionManager {
Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE); Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE);
mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECONDS); mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECOND);
mgr.close(); mgr.close();
@ -316,7 +316,7 @@ public class TestBasicHttpClientConnectionManager {
Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE, Boolean.FALSE); Mockito.when(conn.isOpen()).thenReturn(Boolean.TRUE, Boolean.FALSE);
mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECONDS); mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECOND);
Assert.assertEquals(route, mgr.getRoute()); Assert.assertEquals(route, mgr.getRoute());
Assert.assertEquals(null, mgr.getState()); Assert.assertEquals(null, mgr.getState());

View File

@ -98,7 +98,7 @@ public class TestPoolingHttpClientConnectionManager {
final HttpHost target = new HttpHost("localhost", 80); final HttpHost target = new HttpHost("localhost", 80);
final HttpRoute route = new HttpRoute(target); final HttpRoute route = new HttpRoute(target);
final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECONDS); final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECOND);
entry.assignConnection(conn); entry.assignConnection(conn);
Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE); Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
@ -121,7 +121,7 @@ public class TestPoolingHttpClientConnectionManager {
Assert.assertNotNull(endpoint1); Assert.assertNotNull(endpoint1);
Assert.assertNotSame(conn, endpoint1); Assert.assertNotSame(conn, endpoint1);
mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECONDS); mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECOND);
Mockito.verify(pool).release(entry, true); Mockito.verify(pool).release(entry, true);
} }
@ -131,7 +131,7 @@ public class TestPoolingHttpClientConnectionManager {
final HttpHost target = new HttpHost("localhost", 80); final HttpHost target = new HttpHost("localhost", 80);
final HttpRoute route = new HttpRoute(target); final HttpRoute route = new HttpRoute(target);
final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECONDS); final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECOND);
Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE); Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
Mockito.when(socketFactoryRegistry.lookup("http")).thenReturn(plainSocketFactory); Mockito.when(socketFactoryRegistry.lookup("http")).thenReturn(plainSocketFactory);
@ -153,7 +153,7 @@ public class TestPoolingHttpClientConnectionManager {
Assert.assertNotNull(endpoint1); Assert.assertNotNull(endpoint1);
Assert.assertNotSame(conn, endpoint1); Assert.assertNotSame(conn, endpoint1);
mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECONDS); mgr.release(endpoint1, null, TimeValue.NEG_ONE_MILLISECOND);
Mockito.verify(pool).release(entry, false); Mockito.verify(pool).release(entry, false);
} }
@ -163,7 +163,7 @@ public class TestPoolingHttpClientConnectionManager {
final HttpHost target = new HttpHost("localhost", 80); final HttpHost target = new HttpHost("localhost", 80);
final HttpRoute route = new HttpRoute(target); final HttpRoute route = new HttpRoute(target);
final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECONDS); final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECOND);
entry.assignConnection(conn); entry.assignConnection(conn);
Mockito.when(future.isCancelled()).thenReturn(Boolean.TRUE); Mockito.when(future.isCancelled()).thenReturn(Boolean.TRUE);
@ -202,7 +202,7 @@ public class TestPoolingHttpClientConnectionManager {
final HttpHost target = new HttpHost("localhost", 80); final HttpHost target = new HttpHost("localhost", 80);
final HttpRoute route = new HttpRoute(target); final HttpRoute route = new HttpRoute(target);
final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECONDS); final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECOND);
entry.assignConnection(conn); entry.assignConnection(conn);
Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE); Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
@ -220,7 +220,7 @@ public class TestPoolingHttpClientConnectionManager {
Assert.assertNotNull(endpoint1); Assert.assertNotNull(endpoint1);
Assert.assertTrue(endpoint1.isConnected()); Assert.assertTrue(endpoint1.isConnected());
mgr.release(endpoint1, "some state", TimeValue.NEG_ONE_MILLISECONDS); mgr.release(endpoint1, "some state", TimeValue.NEG_ONE_MILLISECOND);
Mockito.verify(pool).release(entry, true); Mockito.verify(pool).release(entry, true);
Assert.assertEquals("some state", entry.getState()); Assert.assertEquals("some state", entry.getState());
@ -231,7 +231,7 @@ public class TestPoolingHttpClientConnectionManager {
final HttpHost target = new HttpHost("localhost", 80); final HttpHost target = new HttpHost("localhost", 80);
final HttpRoute route = new HttpRoute(target); final HttpRoute route = new HttpRoute(target);
final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECONDS); final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECOND);
entry.assignConnection(conn); entry.assignConnection(conn);
Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE); Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
@ -249,7 +249,7 @@ public class TestPoolingHttpClientConnectionManager {
Assert.assertNotNull(endpoint1); Assert.assertNotNull(endpoint1);
Assert.assertFalse(endpoint1.isConnected()); Assert.assertFalse(endpoint1.isConnected());
mgr.release(endpoint1, "some state", TimeValue.NEG_ONE_MILLISECONDS); mgr.release(endpoint1, "some state", TimeValue.NEG_ONE_MILLISECOND);
Mockito.verify(pool).release(entry, false); Mockito.verify(pool).release(entry, false);
Assert.assertEquals(null, entry.getState()); Assert.assertEquals(null, entry.getState());
@ -262,7 +262,7 @@ public class TestPoolingHttpClientConnectionManager {
final InetAddress local = InetAddress.getByAddress(new byte[]{127, 0, 0, 1}); final InetAddress local = InetAddress.getByAddress(new byte[]{127, 0, 0, 1});
final HttpRoute route = new HttpRoute(target, local, true); final HttpRoute route = new HttpRoute(target, local, true);
final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECONDS); final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECOND);
entry.assignConnection(conn); entry.assignConnection(conn);
Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE); Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
@ -315,7 +315,7 @@ public class TestPoolingHttpClientConnectionManager {
final InetAddress local = InetAddress.getByAddress(new byte[] {127, 0, 0, 1}); final InetAddress local = InetAddress.getByAddress(new byte[] {127, 0, 0, 1});
final HttpRoute route = new HttpRoute(target, local, proxy, true); final HttpRoute route = new HttpRoute(target, local, proxy, true);
final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECONDS); final PoolEntry<HttpRoute, ManagedHttpClientConnection> entry = new PoolEntry<>(route, TimeValue.NEG_ONE_MILLISECOND);
entry.assignConnection(conn); entry.assignConnection(conn);
Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE); Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);

View File

@ -81,7 +81,7 @@ public class TestRouteDirector {
} }
} }
@Test(expected=IllegalArgumentException.class) @Test(expected=NullPointerException.class)
public void testIllegal() { public void testIllegal() {
final HttpRouteDirector rowdy = new BasicRouteDirector(); final HttpRouteDirector rowdy = new BasicRouteDirector();
final HttpRoute route = new HttpRoute(TARGET1); final HttpRoute route = new HttpRoute(TARGET1);

View File

@ -121,7 +121,7 @@ public class TestRouteTracker {
try { try {
new RouteTracker(null, LOCAL41); new RouteTracker(null, LOCAL41);
Assert.fail("null target not detected"); Assert.fail("null target not detected");
} catch (final IllegalArgumentException iax) { } catch (final NullPointerException iax) {
// expected // expected
} }
} }
@ -191,14 +191,14 @@ public class TestRouteTracker {
try { try {
rt.connectProxy(null, true); rt.connectProxy(null, true);
Assert.fail("missing proxy argument not detected (connect/false)"); Assert.fail("missing proxy argument not detected (connect/false)");
} catch (final IllegalArgumentException iax) { } catch (final NullPointerException iax) {
// expected // expected
} }
try { try {
rt.connectProxy(null, false); rt.connectProxy(null, false);
Assert.fail("missing proxy argument not detected (connect/true)"); Assert.fail("missing proxy argument not detected (connect/true)");
} catch (final IllegalArgumentException iax) { } catch (final NullPointerException iax) {
// expected // expected
} }
@ -207,14 +207,14 @@ public class TestRouteTracker {
try { try {
rt.tunnelProxy(null, false); rt.tunnelProxy(null, false);
Assert.fail("missing proxy argument not detected (tunnel/false)"); Assert.fail("missing proxy argument not detected (tunnel/false)");
} catch (final IllegalArgumentException iax) { } catch (final NullPointerException iax) {
// expected // expected
} }
try { try {
rt.tunnelProxy(null, true); rt.tunnelProxy(null, true);
Assert.fail("missing proxy argument not detected (tunnel/true)"); Assert.fail("missing proxy argument not detected (tunnel/true)");
} catch (final IllegalArgumentException iax) { } catch (final NullPointerException iax) {
// expected // expected
} }

View File

@ -84,14 +84,14 @@ public class TestRequestAddCookies {
.build(); .build();
} }
@Test(expected=IllegalArgumentException.class) @Test(expected=NullPointerException.class)
public void testRequestParameterCheck() throws Exception { public void testRequestParameterCheck() throws Exception {
final HttpClientContext context = HttpClientContext.create(); final HttpClientContext context = HttpClientContext.create();
final HttpRequestInterceptor interceptor = new RequestAddCookies(); final HttpRequestInterceptor interceptor = new RequestAddCookies();
interceptor.process(null, null, context); interceptor.process(null, null, context);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected=NullPointerException.class)
public void testContextParameterCheck() throws Exception { public void testContextParameterCheck() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/"); final HttpRequest request = new BasicHttpRequest("GET", "/");
final HttpRequestInterceptor interceptor = new RequestAddCookies(); final HttpRequestInterceptor interceptor = new RequestAddCookies();

View File

@ -41,7 +41,7 @@ import org.junit.Test;
public class TestRequestClientConnControl { public class TestRequestClientConnControl {
@Test(expected=IllegalArgumentException.class) @Test(expected=NullPointerException.class)
public void testRequestParameterCheck() throws Exception { public void testRequestParameterCheck() throws Exception {
final HttpClientContext context = HttpClientContext.create(); final HttpClientContext context = HttpClientContext.create();
final HttpRequestInterceptor interceptor = new RequestClientConnControl(); final HttpRequestInterceptor interceptor = new RequestClientConnControl();

View File

@ -41,7 +41,7 @@ import org.junit.Test;
public class TestRequestDefaultHeaders { public class TestRequestDefaultHeaders {
@Test(expected=IllegalArgumentException.class) @Test(expected=NullPointerException.class)
public void testRequestParameterCheck() throws Exception { public void testRequestParameterCheck() throws Exception {
final HttpContext context = new BasicHttpContext(); final HttpContext context = new BasicHttpContext();
final HttpRequestInterceptor interceptor = new RequestDefaultHeaders(); final HttpRequestInterceptor interceptor = new RequestDefaultHeaders();

View File

@ -111,8 +111,8 @@ public class TestRequestExpectContinue {
final RequestExpectContinue interceptor = new RequestExpectContinue(); final RequestExpectContinue interceptor = new RequestExpectContinue();
try { try {
interceptor.process(null, null, null); interceptor.process(null, null, null);
Assert.fail("IllegalArgumentException should have been thrown"); Assert.fail("NullPointerException should have been thrown");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
// expected // expected
} }
} }

View File

@ -54,14 +54,14 @@ public class TestResponseProcessCookies {
this.cookieStore = new BasicCookieStore(); this.cookieStore = new BasicCookieStore();
} }
@Test(expected=IllegalArgumentException.class) @Test(expected=NullPointerException.class)
public void testResponseParameterCheck() throws Exception { public void testResponseParameterCheck() throws Exception {
final HttpClientContext context = HttpClientContext.create(); final HttpClientContext context = HttpClientContext.create();
final HttpResponseInterceptor interceptor = new ResponseProcessCookies(); final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
interceptor.process(null, null, context); interceptor.process(null, null, context);
} }
@Test(expected=IllegalArgumentException.class) @Test(expected=NullPointerException.class)
public void testContextParameterCheck() throws Exception { public void testContextParameterCheck() throws Exception {
final HttpResponse response = new BasicHttpResponse(200, "OK"); final HttpResponse response = new BasicHttpResponse(200, "OK");
final HttpResponseInterceptor interceptor = new ResponseProcessCookies(); final HttpResponseInterceptor interceptor = new ResponseProcessCookies();

View File

@ -239,7 +239,7 @@ public class TestHttpRoute {
new HttpRoute(null, null, chain1, false, new HttpRoute(null, null, chain1, false,
TunnelType.TUNNELLED, LayerType.PLAIN); TunnelType.TUNNELLED, LayerType.PLAIN);
Assert.fail("missing target not detected"); Assert.fail("missing target not detected");
} catch (final IllegalArgumentException iax) { } catch (final NullPointerException iax) {
// expected // expected
} }
@ -532,7 +532,7 @@ public class TestHttpRoute {
try { try {
new HttpRoute(TARGET1, LOCAL61, null, false); new HttpRoute(TARGET1, LOCAL61, null, false);
Assert.fail("missing proxy not detected"); Assert.fail("missing proxy not detected");
} catch (final IllegalArgumentException iax) { } catch (final NullPointerException iax) {
// expected // expected
} }
} }

View File

@ -80,20 +80,20 @@ public class TestDateUtils {
public void testInvalidInput() throws Exception { public void testInvalidInput() throws Exception {
try { try {
DateUtils.parseDate(null, null, null); DateUtils.parseDate(null, null, null);
Assert.fail("IllegalArgumentException should habe been thrown"); Assert.fail("NullPointerException should habe been thrown");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
// expected // expected
} }
try { try {
DateUtils.formatDate(null); DateUtils.formatDate(null);
Assert.fail("IllegalArgumentException should habe been thrown"); Assert.fail("NullPointerException should habe been thrown");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
// expected // expected
} }
try { try {
DateUtils.formatDate(new Date(), null); DateUtils.formatDate(new Date(), null);
Assert.fail("IllegalArgumentException should habe been thrown"); Assert.fail("NullPointerException should habe been thrown");
} catch (final IllegalArgumentException ex) { } catch (final NullPointerException ex) {
// expected // expected
} }
} }

View File

@ -67,7 +67,7 @@
<properties> <properties>
<maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target> <maven.compiler.target>1.7</maven.compiler.target>
<httpcore.version>5.0-beta10</httpcore.version> <httpcore.version>5.0-beta11</httpcore.version>
<log4j.version>2.9.1</log4j.version> <log4j.version>2.9.1</log4j.version>
<commons-codec.version>1.13</commons-codec.version> <commons-codec.version>1.13</commons-codec.version>
<conscrypt.version>2.2.1</conscrypt.version> <conscrypt.version>2.2.1</conscrypt.version>