You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2018/10/21 17:35:07 UTC

[3/3] httpcomponents-client git commit: Tweaked expected exception check in FutureRequestExecutionService test

Tweaked expected exception check in FutureRequestExecutionService test


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/commit/f4bb8fec
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/tree/f4bb8fec
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-client/diff/f4bb8fec

Branch: refs/heads/master
Commit: f4bb8fec5b5e1c9996fdf94dd739776d51387260
Parents: 59a1bf4
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Sun Oct 21 19:32:13 2018 +0200
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Sun Oct 21 19:32:13 2018 +0200

----------------------------------------------------------------------
 .../classic/TestFutureRequestExecutionService.java  | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/f4bb8fec/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestFutureRequestExecutionService.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestFutureRequestExecutionService.java b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestFutureRequestExecutionService.java
index 7b6c4b0..20f0d32 100644
--- a/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestFutureRequestExecutionService.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/impl/classic/TestFutureRequestExecutionService.java
@@ -53,10 +53,13 @@ import org.apache.hc.core5.http.impl.bootstrap.ServerBootstrap;
 import org.apache.hc.core5.http.io.HttpClientResponseHandler;
 import org.apache.hc.core5.http.io.HttpRequestHandler;
 import org.apache.hc.core5.http.protocol.HttpContext;
+import org.hamcrest.CoreMatchers;
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.ExpectedException;
 
 @SuppressWarnings("boxing") // test code
 public class TestFutureRequestExecutionService {
@@ -67,6 +70,9 @@ public class TestFutureRequestExecutionService {
 
     private final AtomicBoolean blocked = new AtomicBoolean(false);
 
+    @Rule
+    public ExpectedException thrown = ExpectedException.none();
+
     @Before
     public void before() throws Exception {
         this.localServer = ServerBootstrap.bootstrap()
@@ -114,16 +120,22 @@ public class TestFutureRequestExecutionService {
         Assert.assertTrue("request should have returned OK", task.get().booleanValue());
     }
 
-    @Test(expected=CancellationException.class)
+    @Test
     public void shouldCancel() throws InterruptedException, ExecutionException {
+        thrown.expect(CoreMatchers.anyOf(
+                CoreMatchers.instanceOf(CancellationException.class),
+                CoreMatchers.instanceOf(ExecutionException.class)));
+
         final FutureTask<Boolean> task = httpAsyncClientWithFuture.execute(
             new HttpGet(uri), HttpClientContext.create(), new OkidokiHandler());
         task.cancel(true);
         task.get();
     }
 
-    @Test(expected=TimeoutException.class)
+    @Test
     public void shouldTimeout() throws InterruptedException, ExecutionException, TimeoutException {
+        thrown.expect(TimeoutException.class);
+
         blocked.set(true);
         final FutureTask<Boolean> task = httpAsyncClientWithFuture.execute(
             new HttpGet(uri), HttpClientContext.create(), new OkidokiHandler());