cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6889] Adding a basic exception test
Date Mon, 10 Oct 2016 12:28:44 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 6958418ec -> bbda68b6d


[CXF-6889] Adding a basic exception test


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

Branch: refs/heads/master
Commit: bbda68b6d7948d098ee598d248266f4ce81c820a
Parents: 6958418
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Mon Oct 10 13:28:29 2016 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Mon Oct 10 13:28:29 2016 +0100

----------------------------------------------------------------------
 .../cxf/jaxrs/client/JaxrsClientStageCallback.java     |  6 +++---
 .../apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java | 13 +++++++++++++
 2 files changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/bbda68b6/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JaxrsClientStageCallback.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JaxrsClientStageCallback.java
b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JaxrsClientStageCallback.java
index 822d235..c26ffb4 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JaxrsClientStageCallback.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/JaxrsClientStageCallback.java
@@ -21,6 +21,7 @@ package org.apache.cxf.jaxrs.client;
 
 import java.lang.reflect.Type;
 import java.util.Map;
+import java.util.concurrent.CancellationException;
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.CompletionStage;
 import java.util.concurrent.Executor;
@@ -47,7 +48,6 @@ class JaxrsClientStageCallback<T> extends JaxrsClientCallback<T>
 {
     public void handleResponse(Map<String, Object> ctx, Object[] res) {
         context = ctx;
         result = res;
-        //consumer.accept((T)res[0]);
         done = true;
         synchronized (this) {
             notifyAll();
@@ -58,7 +58,7 @@ class JaxrsClientStageCallback<T> extends JaxrsClientCallback<T>
 {
     public void handleException(Map<String, Object> ctx, final Throwable ex) {
         context = ctx;
         exception = ex;
-        //handler.failed(exception);
+        cf.completeExceptionally(ex);
         done = true;
         synchronized (this) {
             notifyAll();
@@ -68,7 +68,7 @@ class JaxrsClientStageCallback<T> extends JaxrsClientCallback<T>
 {
     public boolean cancel(boolean mayInterruptIfRunning) {
         boolean result = super.cancel(mayInterruptIfRunning);
         if (result) {
-            //handler.failed(new CancellationException());
+            cf.completeExceptionally(new CancellationException());
         }
         return result;
     }

http://git-wip-us.apache.org/repos/asf/cxf/blob/bbda68b6/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java
index 568e520..4d32750 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAsyncClientTest.java
@@ -375,6 +375,19 @@ public class JAXRSAsyncClientTest extends AbstractBusClientServerTestBase
{
         Book book = stage.toCompletableFuture().join();
         assertEquals(123L, book.getId());
     }
+    @Test
+    public void testGetBookAsyncStage404() throws Exception {
+        String address = "http://localhost:" + PORT + "/bookstore/bookheaders/404";
+        WebClient wc = createWebClient(address);
+        CompletionStage<Book> stage = wc.path("123").rx().get(Book.class);
+        try {
+            stage.toCompletableFuture().get();
+            fail("Exception expected");
+        } catch (ExecutionException ex) {
+            assertTrue(ex.getCause() instanceof NotFoundException);
+        }
+        
+    }
     private WebClient createWebClient(String address) {
         List<Object> providers = new ArrayList<Object>();
         return WebClient.create(address, providers);


Mime
View raw message