cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject cxf git commit: a test to demonstrate the receiveTimeout configuration works for the jaxrs async invocation with ahc
Date Fri, 13 Jan 2017 04:06:04 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 7c472eba7 -> 17c7ebc89


a test to demonstrate the receiveTimeout configuration works for the jaxrs async invocation
with ahc


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

Branch: refs/heads/master
Commit: 17c7ebc890ff2060c2851eaef69a4383fb8f6e45
Parents: 7c472eb
Author: Freeman Fang <freeman.fang@gmail.com>
Authored: Fri Jan 13 12:05:35 2017 +0800
Committer: Freeman Fang <freeman.fang@gmail.com>
Committed: Fri Jan 13 12:05:35 2017 +0800

----------------------------------------------------------------------
 .../org/apache/cxf/systest/jaxrs/BookStore.java | 10 +++++++++-
 .../cxf/systest/jaxrs/JAXRSAsyncClientTest.java | 20 ++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/17c7ebc8/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
index 6e9c6c4..45d2a19 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
@@ -293,7 +293,15 @@ public class BookStore {
     @Produces("application/xml")
     @Consumes("application/xml")
     public Response patchBook(Book book) {
-        return Response.ok(book).build();
+        if (book.getName().equals("Timeout")) {
+            try {
+                Thread.sleep(25000);
+            } catch (InterruptedException e) {
+            }
+            return Response.ok(book).build();
+        } else {
+            return Response.ok(book).build();
+        }
     }
     
     @DELETE

http://git-wip-us.apache.org/repos/asf/cxf/blob/17c7ebc8/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 b313070..8e0baac 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
@@ -53,10 +53,12 @@ import javax.ws.rs.ext.MessageBodyReader;
 import javax.ws.rs.ext.MessageBodyWriter;
 import javax.xml.ws.Holder;
 
+import org.apache.cxf.jaxrs.client.ClientConfiguration;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
 
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -105,6 +107,24 @@ public class JAXRSAsyncClientTest extends AbstractBusClientServerTestBase
{
     }
     
     @Test
+    public void testPatchBookTimeout() throws Exception {
+        String address = "http://localhost:" + PORT + "/bookstore/patch";
+        WebClient wc = WebClient.create(address);
+        wc.type("application/xml");
+        ClientConfiguration clientConfig = WebClient.getConfig(wc);
+        clientConfig.getRequestContext().put("use.async.http.conduit", true);
+        HTTPClientPolicy clientPolicy = clientConfig.getHttpConduit().getClient();
+        clientPolicy.setReceiveTimeout(15000);
+        clientPolicy.setConnectionTimeout(15000);
+        try {
+            Book book = wc.invoke("PATCH", new Book("Timeout", 123L), Book.class);
+            fail("should throw an exception due to timeout");
+        } catch (javax.ws.rs.ProcessingException e) {
+            //expected!!!
+        }
+    }
+    
+    @Test
     public void testPatchBookInputStream() throws Exception {
         String address = "http://localhost:" + PORT + "/bookstore/patch";
         WebClient wc = WebClient.create(address);


Mime
View raw message