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.HttpRequest;
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.StatusLine;
import org.apache.hc.core5.util.ByteArrayBuffer;
@ -100,7 +100,7 @@ class BasicHttpAsyncCache implements HttpAsyncCache {
if (log.isDebugEnabled()) {
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);
return storage.removeEntry(cacheKey, new FutureCallback<Boolean>() {
@ -147,7 +147,7 @@ class BasicHttpAsyncCache implements HttpAsyncCache {
if (log.isDebugEnabled()) {
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);
}
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.HttpRequest;
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.StatusLine;
import org.apache.hc.core5.util.ByteArrayBuffer;
@ -102,7 +102,7 @@ class BasicHttpCache implements HttpCache {
if (log.isDebugEnabled()) {
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);
try {
storage.removeEntry(cacheKey);
@ -127,7 +127,7 @@ class BasicHttpCache implements HttpCache {
if (log.isDebugEnabled()) {
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);
}
}

View File

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

View File

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

View File

@ -142,7 +142,7 @@ public class TestHttpCacheEntry {
try {
new HttpCacheEntry(null, new Date(), HttpStatus.SC_OK, new Header[]{}, mockResource);
fail("Should have thrown exception");
} catch (final IllegalArgumentException expected) {
} catch (final NullPointerException expected) {
}
}
@ -152,7 +152,7 @@ public class TestHttpCacheEntry {
try {
new HttpCacheEntry(new Date(), null, HttpStatus.SC_OK, new Header[]{}, mockResource);
fail("Should have thrown exception");
} catch (final IllegalArgumentException expected) {
} catch (final NullPointerException expected) {
}
}
@ -162,7 +162,7 @@ public class TestHttpCacheEntry {
try {
new HttpCacheEntry(new Date(), new Date(), HttpStatus.SC_OK, null, mockResource);
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.HttpHost;
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.io.entity.ByteArrayEntity;
import org.apache.hc.core5.http.io.entity.FileEntity;
@ -81,7 +81,7 @@ public class Request {
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));
}

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.HttpResponse;
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.nio.entity.AsyncEntityProducers;
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());
rnd.nextBytes(b1);
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)),
new BasicResponseConsumer<>(new BasicAsyncEntityConsumer()), HttpClientContext.create(), null);
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<>();
for (int i = 0; i < reqCount; i++) {
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)),
new BasicResponseConsumer<>(new BasicAsyncEntityConsumer()), HttpClientContext.create(), null);
queue.add(future);

View File

@ -157,7 +157,7 @@ public class TestHttp1AsyncStatefulConnManagement extends AbstractIntegrationTes
worker.start();
}
for (final HttpWorker worker : workers) {
worker.join(LONG_TIMEOUT.toMillis());
worker.join(LONG_TIMEOUT.toMilliseconds());
}
for (final HttpWorker worker : workers) {
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.HttpVersion;
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.config.Http1Config;
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<>();
for (int i = 0; i < reqCount; i++) {
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)),
new BasicResponseConsumer<>(new BasicAsyncEntityConsumer()), HttpClientContext.create(), null);
queue.add(future);

View File

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

View File

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

View File

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

View File

@ -157,7 +157,7 @@ public class HttpClientCompatibilityTest {
}
// Basic GET requests
{
connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS);
connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND);
final HttpClientContext context = HttpClientContext.create();
context.setCredentialsProvider(credentialsProvider);
final String[] requestUris = new String[] {"/", "/news.html", "/status.html"};
@ -178,7 +178,7 @@ public class HttpClientCompatibilityTest {
}
// Wrong target auth scope
{
connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS);
connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND);
credentialsProvider.setCredentials(
new AuthScope("http", "otherhost", -1, "Restricted Files", null),
new UsernamePasswordCredentials("testuser", "nopassword".toCharArray()));
@ -200,7 +200,7 @@ public class HttpClientCompatibilityTest {
}
// Wrong target credentials
{
connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS);
connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND);
credentialsProvider.setCredentials(
new AuthScope(target),
new UsernamePasswordCredentials("testuser", "wrong password".toCharArray()));
@ -222,7 +222,7 @@ public class HttpClientCompatibilityTest {
}
// Correct target credentials
{
connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS);
connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND);
credentialsProvider.setCredentials(
new AuthScope(target),
new UsernamePasswordCredentials("testuser", "nopassword".toCharArray()));
@ -244,7 +244,7 @@ public class HttpClientCompatibilityTest {
}
// Correct target credentials (no keep-alive)
{
connManager.closeIdle(TimeValue.NEG_ONE_MILLISECONDS);
connManager.closeIdle(TimeValue.NEG_ONE_MILLISECOND);
credentialsProvider.setCredentials(
new AuthScope(target),
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.http.HttpHost;
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.SocketConfig;
import org.apache.hc.core5.http.protocol.HttpProcessor;
@ -126,9 +127,10 @@ public abstract class LocalServerTestBase {
};
public HttpHost start(
final Http1Config http1Config,
final HttpProcessor httpProcessor,
final Decorator<HttpServerRequestHandler> handlerDecorator) throws IOException {
this.server.start(httpProcessor, handlerDecorator);
this.server.start(http1Config, httpProcessor, handlerDecorator);
if (this.httpclient == null) {
this.httpclient = this.clientBuilder.build();
@ -137,8 +139,14 @@ public abstract class LocalServerTestBase {
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 {
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 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(
new RequestTargetHost(), new RequestContent(), new RequestConnControl());
@ -104,12 +104,12 @@ public class TestConnectionManagement extends LocalServerTestBase {
}
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 ConnectionEndpoint endpoint2 = leaseRequest2.get(Timeout.ZERO_MILLISECONDS);
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)) {
Assert.assertEquals(HttpStatus.SC_OK, response2.getCode());
@ -117,7 +117,7 @@ public class TestConnectionManagement extends LocalServerTestBase {
// release connection after marking it for re-use
// 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 ConnectionEndpoint endpoint3 = leaseRequest3.get(Timeout.ZERO_MILLISECONDS);
@ -128,7 +128,7 @@ public class TestConnectionManagement extends LocalServerTestBase {
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();
}
@ -150,7 +150,7 @@ public class TestConnectionManagement extends LocalServerTestBase {
final LeaseRequest leaseRequest1 = this.connManager.lease("id1", route,null);
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(
new RequestTargetHost(), new RequestContent(), new RequestConnControl());
@ -178,7 +178,7 @@ public class TestConnectionManagement extends LocalServerTestBase {
final ConnectionEndpoint endpoint2 = leaseRequest2.get(Timeout.ZERO_MILLISECONDS);
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)) {
Assert.assertEquals(HttpStatus.SC_OK, response2.getCode());
@ -203,7 +203,7 @@ public class TestConnectionManagement extends LocalServerTestBase {
Assert.assertFalse(endpoint4.isConnected());
// 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)) {
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 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.getStats(route).getLeased());
@ -272,12 +272,12 @@ public class TestConnectionManagement extends LocalServerTestBase {
final LeaseRequest leaseRequest1 = this.connManager.lease("id1", route,null);
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.getStats(route).getLeased());
// 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.
Assert.assertEquals(1, this.connManager.getTotalStats().getAvailable());

View File

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

View File

@ -30,7 +30,7 @@ package org.apache.hc.client5.http.async.methods;
import java.net.URI;
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;
/**
@ -43,96 +43,96 @@ public enum HttpRequests {
DELETE {
@Override
public BasicHttpRequest create(final URI uri) {
return new BasicHttpRequest(Methods.DELETE, uri);
return new BasicHttpRequest(Method.DELETE, uri);
}
@Override
public BasicHttpRequest create(final HttpHost host, final String path) {
return new BasicHttpRequest(Methods.DELETE, host, path);
return new BasicHttpRequest(Method.DELETE, host, path);
}
},
GET {
@Override
public BasicHttpRequest create(final URI uri) {
return new BasicHttpRequest(Methods.GET, uri);
return new BasicHttpRequest(Method.GET, uri);
}
@Override
public BasicHttpRequest create(final HttpHost host, final String path) {
return new BasicHttpRequest(Methods.GET, host, path);
return new BasicHttpRequest(Method.GET, host, path);
}
},
HEAD {
@Override
public BasicHttpRequest create(final URI uri) {
return new BasicHttpRequest(Methods.HEAD, uri);
return new BasicHttpRequest(Method.HEAD, uri);
}
@Override
public BasicHttpRequest create(final HttpHost host, final String path) {
return new BasicHttpRequest(Methods.HEAD, host, path);
return new BasicHttpRequest(Method.HEAD, host, path);
}
},
OPTIONS {
@Override
public BasicHttpRequest create(final URI uri) {
return new BasicHttpRequest(Methods.OPTIONS, uri);
return new BasicHttpRequest(Method.OPTIONS, uri);
}
@Override
public BasicHttpRequest create(final HttpHost host, final String path) {
return new BasicHttpRequest(Methods.OPTIONS, host, path);
return new BasicHttpRequest(Method.OPTIONS, host, path);
}
},
PATCH {
@Override
public BasicHttpRequest create(final URI uri) {
return new BasicHttpRequest(Methods.PATCH, uri);
return new BasicHttpRequest(Method.PATCH, uri);
}
@Override
public BasicHttpRequest create(final HttpHost host, final String path) {
return new BasicHttpRequest(Methods.PATCH, host, path);
return new BasicHttpRequest(Method.PATCH, host, path);
}
},
POST {
@Override
public BasicHttpRequest create(final URI uri) {
return new BasicHttpRequest(Methods.POST, uri);
return new BasicHttpRequest(Method.POST, uri);
}
@Override
public BasicHttpRequest create(final HttpHost host, final String path) {
return new BasicHttpRequest(Methods.POST, host, path);
return new BasicHttpRequest(Method.POST, host, path);
}
},
PUT {
@Override
public BasicHttpRequest create(final URI uri) {
return new BasicHttpRequest(Methods.PUT, uri);
return new BasicHttpRequest(Method.PUT, uri);
}
@Override
public BasicHttpRequest create(final HttpHost host, final String path) {
return new BasicHttpRequest(Methods.PUT, host, path);
return new BasicHttpRequest(Method.PUT, host, path);
}
},
TRACE {
@Override
public BasicHttpRequest create(final URI uri) {
return new BasicHttpRequest(Methods.TRACE, uri);
return new BasicHttpRequest(Method.TRACE, uri);
}
@Override
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.HttpHost;
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;
/**
@ -73,11 +73,11 @@ public final class SimpleHttpRequest extends ConfigurableHttpRequest {
super(method, requestUri);
}
SimpleHttpRequest(final Methods method, final URI requestUri) {
SimpleHttpRequest(final Method method, final URI 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);
}

View File

@ -30,7 +30,7 @@ package org.apache.hc.client5.http.async.methods;
import java.net.URI;
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.
@ -42,96 +42,96 @@ public enum SimpleHttpRequests {
DELETE {
@Override
public SimpleHttpRequest create(final URI uri) {
return new SimpleHttpRequest(Methods.DELETE, uri);
return new SimpleHttpRequest(Method.DELETE, uri);
}
@Override
public SimpleHttpRequest create(final HttpHost host, final String path) {
return new SimpleHttpRequest(Methods.DELETE, host, path);
return new SimpleHttpRequest(Method.DELETE, host, path);
}
},
GET {
@Override
public SimpleHttpRequest create(final URI uri) {
return new SimpleHttpRequest(Methods.GET, uri);
return new SimpleHttpRequest(Method.GET, uri);
}
@Override
public SimpleHttpRequest create(final HttpHost host, final String path) {
return new SimpleHttpRequest(Methods.GET, host, path);
return new SimpleHttpRequest(Method.GET, host, path);
}
},
HEAD {
@Override
public SimpleHttpRequest create(final URI uri) {
return new SimpleHttpRequest(Methods.HEAD, uri);
return new SimpleHttpRequest(Method.HEAD, uri);
}
@Override
public SimpleHttpRequest create(final HttpHost host, final String path) {
return new SimpleHttpRequest(Methods.HEAD, host, path);
return new SimpleHttpRequest(Method.HEAD, host, path);
}
},
OPTIONS {
@Override
public SimpleHttpRequest create(final URI uri) {
return new SimpleHttpRequest(Methods.OPTIONS, uri);
return new SimpleHttpRequest(Method.OPTIONS, uri);
}
@Override
public SimpleHttpRequest create(final HttpHost host, final String path) {
return new SimpleHttpRequest(Methods.OPTIONS, host, path);
return new SimpleHttpRequest(Method.OPTIONS, host, path);
}
},
PATCH {
@Override
public SimpleHttpRequest create(final URI uri) {
return new SimpleHttpRequest(Methods.PATCH, uri);
return new SimpleHttpRequest(Method.PATCH, uri);
}
@Override
public SimpleHttpRequest create(final HttpHost host, final String path) {
return new SimpleHttpRequest(Methods.PATCH, host, path);
return new SimpleHttpRequest(Method.PATCH, host, path);
}
},
POST {
@Override
public SimpleHttpRequest create(final URI uri) {
return new SimpleHttpRequest(Methods.POST, uri);
return new SimpleHttpRequest(Method.POST, uri);
}
@Override
public SimpleHttpRequest create(final HttpHost host, final String path) {
return new SimpleHttpRequest(Methods.POST, host, path);
return new SimpleHttpRequest(Method.POST, host, path);
}
},
PUT {
@Override
public SimpleHttpRequest create(final URI uri) {
return new SimpleHttpRequest(Methods.PUT, uri);
return new SimpleHttpRequest(Method.PUT, uri);
}
@Override
public SimpleHttpRequest create(final HttpHost host, final String path) {
return new SimpleHttpRequest(Methods.PUT, host, path);
return new SimpleHttpRequest(Method.PUT, host, path);
}
},
TRACE {
@Override
public SimpleHttpRequest create(final URI uri) {
return new SimpleHttpRequest(Methods.TRACE, uri);
return new SimpleHttpRequest(Method.TRACE, uri);
}
@Override
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.HttpResponse;
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.util.Args;
import org.apache.hc.core5.util.TimeValue;
@ -226,7 +226,7 @@ public class DefaultHttpRequestRetryStrategy implements HttpRequestRetryStrategy
}
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 {
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.HttpRequest;
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.nio.AsyncDataConsumer;
import org.apache.hc.core5.http.nio.AsyncEntityProducer;
@ -181,7 +181,7 @@ public final class AsyncProtocolExec implements AsyncExecChainHandler {
clientContext.setAttribute(HttpCoreContext.HTTP_RESPONSE, response);
httpProcessor.process(response, entityDetails, clientContext);
if (Methods.TRACE.isSame(request.getMethod())) {
if (Method.TRACE.isSame(request.getMethod())) {
// Do not perform authentication for TRACE request
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.HttpResponse;
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.message.BasicHttpRequest;
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_TEMPORARILY:
case HttpStatus.SC_SEE_OTHER:
if (!Methods.isSafe(request.getMethod())) {
state.currentRequest = new BasicHttpRequest(Methods.GET, redirectUri);
if (!Method.isSafe(request.getMethod())) {
state.currentRequest = new BasicHttpRequest(Method.GET, redirectUri);
state.currentEntityProducer = null;
}
}

View File

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

View File

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

View File

@ -478,7 +478,7 @@ public final class MinimalHttpAsyncClient extends AbstractMinimalHttpAsyncClient
@Override
public void releaseAndReuse() {
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 Long lastUpdate = getLastUpdate(lastRouteBackoffs, route);
final long now = clock.getCurrentTime();
if (now - lastUpdate.longValue() < coolDown.toMillis()) {
if (now - lastUpdate.longValue() < coolDown.toMilliseconds()) {
return;
}
connPerRoute.setMaxPerRoute(route, getBackedOffPoolSize(curr));
@ -114,8 +114,8 @@ public class AIMDBackoffManager implements BackoffManager {
final Long lastProbe = getLastUpdate(lastRouteProbes, route);
final Long lastBackoff = getLastUpdate(lastRouteBackoffs, route);
final long now = clock.getCurrentTime();
if (now - lastProbe.longValue() < coolDown.toMillis()
|| now - lastBackoff.longValue() < coolDown.toMillis()) {
if (now - lastProbe.longValue() < coolDown.toMilliseconds()
|| now - lastBackoff.longValue() < coolDown.toMilliseconds()) {
return;
}
connPerRoute.setMaxPerRoute(route, max);

View File

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

View File

@ -150,7 +150,7 @@ public class MinimalHttpClient extends CloseableHttpClient {
httpProcessor.process(response, response.getEntity(), context);
if (reuseStrategy.keepAlive(request, response, context)) {
execRuntime.markConnectionReusable(null, TimeValue.NEG_ONE_MILLISECONDS);
execRuntime.markConnectionReusable(null, TimeValue.NEG_ONE_MILLISECOND);
} else {
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.HttpHost;
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.io.entity.EntityUtils;
import org.apache.hc.core5.http.protocol.HttpCoreContext;
@ -167,7 +167,7 @@ public final class ProtocolExec implements ExecChainHandler {
context.setAttribute(HttpCoreContext.HTTP_RESPONSE, response);
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
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.HttpHost;
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.io.entity.EntityUtils;
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_TEMPORARILY:
case HttpStatus.SC_SEE_OTHER:
if (!Methods.isSafe(request.getMethod())) {
if (!Method.isSafe(request.getMethod())) {
redirect = new HttpGet(redirectUri);
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

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.TlsCiphers;
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.net.NamedEndpoint;
import org.apache.hc.core5.reactor.ssl.SSLBufferMode;
@ -134,7 +134,7 @@ abstract class AbstractClientTlsStrategy implements TlsStrategy {
verifySession(host.getHostName(), sslEngine.getSession());
final TlsDetails tlsDetails = createTlsDetails(sslEngine);
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)) {
throw new SSLHandshakeException("Cipher suite `" + negotiatedCipherSuite
+ "` does not provide adequate security for HTTP/2");

View File

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

View File

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

View File

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

View File

@ -45,7 +45,7 @@ public class TestCookieOrigin {
}
@SuppressWarnings("unused")
@Test(expected=IllegalArgumentException.class)
@Test(expected=NullPointerException.class)
public void testNullHost() {
new CookieOrigin(null, 80, "/", false);
}
@ -63,7 +63,7 @@ public class TestCookieOrigin {
}
@SuppressWarnings("unused")
@Test(expected=IllegalArgumentException.class)
@Test(expected=NullPointerException.class)
public void testNullPath() {
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.HttpRequest;
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.nio.AsyncPushConsumer;
import org.apache.hc.core5.http.nio.support.BasicRequestProducer;
@ -118,7 +118,7 @@ public class AsyncClientH2ServerPush {
final HttpHost target = new HttpHost("nghttp2.org");
final String requestURI = "/httpbin/";
final Future<Void> future = client.execute(
new BasicRequestProducer(Methods.GET, target, requestURI),
new BasicRequestProducer(Method.GET, target, requestURI),
new AbstractCharResponseConsumer<Void>() {
@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.HttpHost;
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.nio.support.BasicRequestProducer;
import org.apache.hc.core5.io.CloseMode;
@ -66,7 +66,7 @@ public class AsyncClientHttpExchangeStreaming {
for (final String requestUri: requestUris) {
final Future<Void> future = client.execute(
new BasicRequestProducer(Methods.GET, target, requestUri),
new BasicRequestProducer(Method.GET, target, requestUri),
new AbstractCharResponseConsumer<Void>() {
@Override

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -71,14 +71,14 @@ public class TestRequestAuthCache {
this.credProvider.setCredentials(this.authscope2, this.creds2);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected=NullPointerException.class)
public void testRequestParameterCheck() throws Exception {
final HttpClientContext context = HttpClientContext.create();
final HttpRequestInterceptor interceptor = new RequestAuthCache();
interceptor.process(null, null, context);
}
@Test(expected=IllegalArgumentException.class)
@Test(expected=NullPointerException.class)
public void testContextParameterCheck() throws Exception {
final HttpRequest request = new BasicHttpRequest("GET", "/");
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.HttpException;
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.message.BasicClassicHttpRequest;
import org.apache.hc.core5.http.message.BasicClassicHttpResponse;
@ -77,7 +77,7 @@ public class TestContentCompressionExec {
@Test
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");
Mockito.when(execChain.proceed(request, scope)).thenReturn(response);
@ -90,7 +90,7 @@ public class TestContentCompressionExec {
@Test
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 StringEntity original = new StringEntity("plain stuff");
response.setEntity(original);
@ -106,7 +106,7 @@ public class TestContentCompressionExec {
@Test
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 HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("GZip").build();
response.setEntity(original);
@ -122,7 +122,7 @@ public class TestContentCompressionExec {
@Test
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 HttpEntity original = EntityBuilder.create().setText("").setContentEncoding("GZip").build();
response.setEntity(original);
@ -138,7 +138,7 @@ public class TestContentCompressionExec {
@Test
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 HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("x-gzip").build();
response.setEntity(original);
@ -154,7 +154,7 @@ public class TestContentCompressionExec {
@Test
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 HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("deFlaTe").build();
response.setEntity(original);
@ -170,7 +170,7 @@ public class TestContentCompressionExec {
@Test
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 HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("identity").build();
response.setEntity(original);
@ -186,7 +186,7 @@ public class TestContentCompressionExec {
@Test(expected=HttpException.class)
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 HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("whatever").build();
response.setEntity(original);
@ -200,7 +200,7 @@ public class TestContentCompressionExec {
@Test
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 HttpEntity original = EntityBuilder.create().setText("encoded stuff").setContentEncoding("GZip").build();
response.setEntity(original);

View File

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

View File

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

View File

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

View File

@ -180,7 +180,7 @@ public class TestBasicHttpClientConnectionManager {
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(null, mgr.getState());
@ -227,15 +227,15 @@ public class TestBasicHttpClientConnectionManager {
Mockito.verify(connFactory, Mockito.times(2)).createConnection(Mockito.<Socket>any());
}
@Test(expected=IllegalArgumentException.class)
@Test(expected=NullPointerException.class)
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)
public void testReleaseAnotherConnection() throws Exception {
final ConnectionEndpoint wrongCon = Mockito.mock(ConnectionEndpoint.class);
mgr.release(wrongCon, null, TimeValue.NEG_ONE_MILLISECONDS);
mgr.release(wrongCon, null, TimeValue.NEG_ONE_MILLISECOND);
}
@Test
@ -253,7 +253,7 @@ public class TestBasicHttpClientConnectionManager {
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();
@ -316,7 +316,7 @@ public class TestBasicHttpClientConnectionManager {
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(null, mgr.getState());

View File

@ -98,7 +98,7 @@ public class TestPoolingHttpClientConnectionManager {
final HttpHost target = new HttpHost("localhost", 80);
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);
Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
@ -121,7 +121,7 @@ public class TestPoolingHttpClientConnectionManager {
Assert.assertNotNull(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);
}
@ -131,7 +131,7 @@ public class TestPoolingHttpClientConnectionManager {
final HttpHost target = new HttpHost("localhost", 80);
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(socketFactoryRegistry.lookup("http")).thenReturn(plainSocketFactory);
@ -153,7 +153,7 @@ public class TestPoolingHttpClientConnectionManager {
Assert.assertNotNull(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);
}
@ -163,7 +163,7 @@ public class TestPoolingHttpClientConnectionManager {
final HttpHost target = new HttpHost("localhost", 80);
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);
Mockito.when(future.isCancelled()).thenReturn(Boolean.TRUE);
@ -202,7 +202,7 @@ public class TestPoolingHttpClientConnectionManager {
final HttpHost target = new HttpHost("localhost", 80);
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);
Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
@ -220,7 +220,7 @@ public class TestPoolingHttpClientConnectionManager {
Assert.assertNotNull(endpoint1);
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);
Assert.assertEquals("some state", entry.getState());
@ -231,7 +231,7 @@ public class TestPoolingHttpClientConnectionManager {
final HttpHost target = new HttpHost("localhost", 80);
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);
Mockito.when(future.isCancelled()).thenReturn(Boolean.FALSE);
@ -249,7 +249,7 @@ public class TestPoolingHttpClientConnectionManager {
Assert.assertNotNull(endpoint1);
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);
Assert.assertEquals(null, entry.getState());
@ -262,7 +262,7 @@ public class TestPoolingHttpClientConnectionManager {
final InetAddress local = InetAddress.getByAddress(new byte[]{127, 0, 0, 1});
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);
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 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);
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() {
final HttpRouteDirector rowdy = new BasicRouteDirector();
final HttpRoute route = new HttpRoute(TARGET1);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -67,7 +67,7 @@
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<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>
<commons-codec.version>1.13</commons-codec.version>
<conscrypt.version>2.2.1</conscrypt.version>