You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2017/01/13 11:55:18 UTC
[2/2] cxf git commit: a test to demonstrate the receiveTimeout
configuration works for the jaxrs async invocation with ahc
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/45f6dac0
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/45f6dac0
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/45f6dac0
Branch: refs/heads/3.1.x-fixes
Commit: 45f6dac04dc543371c9de1ac3fbd4260f7805dd6
Parents: c3b8873
Author: Freeman Fang <fr...@gmail.com>
Authored: Fri Jan 13 12:05:35 2017 +0800
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Fri Jan 13 11:54:56 2017 +0000
----------------------------------------------------------------------
.../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/45f6dac0/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/45f6dac0/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 8713229..ed78c62 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
@@ -52,10 +52,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;
@@ -104,6 +106,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);