hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1790031 [1/2] - in /httpcomponents/httpcore/trunk: httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/ httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/ httpcore5-testing/src/main/java/org/apache/hc/core5/te...
Date Mon, 03 Apr 2017 18:23:05 GMT
Author: olegk
Date: Mon Apr  3 18:23:04 2017
New Revision: 1790031

URL: http://svn.apache.org/viewvc?rev=1790031&view=rev
Log:
HTTPCORE-451: revised public APIs to make use of TimeValue to represent time values

Modified:
    httpcomponents/httpcore/trunk/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2FileServerExample.java
    httpcomponents/httpcore/trunk/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2MultiStreamExecutionExample.java
    httpcomponents/httpcore/trunk/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2RequestExecutionExample.java
    httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2RequesterBootstrap.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/AsyncRequester.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestClient.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/IOReactorExecutor.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestClient.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/compatibility/http2/Http2CompatibilityTest.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/Http1IntegrationTest.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/InternalServerTestBase.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/Http2IntegrationTest.java
    httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/InternalServerTestBase.java
    httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncFileServerExample.java
    httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncPipelinedRequestExecutionExample.java
    httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncRequestExecutionExample.java
    httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncReverseProxyExample.java
    httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ClassicFileServerExample.java
    httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/ClassicReverseProxyExample.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/config/SocketConfig.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/AsyncRequester.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/AsyncRequesterBootstrap.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/HttpAsyncRequester.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/HttpServer.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/IOReactorExecutor.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/http/impl/bootstrap/RequesterBootstrap.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/pool/ConnPoolControl.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/pool/LeaseRequest.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/pool/PoolEntry.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/pool/RoutePool.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/pool/StrictConnPool.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/AbstractMultiworkerIOReactor.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOReactor.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOReactorConfig.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/reactor/IOReactorImpl.java
    httpcomponents/httpcore/trunk/httpcore5/src/main/java/org/apache/hc/core5/util/TimeValue.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/pool/TestPoolEntry.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/pool/TestRouteSpecificPool.java
    httpcomponents/httpcore/trunk/httpcore5/src/test/java/org/apache/hc/core5/pool/TestStrictConnPool.java

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2FileServerExample.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2FileServerExample.java?rev=1790031&r1=1790030&r2=1790031&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2FileServerExample.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2FileServerExample.java Mon Apr  3 18:23:04 2017
@@ -65,6 +65,7 @@ import org.apache.hc.core5.http2.impl.ni
 import org.apache.hc.core5.io.ShutdownType;
 import org.apache.hc.core5.reactor.IOReactorConfig;
 import org.apache.hc.core5.reactor.ListenerEndpoint;
+import org.apache.hc.core5.util.TimeValue;
 
 /**
  * Example of asynchronous embedded HTTP/2 file server.
@@ -236,7 +237,7 @@ public class Http2FileServerExample {
         ListenerEndpoint listenerEndpoint = server.listen(new InetSocketAddress(port));
         listenerEndpoint.waitFor();
         System.out.print("Listening on " + listenerEndpoint.getAddress());
-        server.awaitShutdown(Long.MAX_VALUE, TimeUnit.DAYS);
+        server.awaitShutdown(TimeValue.MAX_VALUE);
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2MultiStreamExecutionExample.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2MultiStreamExecutionExample.java?rev=1790031&r1=1790030&r2=1790031&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2MultiStreamExecutionExample.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2MultiStreamExecutionExample.java Mon Apr  3 18:23:04 2017
@@ -29,7 +29,6 @@ package org.apache.hc.core5.http.example
 import java.util.List;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
 
 import org.apache.hc.core5.concurrent.FutureCallback;
 import org.apache.hc.core5.http.Header;
@@ -47,6 +46,7 @@ import org.apache.hc.core5.http2.frame.R
 import org.apache.hc.core5.http2.impl.nio.Http2StreamListener;
 import org.apache.hc.core5.http2.impl.nio.bootstrap.H2RequesterBootstrap;
 import org.apache.hc.core5.io.ShutdownType;
+import org.apache.hc.core5.util.TimeValue;
 
 /**
  * Example of HTTP/2 concurrent request execution using multiple streams.
@@ -108,7 +108,7 @@ public class Http2MultiStreamExecutionEx
         HttpHost target = new HttpHost("http2bin.org");
         String[] requestUris = new String[] {"/", "/ip", "/user-agent", "/headers"};
 
-        Future<AsyncClientEndpoint> future = requester.connect(target, 5, TimeUnit.SECONDS);
+        Future<AsyncClientEndpoint> future = requester.connect(target, TimeValue.ofSeconds(5));
         AsyncClientEndpoint clientEndpoint = future.get();
 
         final CountDownLatch latch = new CountDownLatch(requestUris.length);

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2RequestExecutionExample.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2RequestExecutionExample.java?rev=1790031&r1=1790030&r2=1790031&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2RequestExecutionExample.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/examples/org/apache/hc/core5/http/examples/Http2RequestExecutionExample.java Mon Apr  3 18:23:04 2017
@@ -29,7 +29,6 @@ package org.apache.hc.core5.http.example
 import java.util.List;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
 
 import org.apache.hc.core5.concurrent.FutureCallback;
 import org.apache.hc.core5.http.Header;
@@ -47,6 +46,7 @@ import org.apache.hc.core5.http2.frame.R
 import org.apache.hc.core5.http2.impl.nio.Http2StreamListener;
 import org.apache.hc.core5.http2.impl.nio.bootstrap.H2RequesterBootstrap;
 import org.apache.hc.core5.io.ShutdownType;
+import org.apache.hc.core5.util.TimeValue;
 
 /**
  * Example of HTTP/2 request execution.
@@ -110,7 +110,7 @@ public class Http2RequestExecutionExampl
 
         final CountDownLatch latch = new CountDownLatch(requestUris.length);
         for (final String requestUri: requestUris) {
-            final Future<AsyncClientEndpoint> future = requester.connect(target, 5, TimeUnit.SECONDS);
+            final Future<AsyncClientEndpoint> future = requester.connect(target, TimeValue.ofSeconds(5));
             final AsyncClientEndpoint clientEndpoint = future.get();
             clientEndpoint.executeAndRelease(
                     new BasicRequestProducer("GET", target, requestUri),

Modified: httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2RequesterBootstrap.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2RequesterBootstrap.java?rev=1790031&r1=1790030&r2=1790031&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2RequesterBootstrap.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/impl/nio/bootstrap/H2RequesterBootstrap.java Mon Apr  3 18:23:04 2017
@@ -28,7 +28,6 @@ package org.apache.hc.core5.http2.impl.n
 
 import java.util.ArrayList;
 import java.util.List;
-import java.util.concurrent.TimeUnit;
 
 import org.apache.hc.core5.function.Supplier;
 import org.apache.hc.core5.http.ExceptionListener;
@@ -51,6 +50,7 @@ import org.apache.hc.core5.reactor.IORea
 import org.apache.hc.core5.reactor.IOReactorException;
 import org.apache.hc.core5.reactor.IOSession;
 import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.TimeValue;
 
 /**
  * @since 5.0
@@ -65,8 +65,7 @@ public class H2RequesterBootstrap {
     private H2Config h2Config;
     private int defaultMaxPerRoute;
     private int maxTotal;
-    private long timeToLive;
-    private TimeUnit timeUnit;
+    private TimeValue timeToLive;
     private ConnPoolPolicy connPoolPolicy;
     private TlsStrategy tlsStrategy;
     private ExceptionListener exceptionListener;
@@ -124,9 +123,8 @@ public class H2RequesterBootstrap {
         return this;
     }
 
-    public final H2RequesterBootstrap setTimeToLive(final long timeToLive, final TimeUnit timeUnit) {
+    public final H2RequesterBootstrap setTimeToLive(final TimeValue timeToLive) {
         this.timeToLive = timeToLive;
-        this.timeUnit = timeUnit;
         return this;
     }
 
@@ -197,7 +195,7 @@ public class H2RequesterBootstrap {
         final StrictConnPool<HttpHost, IOSession> connPool = new StrictConnPool<>(
                 defaultMaxPerRoute > 0 ? defaultMaxPerRoute : 20,
                 maxTotal > 0 ? maxTotal : 50,
-                timeToLive, timeUnit != null ? timeUnit : TimeUnit.MILLISECONDS,
+                timeToLive,
                 connPoolPolicy,
                 connPoolListener);
         final AsyncPushConsumerRegistry pushConsumerRegistry = new AsyncPushConsumerRegistry();

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/AsyncRequester.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/AsyncRequester.java?rev=1790031&r1=1790030&r2=1790031&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/AsyncRequester.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/AsyncRequester.java Mon Apr  3 18:23:04 2017
@@ -31,7 +31,6 @@ import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.SocketAddress;
 import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
 
 import org.apache.hc.core5.function.Callback;
 import org.apache.hc.core5.http.HttpHost;
@@ -44,6 +43,7 @@ import org.apache.hc.core5.reactor.IOSes
 import org.apache.hc.core5.reactor.SessionRequest;
 import org.apache.hc.core5.reactor.SessionRequestCallback;
 import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.TimeValue;
 
 public class AsyncRequester extends IOReactorExecutor<DefaultConnectingIOReactor> implements ConnectionInitiator {
 
@@ -77,15 +77,11 @@ public class AsyncRequester extends IORe
         return new InetSocketAddress(hostName, port);
     }
 
-    public SessionRequest requestSession(
-            final HttpHost host,
-            final long timeout,
-            final TimeUnit timeUnit,
-            final SessionRequestCallback callback) {
+    public SessionRequest requestSession(final HttpHost host, final TimeValue timeout, final SessionRequestCallback callback) {
         Args.notNull(host, "Host");
-        Args.notNull(timeUnit, "Time unit");
+        Args.notNull(timeout, "Timeout");
         final SessionRequest  sessionRequest = reactor().connect(host, toSocketAddress(host), null, null, callback);
-        sessionRequest.setConnectTimeout((int) timeUnit.toMillis(timeout));
+        sessionRequest.setConnectTimeout(timeout.toMillisIntBound());
         return sessionRequest;
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestClient.java?rev=1790031&r1=1790030&r2=1790031&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestClient.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/Http1TestClient.java Mon Apr  3 18:23:04 2017
@@ -30,7 +30,6 @@ package org.apache.hc.core5.testing.nio.
 import java.io.IOException;
 import java.net.SocketTimeoutException;
 import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
 
 import javax.net.ssl.SSLContext;
 
@@ -46,6 +45,7 @@ import org.apache.hc.core5.reactor.IORea
 import org.apache.hc.core5.reactor.IOSession;
 import org.apache.hc.core5.reactor.SessionRequest;
 import org.apache.hc.core5.reactor.SessionRequestCallback;
+import org.apache.hc.core5.util.TimeValue;
 
 public class Http1TestClient extends AsyncRequester  {
 
@@ -81,11 +81,10 @@ public class Http1TestClient extends Asy
 
     public Future<ClientSessionEndpoint> connect(
             final HttpHost host,
-            final long timeout,
-            final TimeUnit timeUnit,
+            final TimeValue timeout,
             final FutureCallback<ClientSessionEndpoint> callback) throws InterruptedException {
         final BasicFuture<ClientSessionEndpoint> future = new BasicFuture<>(callback);
-        requestSession(host, timeout, timeUnit, new SessionRequestCallback() {
+        requestSession(host, timeout, new SessionRequestCallback() {
 
             @Override
             public void completed(final SessionRequest request) {
@@ -111,19 +110,12 @@ public class Http1TestClient extends Asy
         return future;
     }
 
-    public Future<ClientSessionEndpoint> connect(
-            final HttpHost host,
-            final long timeout,
-            final TimeUnit timeUnit) throws InterruptedException {
-        return connect(host, timeout, timeUnit, null);
+    public Future<ClientSessionEndpoint> connect(final HttpHost host, final TimeValue timeout) throws InterruptedException {
+        return connect(host, timeout, null);
     }
 
-    public Future<ClientSessionEndpoint> connect(
-            final String hostname,
-            final int port,
-            final long timeout,
-            final TimeUnit timeUnit) throws InterruptedException {
-        return connect(new HttpHost(hostname, port), timeout, timeUnit);
+    public Future<ClientSessionEndpoint> connect(final String hostname, final int port, final TimeValue timeout) throws InterruptedException {
+        return connect(new HttpHost(hostname, port), timeout, null);
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/IOReactorExecutor.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/IOReactorExecutor.java?rev=1790031&r1=1790030&r2=1790031&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/IOReactorExecutor.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http/IOReactorExecutor.java Mon Apr  3 18:23:04 2017
@@ -32,7 +32,6 @@ import java.util.List;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
 
 import org.apache.hc.core5.function.Callback;
@@ -47,6 +46,7 @@ import org.apache.hc.core5.reactor.IORea
 import org.apache.hc.core5.reactor.IOSession;
 import org.apache.hc.core5.util.Args;
 import org.apache.hc.core5.util.Asserts;
+import org.apache.hc.core5.util.TimeValue;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
@@ -143,10 +143,11 @@ abstract class IOReactorExecutor<T exten
         return ioReactor.getAuditLog();
     }
 
-    public void awaitShutdown(final long deadline, final TimeUnit timeUnit) throws InterruptedException {
+    public void awaitShutdown(final TimeValue waitTime) throws InterruptedException {
+        Args.notNull(waitTime, "Wait time");
         final T ioReactor = ioReactorRef.get();
         if (ioReactor != null) {
-            ioReactor.awaitShutdown(deadline, timeUnit);
+            ioReactor.awaitShutdown(waitTime);
         }
     }
 
@@ -159,14 +160,15 @@ abstract class IOReactorExecutor<T exten
         }
     }
 
-    public void shutdown(final long graceTime, final TimeUnit timeUnit) {
+    public void shutdown(final TimeValue graceTime) {
+        Args.notNull(graceTime, "Grace time");
         final T ioReactor = ioReactorRef.get();
         if (ioReactor != null) {
             if (status.compareAndSet(Status.RUNNING, Status.TERMINATED)) {
                 ioReactor.initiateShutdown();
             }
             try {
-                ioReactor.awaitShutdown(graceTime, timeUnit);
+                ioReactor.awaitShutdown(graceTime);
             } catch (InterruptedException e) {
                 Thread.currentThread().interrupt();
             }
@@ -176,7 +178,7 @@ abstract class IOReactorExecutor<T exten
 
     @Override
     public void close() throws Exception {
-        shutdown(5, TimeUnit.SECONDS);
+        shutdown(TimeValue.ofSeconds(5));
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestClient.java?rev=1790031&r1=1790030&r2=1790031&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestClient.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/nio/http2/Http2TestClient.java Mon Apr  3 18:23:04 2017
@@ -30,7 +30,6 @@ package org.apache.hc.core5.testing.nio.
 import java.io.IOException;
 import java.net.SocketTimeoutException;
 import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
 
 import javax.net.ssl.SSLContext;
 
@@ -52,6 +51,7 @@ import org.apache.hc.core5.reactor.Sessi
 import org.apache.hc.core5.testing.nio.http.AsyncRequester;
 import org.apache.hc.core5.testing.nio.http.ClientSessionEndpoint;
 import org.apache.hc.core5.util.Args;
+import org.apache.hc.core5.util.TimeValue;
 
 public class Http2TestClient extends AsyncRequester {
 
@@ -97,11 +97,10 @@ public class Http2TestClient extends Asy
 
     public Future<ClientSessionEndpoint> connect(
             final HttpHost host,
-            final long timeout,
-            final TimeUnit timeUnit,
+            final TimeValue timeout,
             final FutureCallback<ClientSessionEndpoint> callback) throws InterruptedException {
         final BasicFuture<ClientSessionEndpoint> future = new BasicFuture<>(callback);
-        requestSession(host, timeout, timeUnit, new SessionRequestCallback() {
+        requestSession(host, timeout, new SessionRequestCallback() {
 
             @Override
             public void completed(final SessionRequest request) {
@@ -127,19 +126,12 @@ public class Http2TestClient extends Asy
         return future;
     }
 
-    public Future<ClientSessionEndpoint> connect(
-            final HttpHost host,
-            final long timeout,
-            final TimeUnit timeUnit) throws InterruptedException {
-        return connect(host, timeout, timeUnit, null);
+    public Future<ClientSessionEndpoint> connect(final HttpHost host,final TimeValue timeout) throws InterruptedException {
+        return connect(host, timeout, null);
     }
 
-    public Future<ClientSessionEndpoint> connect(
-            final String hostname,
-            final int port,
-            final long timeout,
-            final TimeUnit timeUnit) throws InterruptedException {
-        return connect(new HttpHost(hostname, port), timeout, timeUnit);
+    public Future<ClientSessionEndpoint> connect(final String hostname, final int port, final TimeValue timeout) throws InterruptedException {
+        return connect(new HttpHost(hostname, port), timeout, null);
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/compatibility/http2/Http2CompatibilityTest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/compatibility/http2/Http2CompatibilityTest.java?rev=1790031&r1=1790030&r2=1790031&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/compatibility/http2/Http2CompatibilityTest.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/compatibility/http2/Http2CompatibilityTest.java Mon Apr  3 18:23:04 2017
@@ -47,7 +47,6 @@ import org.apache.hc.core5.http.HttpRequ
 import org.apache.hc.core5.http.HttpResponse;
 import org.apache.hc.core5.http.HttpStatus;
 import org.apache.hc.core5.http.Message;
-import org.apache.hc.core5.testing.nio.http.ClientSessionEndpoint;
 import org.apache.hc.core5.http.message.BasicHttpRequest;
 import org.apache.hc.core5.http.nio.AsyncPushConsumer;
 import org.apache.hc.core5.http.nio.BasicRequestProducer;
@@ -57,7 +56,9 @@ import org.apache.hc.core5.http.nio.enti
 import org.apache.hc.core5.http.nio.support.BasicAsyncPushHandler;
 import org.apache.hc.core5.http2.config.H2Config;
 import org.apache.hc.core5.reactor.IOReactorConfig;
+import org.apache.hc.core5.testing.nio.http.ClientSessionEndpoint;
 import org.apache.hc.core5.testing.nio.http2.Http2TestClient;
+import org.apache.hc.core5.util.TimeValue;
 
 public class Http2CompatibilityTest {
 
@@ -110,13 +111,13 @@ public class Http2CompatibilityTest {
     }
 
     void shutdown() throws Exception {
-        client.shutdown(5, TimeUnit.SECONDS);
+        client.shutdown(TimeValue.ofSeconds(5));
     }
 
     private final static String[] REQUEST_URIS = new String[] {"/", "/news.html", "/status.html"};
 
     void execute() throws Exception {
-        final Future<ClientSessionEndpoint> connectFuture = client.connect(target, 5, TimeUnit.SECONDS);
+        final Future<ClientSessionEndpoint> connectFuture = client.connect(target, TimeValue.ofSeconds(5));
         final ClientSessionEndpoint clientEndpoint = connectFuture.get(5, TimeUnit.SECONDS);
 
         final BlockingDeque<RequestResult> resultQueue = new LinkedBlockingDeque<>();

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/Http1IntegrationTest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/Http1IntegrationTest.java?rev=1790031&r1=1790030&r2=1790031&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/Http1IntegrationTest.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/Http1IntegrationTest.java Mon Apr  3 18:23:04 2017
@@ -55,7 +55,6 @@ import java.util.StringTokenizer;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicReference;
 
 import org.apache.hc.core5.function.Supplier;
@@ -125,6 +124,7 @@ import org.apache.hc.core5.reactor.Sessi
 import org.apache.hc.core5.testing.ProtocolScheme;
 import org.apache.hc.core5.util.CharArrayBuffer;
 import org.apache.hc.core5.util.TextUtils;
+import org.apache.hc.core5.util.TimeValue;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -147,8 +147,8 @@ public class Http1IntegrationTest extend
         super(scheme);
     }
 
-    private static final long TIMEOUT = 30;
-    private static final long LONG_TIMEOUT = 60;
+    private static final TimeValue TIMEOUT = TimeValue.ofSeconds(30);
+    private static final TimeValue LONG_TIMEOUT = TimeValue.ofSeconds(60);
 
     private Http1TestClient client;
 
@@ -162,7 +162,7 @@ public class Http1IntegrationTest extend
     @After
     public void cleanup() throws Exception {
         if (client != null) {
-            client.shutdown(3, TimeUnit.SECONDS);
+            client.shutdown(TimeValue.ofSeconds(5));
         }
     }
 
@@ -188,14 +188,14 @@ public class Http1IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         for (int i = 0; i < 5; i++) {
             final Future<Message<HttpResponse, String>> future = streamEndpoint.execute(
                     new BasicRequestProducer("GET", createRequestURI(serverEndpoint, "/hello")),
                     new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-            final Message<HttpResponse, String> result = future.get(TIMEOUT, TimeUnit.SECONDS);
+            final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
             Assert.assertNotNull(result);
             final HttpResponse response1 = result.getHead();
             final String entity1 = result.getBody();
@@ -219,13 +219,13 @@ public class Http1IntegrationTest extend
         final InetSocketAddress serverEndpoint = server.start(httpProcessor, H1Config.DEFAULT);
 
         client.start();
-        final Future<ClientSessionEndpoint> connectFuture = client.connect("localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+        final Future<ClientSessionEndpoint> connectFuture = client.connect("localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final Future<Message<HttpResponse, String>> future = streamEndpoint.execute(
                 new BasicRequestProducer("GET", createRequestURI(serverEndpoint, "/hello")),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-        final Message<HttpResponse, String> result = future.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result);
         final HttpResponse response = result.getHead();
         final String entity = result.getBody();
@@ -248,7 +248,7 @@ public class Http1IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final Queue<Future<Message<HttpResponse, String>>> queue = new LinkedList<>();
@@ -259,7 +259,7 @@ public class Http1IntegrationTest extend
         }
         while (!queue.isEmpty()) {
             final Future<Message<HttpResponse, String>> future = queue.remove();
-            final Message<HttpResponse, String> result = future.get(TIMEOUT, TimeUnit.SECONDS);
+            final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
             Assert.assertNotNull(result);
             final HttpResponse response = result.getHead();
             final String entity = result.getBody();
@@ -283,14 +283,14 @@ public class Http1IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final Future<Message<HttpResponse, String>> future1 = streamEndpoint.execute(
                 new BasicRequestProducer("GET", createRequestURI(serverEndpoint, "/")),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
 
-        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result1);
         final HttpResponse response1 = result1.getHead();
         Assert.assertNotNull(response1);
@@ -306,7 +306,7 @@ public class Http1IntegrationTest extend
                 new BasicRequestProducer("GET", createRequestURI(serverEndpoint, "/")),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer(512)), null);
 
-        final Message<HttpResponse, String> result2 = future2.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result2 = future2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result2);
         final HttpResponse response2 = result2.getHead();
         Assert.assertNotNull(response2);
@@ -333,7 +333,7 @@ public class Http1IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final Queue<Future<Message<HttpResponse, String>>> queue = new LinkedList<>();
@@ -344,7 +344,7 @@ public class Http1IntegrationTest extend
         }
         while (!queue.isEmpty()) {
             final Future<Message<HttpResponse, String>> future = queue.remove();
-            final Message<HttpResponse, String> result = future.get(LONG_TIMEOUT, TimeUnit.SECONDS);
+            final Message<HttpResponse, String> result = future.get(LONG_TIMEOUT.getDuration(), LONG_TIMEOUT.getTimeUnit());
             Assert.assertNotNull(result);
             final HttpResponse response = result.getHead();
             Assert.assertNotNull(response);
@@ -372,7 +372,7 @@ public class Http1IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         for (int i = 0; i < 5; i++) {
@@ -380,7 +380,7 @@ public class Http1IntegrationTest extend
                     new BasicRequestProducer("POST", createRequestURI(serverEndpoint, "/hello"),
                             new BasicAsyncEntityProducer("Hi there")),
                     new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-            final Message<HttpResponse, String> result = future.get(TIMEOUT, TimeUnit.SECONDS);
+            final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
             Assert.assertNotNull(result);
             final HttpResponse response1 = result.getHead();
             final String entity1 = result.getBody();
@@ -404,7 +404,7 @@ public class Http1IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final Queue<Future<Message<HttpResponse, String>>> queue = new LinkedList<>();
@@ -416,7 +416,7 @@ public class Http1IntegrationTest extend
         }
         while (!queue.isEmpty()) {
             final Future<Message<HttpResponse, String>> future = queue.remove();
-            final Message<HttpResponse, String> result = future.get(TIMEOUT, TimeUnit.SECONDS);
+            final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
             Assert.assertNotNull(result);
             final HttpResponse response = result.getHead();
             final String entity = result.getBody();
@@ -440,7 +440,7 @@ public class Http1IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         for (int i = 0; i < 5; i++) {
@@ -449,7 +449,7 @@ public class Http1IntegrationTest extend
             final Future<Message<HttpResponse, String>> future = streamEndpoint.execute(
                     new BasicRequestProducer(request, new BasicAsyncEntityProducer("Hi there")),
                     new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-            final Message<HttpResponse, String> result = future.get(TIMEOUT, TimeUnit.SECONDS);
+            final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
             Assert.assertNotNull(result);
             final HttpResponse response1 = result.getHead();
             final String entity1 = result.getBody();
@@ -473,7 +473,7 @@ public class Http1IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         for (int i = 0; i < 5; i++) {
@@ -481,7 +481,7 @@ public class Http1IntegrationTest extend
             final Future<Message<HttpResponse, String>> future = streamEndpoint.execute(
                     new BasicRequestProducer(request, null),
                     new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-            final Message<HttpResponse, String> result = future.get(TIMEOUT, TimeUnit.SECONDS);
+            final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
             Assert.assertNotNull(result);
             final HttpResponse response1 = result.getHead();
             final String entity1 = result.getBody();
@@ -505,7 +505,7 @@ public class Http1IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         for (int i = 0; i < 5; i++) {
@@ -513,7 +513,7 @@ public class Http1IntegrationTest extend
                     new BasicRequestProducer("POST", createRequestURI(serverEndpoint, "/echo"),
                             new MultiLineEntityProducer("0123456789abcdef", 5000)),
                     new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-            final Message<HttpResponse, String> result = future.get(TIMEOUT, TimeUnit.SECONDS);
+            final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
             Assert.assertNotNull(result);
             final HttpResponse response = result.getHead();
             Assert.assertNotNull(response);
@@ -541,7 +541,7 @@ public class Http1IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final Queue<Future<Message<HttpResponse, String>>> queue = new LinkedList<>();
@@ -553,7 +553,7 @@ public class Http1IntegrationTest extend
         }
         while (!queue.isEmpty()) {
             final Future<Message<HttpResponse, String>> future = queue.remove();
-            final Message<HttpResponse, String> result = future.get(TIMEOUT, TimeUnit.SECONDS);
+            final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
             Assert.assertNotNull(result);
             final HttpResponse response = result.getHead();
             Assert.assertNotNull(response);
@@ -582,7 +582,7 @@ public class Http1IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final Queue<Future<Message<HttpResponse, String>>> queue = new LinkedList<>();
@@ -594,7 +594,7 @@ public class Http1IntegrationTest extend
         }
         while (!queue.isEmpty()) {
             final Future<Message<HttpResponse, String>> future = queue.remove();
-            final Message<HttpResponse, String> result = future.get(TIMEOUT, TimeUnit.SECONDS);
+            final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
             Assert.assertNotNull(result);
             final HttpResponse response = result.getHead();
             Assert.assertNotNull(response);
@@ -622,14 +622,14 @@ public class Http1IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         for (int i = 0; i < 5; i++) {
             final Future<Message<HttpResponse, String>> future = streamEndpoint.execute(
                     new BasicRequestProducer("HEAD", createRequestURI(serverEndpoint, "/hello")),
                     new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-            final Message<HttpResponse, String> result = future.get(TIMEOUT, TimeUnit.SECONDS);
+            final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
             Assert.assertNotNull(result);
             final HttpResponse response1 = result.getHead();
             Assert.assertNotNull(response1);
@@ -652,7 +652,7 @@ public class Http1IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final Queue<Future<Message<HttpResponse, String>>> queue = new LinkedList<>();
@@ -663,7 +663,7 @@ public class Http1IntegrationTest extend
         }
         while (!queue.isEmpty()) {
             final Future<Message<HttpResponse, String>> future = queue.remove();
-            final Message<HttpResponse, String> result = future.get(TIMEOUT, TimeUnit.SECONDS);
+            final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
             Assert.assertNotNull(result);
             final HttpResponse response1 = result.getHead();
             Assert.assertNotNull(response1);
@@ -709,7 +709,7 @@ public class Http1IntegrationTest extend
 
         client.start();
         final SessionRequest sessionRequest = client.requestSession(
-                new HttpHost("localhost", serverEndpoint.getPort()), TIMEOUT, TimeUnit.SECONDS, null);
+                new HttpHost("localhost", serverEndpoint.getPort()), TIMEOUT, null);
         sessionRequest.waitFor();
         final IOSession ioSession = sessionRequest.getSession();
         final ClientSessionEndpoint streamEndpoint = new ClientSessionEndpoint(ioSession);
@@ -724,7 +724,7 @@ public class Http1IntegrationTest extend
         final Future<Message<HttpResponse, String>> future1 = streamEndpoint.execute(
                 new BasicRequestProducer(request1, new MultiLineEntityProducer("0123456789abcdef", 1000)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result1);
         final HttpResponse response1 = result1.getHead();
         Assert.assertNotNull(response1);
@@ -737,7 +737,7 @@ public class Http1IntegrationTest extend
         final Future<Message<HttpResponse, String>> future2 = streamEndpoint.execute(
                 new BasicRequestProducer(request2, new MultiLineEntityProducer("0123456789abcdef", 5000)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-        final Message<HttpResponse, String> result2 = future2.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result2 = future2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result2);
         final HttpResponse response2 = result2.getHead();
         Assert.assertNotNull(response2);
@@ -751,7 +751,7 @@ public class Http1IntegrationTest extend
         final Future<Message<HttpResponse, String>> future3 = streamEndpoint.execute(
                 new BasicRequestProducer(request3, new MultiLineEntityProducer("0123456789abcdef", 1000)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-        final Message<HttpResponse, String> result3 = future3.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result3 = future3.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result3);
         final HttpResponse response3 = result3.getHead();
         Assert.assertNotNull(response3);
@@ -764,7 +764,7 @@ public class Http1IntegrationTest extend
         final Future<Message<HttpResponse, String>> future4 = streamEndpoint.execute(
                 new BasicRequestProducer(request4, new BasicAsyncEntityProducer("blah")),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-        final Message<HttpResponse, String> result4 = future4.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result4 = future4.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result4);
         final HttpResponse response4 = result4.getHead();
         Assert.assertNotNull(response4);
@@ -856,7 +856,7 @@ public class Http1IntegrationTest extend
 
         client.start(H1Config.custom().setWaitForContinueTimeout(100).build());
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final Queue<Future<Message<HttpResponse, String>>> queue = new LinkedList<>();
@@ -868,7 +868,7 @@ public class Http1IntegrationTest extend
         }
         while (!queue.isEmpty()) {
             final Future<Message<HttpResponse, String>> future = queue.remove();
-            final Message<HttpResponse, String> result = future.get(LONG_TIMEOUT, TimeUnit.SECONDS);
+            final Message<HttpResponse, String> result = future.get(LONG_TIMEOUT.getDuration(), LONG_TIMEOUT.getTimeUnit());
             Assert.assertNotNull(result);
             final HttpResponse response = result.getHead();
             Assert.assertNotNull(response);
@@ -944,14 +944,14 @@ public class Http1IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final HttpRequest request1 = new BasicHttpRequest("POST", createRequestURI(serverEndpoint, "/echo"));
         final Future<Message<HttpResponse, String>> future1 = streamEndpoint.execute(
                 new BasicRequestProducer(request1, new MultiLineEntityProducer("0123456789abcdef", 5000)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result1);
         final HttpResponse response1 = result1.getHead();
         Assert.assertNotNull(response1);
@@ -974,7 +974,7 @@ public class Http1IntegrationTest extend
         client.start(H1Config.custom().setBufferSize(256).build());
 
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final HttpRequest request1 = new BasicHttpRequest("GET", createRequestURI(serverEndpoint, "/"));
@@ -1007,7 +1007,7 @@ public class Http1IntegrationTest extend
                 }),
                 null);
 
-        final Message<HttpResponse, String> result1 = future1.get(LONG_TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result1 = future1.get(LONG_TIMEOUT.getDuration(), LONG_TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result1);
         final HttpResponse response1 = result1.getHead();
         Assert.assertNotNull(response1);
@@ -1034,7 +1034,7 @@ public class Http1IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final HttpRequest request1 = new BasicHttpRequest("POST", createRequestURI(serverEndpoint, "/echo"));
@@ -1063,7 +1063,7 @@ public class Http1IntegrationTest extend
 
                 }),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-        final Message<HttpResponse, String> result1 = future1.get(LONG_TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result1 = future1.get(LONG_TIMEOUT.getDuration(), LONG_TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result1);
         final HttpResponse response1 = result1.getHead();
         Assert.assertNotNull(response1);
@@ -1140,14 +1140,14 @@ public class Http1IntegrationTest extend
         client.start(H1Config.custom().setBufferSize(256).build());
 
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final HttpRequest request1 = new BasicHttpRequest("POST", createRequestURI(serverEndpoint, "/hello"));
         final Future<Message<HttpResponse, String>> future1 = streamEndpoint.execute(
                 new BasicRequestProducer(request1, new MultiLineEntityProducer("0123456789abcd", 2000)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-        final Message<HttpResponse, String> result1 = future1.get(LONG_TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result1 = future1.get(LONG_TIMEOUT.getDuration(), LONG_TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result1);
         final HttpResponse response1 = result1.getHead();
         Assert.assertNotNull(response1);
@@ -1174,7 +1174,7 @@ public class Http1IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final Future<Message<HttpResponse, String>> future1 = streamEndpoint.execute(
@@ -1192,7 +1192,7 @@ public class Http1IntegrationTest extend
                         new BasicAsyncEntityProducer("Hi there")),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
 
-        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result1);
         final HttpResponse response1 = result1.getHead();
         final String entity1 = result1.getBody();
@@ -1200,7 +1200,7 @@ public class Http1IntegrationTest extend
         Assert.assertEquals(200, response1.getCode());
         Assert.assertEquals("Hi back", entity1);
 
-        final Message<HttpResponse, String> result2 = future2.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result2 = future2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result2);
         final HttpResponse response2 = result2.getHead();
         final String entity2 = result2.getBody();
@@ -1209,7 +1209,7 @@ public class Http1IntegrationTest extend
         Assert.assertEquals("Hi back", entity2);
 
         try {
-            final Message<HttpResponse, String> result3 = future3.get(TIMEOUT, TimeUnit.SECONDS);
+            final Message<HttpResponse, String> result3 = future3.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
             Assert.assertNull(result3);
             Assert.assertTrue(future3.isCancelled());
         } catch (final ExecutionException ignore) {
@@ -1219,7 +1219,7 @@ public class Http1IntegrationTest extend
                 new BasicRequestProducer("POST", createRequestURI(serverEndpoint, "/hello-3"),
                         new BasicAsyncEntityProducer("Hi there")),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-        final Message<HttpResponse, String> result4 = future4.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result4 = future4.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNull(result4);
         Assert.assertTrue(future4.isCancelled());
     }
@@ -1238,7 +1238,7 @@ public class Http1IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final Future<Message<HttpResponse, String>> future1 = streamEndpoint.execute(
@@ -1256,7 +1256,7 @@ public class Http1IntegrationTest extend
                         new BasicAsyncEntityProducer("Hi there")),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
 
-        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result1);
         final HttpResponse response1 = result1.getHead();
         final String entity1 = result1.getBody();
@@ -1264,7 +1264,7 @@ public class Http1IntegrationTest extend
         Assert.assertEquals(200, response1.getCode());
         Assert.assertEquals("Hi back", entity1);
 
-        final Message<HttpResponse, String> result2 = future2.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result2 = future2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result2);
         final HttpResponse response2 = result2.getHead();
         final String entity2 = result2.getBody();
@@ -1273,7 +1273,7 @@ public class Http1IntegrationTest extend
         Assert.assertTrue(entity2.length() > 0);
 
         try {
-            final Message<HttpResponse, String> result3 = future3.get(TIMEOUT, TimeUnit.SECONDS);
+            final Message<HttpResponse, String> result3 = future3.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
             Assert.assertNull(result3);
             Assert.assertTrue(future3.isCancelled());
         } catch (final ExecutionException ignore) {
@@ -1394,7 +1394,7 @@ public class Http1IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final AsyncRequestProducer requestProducer = new BasicRequestProducer("GET", createRequestURI(serverEndpoint, "/hello"));
@@ -1433,13 +1433,13 @@ public class Http1IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final Future<Message<HttpResponse, String>> future = streamEndpoint.execute(
                 new BasicRequestProducer("GET", createRequestURI(serverEndpoint, "/hello")),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-        final Message<HttpResponse, String> result = future.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result);
         final HttpResponse response1 = result.getHead();
         final String entity1 = result.getBody();
@@ -1454,13 +1454,13 @@ public class Http1IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final Future<Message<HttpResponse, String>> future = streamEndpoint.execute(
                 new BasicRequestProducer("GET", createRequestURI(serverEndpoint, "/hello")),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-        final Message<HttpResponse, String> result = future.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result);
         final HttpResponse response1 = result.getHead();
         final String entity1 = result.getBody();
@@ -1493,13 +1493,13 @@ public class Http1IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final Future<Message<HttpResponse, String>> future = streamEndpoint.execute(
                 new BasicRequestProducer("GET", createRequestURI(serverEndpoint, "/hello")),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-        final Message<HttpResponse, String> result = future.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result);
         final HttpResponse response1 = result.getHead();
         Assert.assertNotNull(response1);
@@ -1522,7 +1522,7 @@ public class Http1IntegrationTest extend
         client.start(new DefaultHttpProcessor(new RequestContent(), new RequestConnControl()), H1Config.DEFAULT);
 
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final HttpRequest request1 = new BasicHttpRequest("GET", createRequestURI(serverEndpoint, "/hello"));
@@ -1530,7 +1530,7 @@ public class Http1IntegrationTest extend
         final Future<Message<HttpResponse, String>> future1 = streamEndpoint.execute(
                 new BasicRequestProducer(request1, null),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result1);
         final HttpResponse response1 = result1.getHead();
         Assert.assertNotNull(response1);
@@ -1542,7 +1542,7 @@ public class Http1IntegrationTest extend
         final Future<Message<HttpResponse, String>> future2 = streamEndpoint.execute(
                 new BasicRequestProducer(request2, null),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-        final Message<HttpResponse, String> result2 = future2.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result2 = future2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result2);
         final HttpResponse response2 = result2.getHead();
         Assert.assertNotNull(response2);
@@ -1583,7 +1583,7 @@ public class Http1IntegrationTest extend
         client.start();
 
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final HttpRequest request1 = new BasicHttpRequest("GET", createRequestURI(serverEndpoint, "/hello"));
@@ -1591,7 +1591,7 @@ public class Http1IntegrationTest extend
         final Future<Message<HttpResponse, String>> future1 = streamEndpoint.execute(
                 new BasicRequestProducer(request1, null),
                 new BasicResponseConsumer<>(entityConsumer), null);
-        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result1);
         final HttpResponse response1 = result1.getHead();
         Assert.assertNotNull(response1);

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/InternalServerTestBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/InternalServerTestBase.java?rev=1790031&r1=1790030&r2=1790031&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/InternalServerTestBase.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http/InternalServerTestBase.java Mon Apr  3 18:23:04 2017
@@ -28,13 +28,13 @@
 package org.apache.hc.core5.testing.nio.http;
 
 import java.net.URL;
-import java.util.concurrent.TimeUnit;
 
 import javax.net.ssl.SSLContext;
 
 import org.apache.hc.core5.reactor.IOReactorConfig;
 import org.apache.hc.core5.ssl.SSLContextBuilder;
 import org.apache.hc.core5.testing.ProtocolScheme;
+import org.apache.hc.core5.util.TimeValue;
 import org.junit.Rule;
 import org.junit.rules.ExternalResource;
 
@@ -66,7 +66,7 @@ public abstract class InternalServerTest
         protected void after() {
             if (server != null) {
                 try {
-                    server.shutdown(3, TimeUnit.SECONDS);
+                    server.shutdown(TimeValue.ofSeconds(5));
                     server = null;
                 } catch (final Exception ignore) {
                 }

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/Http2IntegrationTest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/Http2IntegrationTest.java?rev=1790031&r1=1790030&r2=1790031&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/Http2IntegrationTest.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/Http2IntegrationTest.java Mon Apr  3 18:23:04 2017
@@ -70,7 +70,6 @@ import org.apache.hc.core5.http.HttpRequ
 import org.apache.hc.core5.http.HttpResponse;
 import org.apache.hc.core5.http.HttpStatus;
 import org.apache.hc.core5.http.Message;
-import org.apache.hc.core5.testing.nio.http.ClientSessionEndpoint;
 import org.apache.hc.core5.http.impl.nio.AbstractClassicServerExchangeHandler;
 import org.apache.hc.core5.http.impl.nio.entity.AbstractClassicEntityConsumer;
 import org.apache.hc.core5.http.impl.nio.entity.AbstractClassicEntityProducer;
@@ -104,12 +103,14 @@ import org.apache.hc.core5.http2.nio.com
 import org.apache.hc.core5.http2.nio.support.BasicPingHandler;
 import org.apache.hc.core5.reactor.IOReactorConfig;
 import org.apache.hc.core5.testing.ProtocolScheme;
+import org.apache.hc.core5.testing.nio.http.ClientSessionEndpoint;
 import org.apache.hc.core5.testing.nio.http.EchoHandler;
 import org.apache.hc.core5.testing.nio.http.MessageExchangeHandler;
 import org.apache.hc.core5.testing.nio.http.MultiLineEntityProducer;
 import org.apache.hc.core5.testing.nio.http.MultiLineResponseHandler;
 import org.apache.hc.core5.testing.nio.http.SingleLineResponseHandler;
 import org.apache.hc.core5.util.TextUtils;
+import org.apache.hc.core5.util.TimeValue;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
@@ -132,8 +133,8 @@ public class Http2IntegrationTest extend
         super(scheme);
     }
 
-    private static final long TIMEOUT = 30;
-    private static final long LONG_TIMEOUT = 60;
+    private static final TimeValue TIMEOUT = TimeValue.ofSeconds(30);
+    private static final TimeValue LONG_TIMEOUT = TimeValue.ofSeconds(60);
 
     private Http2TestClient client;
 
@@ -146,7 +147,7 @@ public class Http2IntegrationTest extend
     @After
     public void cleanup() throws Exception {
         if (client != null) {
-            client.shutdown(3, TimeUnit.SECONDS);
+            client.shutdown(TimeValue.ofSeconds(5));
         }
     }
 
@@ -172,7 +173,7 @@ public class Http2IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final Queue<Future<Message<HttpResponse, String>>> queue = new LinkedList<>();
@@ -184,7 +185,7 @@ public class Http2IntegrationTest extend
         }
         while (!queue.isEmpty()) {
             final Future<Message<HttpResponse, String>> future = queue.remove();
-            final Message<HttpResponse, String> result = future.get(TIMEOUT, TimeUnit.SECONDS);
+            final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
             Assert.assertNotNull(result);
             final HttpResponse response = result.getHead();
             final String entity = result.getBody();
@@ -208,7 +209,7 @@ public class Http2IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final Future<Message<HttpResponse, String>> future1 = streamEndpoint.execute(
@@ -219,7 +220,7 @@ public class Http2IntegrationTest extend
                 new BasicRequestProducer("GET", createRequestURI(serverEndpoint, "/")),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer(512)), null);
 
-        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result1);
         final HttpResponse response1 = result1.getHead();
         Assert.assertNotNull(response1);
@@ -231,7 +232,7 @@ public class Http2IntegrationTest extend
             Assert.assertEquals("0123456789abcdef", t1.nextToken());
         }
 
-        final Message<HttpResponse, String> result2 = future2.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result2 = future2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result2);
         final HttpResponse response2 = result2.getHead();
         Assert.assertNotNull(response2);
@@ -258,7 +259,7 @@ public class Http2IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final Queue<Future<Message<HttpResponse, String>>> queue = new LinkedList<>();
@@ -271,7 +272,7 @@ public class Http2IntegrationTest extend
         }
         while (!queue.isEmpty()) {
             final Future<Message<HttpResponse, String>> future = queue.remove();
-            final Message<HttpResponse, String> result = future.get(TIMEOUT, TimeUnit.SECONDS);
+            final Message<HttpResponse, String> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
             Assert.assertNotNull(result);
             final HttpResponse response = result.getHead();
             final String entity1 = result.getBody();
@@ -295,14 +296,14 @@ public class Http2IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final Future<Message<HttpResponse, String>> future1 = streamEndpoint.execute(
                 new BasicRequestProducer("POST", createRequestURI(serverEndpoint, "/echo"),
                         new MultiLineEntityProducer("0123456789abcdef", 5000)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result1);
         final HttpResponse response1 = result1.getHead();
         Assert.assertNotNull(response1);
@@ -329,7 +330,7 @@ public class Http2IntegrationTest extend
 
         client.start(H2Config.custom().setInitialWindowSize(16).build());
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final Future<Message<HttpResponse, String>> future1 = streamEndpoint.execute(
@@ -361,7 +362,7 @@ public class Http2IntegrationTest extend
                 }),
                 null);
 
-        final Message<HttpResponse, String> result1 = future1.get(LONG_TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result1 = future1.get(LONG_TIMEOUT.getDuration(), LONG_TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result1);
         final HttpResponse response1 = result1.getHead();
         Assert.assertNotNull(response1);
@@ -388,7 +389,7 @@ public class Http2IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final HttpRequest request1 = new BasicHttpRequest("POST", createRequestURI(serverEndpoint, "/echo"));
@@ -417,7 +418,7 @@ public class Http2IntegrationTest extend
 
                 }),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-        final Message<HttpResponse, String> result1 = future1.get(LONG_TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result1 = future1.get(LONG_TIMEOUT.getDuration(), LONG_TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result1);
         final HttpResponse response1 = result1.getHead();
         Assert.assertNotNull(response1);
@@ -496,14 +497,14 @@ public class Http2IntegrationTest extend
                 .build());
 
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final HttpRequest request1 = new BasicHttpRequest("POST", createRequestURI(serverEndpoint, "/hello"));
         final Future<Message<HttpResponse, String>> future1 = streamEndpoint.execute(
                 new BasicRequestProducer(request1, new MultiLineEntityProducer("0123456789abcd", 2000)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-        final Message<HttpResponse, String> result1 = future1.get(LONG_TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result1 = future1.get(LONG_TIMEOUT.getDuration(), LONG_TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result1);
         final HttpResponse response1 = result1.getHead();
         Assert.assertNotNull(response1);
@@ -569,13 +570,13 @@ public class Http2IntegrationTest extend
         });
 
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final Future<Message<HttpResponse, String>> future1 = streamEndpoint.execute(
                 new BasicRequestProducer("GET", createRequestURI(serverEndpoint, "/hello")),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result1);
         final HttpResponse response1 = result1.getHead();
         final String entity1 = result1.getBody();
@@ -645,13 +646,13 @@ public class Http2IntegrationTest extend
         client.start(H2Config.custom().setPushEnabled(true).build());
 
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final Future<Message<HttpResponse, String>> future1 = streamEndpoint.execute(
                 new BasicRequestProducer("GET", createRequestURI(serverEndpoint, "/hello")),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result1);
         final HttpResponse response1 = result1.getHead();
         final String entity1 = result1.getBody();
@@ -684,7 +685,7 @@ public class Http2IntegrationTest extend
 
         client.start(H2Config.custom().setMaxConcurrentStreams(20).build());
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final Queue<Future<Message<HttpResponse, Void>>> queue = new LinkedList<>();
@@ -698,7 +699,7 @@ public class Http2IntegrationTest extend
 
         while (!queue.isEmpty()) {
             final Future<Message<HttpResponse, Void>> future = queue.remove();
-            final Message<HttpResponse, Void> result = future.get(TIMEOUT, TimeUnit.SECONDS);
+            final Message<HttpResponse, Void> result = future.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
             Assert.assertNotNull(result);
             final HttpResponse response = result.getHead();
             Assert.assertNotNull(response);
@@ -743,7 +744,7 @@ public class Http2IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final HttpRequest request1 = new BasicHttpRequest("POST", createRequestURI(serverEndpoint, "/echo"));
@@ -751,7 +752,7 @@ public class Http2IntegrationTest extend
         final Future<Message<HttpResponse, String>> future1 = streamEndpoint.execute(
                 new BasicRequestProducer(request1, new MultiLineEntityProducer("0123456789abcdef", 5000)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result1);
         final HttpResponse response1 = result1.getHead();
         Assert.assertNotNull(response1);
@@ -762,7 +763,7 @@ public class Http2IntegrationTest extend
         final Future<Message<HttpResponse, String>> future2 = streamEndpoint.execute(
                 new BasicRequestProducer(request2, new MultiLineEntityProducer("0123456789abcdef", 5000)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-        final Message<HttpResponse, String> result2 = future2.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result2 = future2.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result2);
         final HttpResponse response2 = result2.getHead();
         Assert.assertNotNull(response2);
@@ -837,14 +838,14 @@ public class Http2IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final HttpRequest request1 = new BasicHttpRequest("POST", createRequestURI(serverEndpoint, "/echo"));
         final Future<Message<HttpResponse, String>> future1 = streamEndpoint.execute(
                 new BasicRequestProducer(request1, new MultiLineEntityProducer("0123456789abcdef", 5000)),
                 new BasicResponseConsumer<>(new StringAsyncEntityConsumer()), null);
-        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result1);
         final HttpResponse response1 = result1.getHead();
         Assert.assertNotNull(response1);
@@ -885,7 +886,7 @@ public class Http2IntegrationTest extend
         client.start();
 
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final HttpRequest request1 = new BasicHttpRequest("GET", createRequestURI(serverEndpoint, "/hello"));
@@ -893,7 +894,7 @@ public class Http2IntegrationTest extend
         final Future<Message<HttpResponse, String>> future1 = streamEndpoint.execute(
                 new BasicRequestProducer(request1, null),
                 new BasicResponseConsumer<>(entityConsumer), null);
-        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT, TimeUnit.SECONDS);
+        final Message<HttpResponse, String> result1 = future1.get(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit());
         Assert.assertNotNull(result1);
         final HttpResponse response1 = result1.getHead();
         Assert.assertNotNull(response1);
@@ -926,7 +927,7 @@ public class Http2IntegrationTest extend
 
         client.start();
         final Future<ClientSessionEndpoint> connectFuture = client.connect(
-                "localhost", serverEndpoint.getPort(), TIMEOUT, TimeUnit.SECONDS);
+                "localhost", serverEndpoint.getPort(), TIMEOUT);
         final ClientSessionEndpoint streamEndpoint = connectFuture.get();
 
         final int n = 10;
@@ -949,7 +950,7 @@ public class Http2IntegrationTest extend
             })));
 
         }
-        Assert.assertTrue(latch.await(TIMEOUT, TimeUnit.SECONDS));
+        Assert.assertTrue(latch.await(TIMEOUT.getDuration(), TIMEOUT.getTimeUnit()));
         Assert.assertEquals(n, count.get());
     }
 

Modified: httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/InternalServerTestBase.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/InternalServerTestBase.java?rev=1790031&r1=1790030&r2=1790031&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/InternalServerTestBase.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/nio/http2/InternalServerTestBase.java Mon Apr  3 18:23:04 2017
@@ -28,13 +28,13 @@
 package org.apache.hc.core5.testing.nio.http2;
 
 import java.net.URL;
-import java.util.concurrent.TimeUnit;
 
 import javax.net.ssl.SSLContext;
 
 import org.apache.hc.core5.reactor.IOReactorConfig;
 import org.apache.hc.core5.ssl.SSLContextBuilder;
 import org.apache.hc.core5.testing.ProtocolScheme;
+import org.apache.hc.core5.util.TimeValue;
 import org.junit.Rule;
 import org.junit.rules.ExternalResource;
 
@@ -65,7 +65,7 @@ public abstract class InternalServerTest
         protected void after() {
             if (server != null) {
                 try {
-                    server.shutdown(3, TimeUnit.SECONDS);
+                    server.shutdown(TimeValue.ofSeconds(5));
                     server = null;
                 } catch (final Exception ignore) {
                 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncFileServerExample.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncFileServerExample.java?rev=1790031&r1=1790030&r2=1790031&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncFileServerExample.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncFileServerExample.java Mon Apr  3 18:23:04 2017
@@ -61,6 +61,7 @@ import org.apache.hc.core5.http.protocol
 import org.apache.hc.core5.io.ShutdownType;
 import org.apache.hc.core5.reactor.IOReactorConfig;
 import org.apache.hc.core5.reactor.ListenerEndpoint;
+import org.apache.hc.core5.util.TimeValue;
 
 /**
  * Example of asynchronous embedded HTTP/1.1 file server.
@@ -199,7 +200,7 @@ public class AsyncFileServerExample {
         ListenerEndpoint listenerEndpoint = server.listen(new InetSocketAddress(port));
         listenerEndpoint.waitFor();
         System.out.print("Listening on " + listenerEndpoint.getAddress());
-        server.awaitShutdown(Long.MAX_VALUE, TimeUnit.DAYS);
+        server.awaitShutdown(TimeValue.MAX_VALUE);
     }
 
 }

Modified: httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncPipelinedRequestExecutionExample.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncPipelinedRequestExecutionExample.java?rev=1790031&r1=1790030&r2=1790031&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncPipelinedRequestExecutionExample.java (original)
+++ httpcomponents/httpcore/trunk/httpcore5/src/examples/org/apache/hc/core5/http/examples/AsyncPipelinedRequestExecutionExample.java Mon Apr  3 18:23:04 2017
@@ -47,6 +47,7 @@ import org.apache.hc.core5.http.nio.Basi
 import org.apache.hc.core5.http.nio.entity.StringAsyncEntityConsumer;
 import org.apache.hc.core5.io.ShutdownType;
 import org.apache.hc.core5.reactor.IOReactorConfig;
+import org.apache.hc.core5.util.TimeValue;
 
 /**
  * Example of asynchronous HTTP/1.1 request execution.
@@ -100,7 +101,7 @@ public class AsyncPipelinedRequestExecut
         HttpHost target = new HttpHost("httpbin.org");
         String[] requestUris = new String[] {"/", "/ip", "/user-agent", "/headers"};
 
-        Future<AsyncClientEndpoint> future = requester.connect(target, 5, TimeUnit.SECONDS);
+        Future<AsyncClientEndpoint> future = requester.connect(target, TimeValue.ofSeconds(5));
         AsyncClientEndpoint clientEndpoint = future.get();
 
         final CountDownLatch latch = new CountDownLatch(requestUris.length);



Mime
View raw message