Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id F0E692009C6 for ; Sun, 1 May 2016 21:36:20 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id EF66B1609AD; Sun, 1 May 2016 21:36:20 +0200 (CEST) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B8A671609BB for ; Sun, 1 May 2016 21:36:19 +0200 (CEST) Received: (qmail 56267 invoked by uid 500); 1 May 2016 19:36:18 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 55345 invoked by uid 99); 1 May 2016 19:36:17 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 May 2016 19:36:17 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 92560E0F85; Sun, 1 May 2016 19:36:17 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: reta@apache.org To: commits@cxf.apache.org Date: Sun, 01 May 2016 19:36:40 -0000 Message-Id: In-Reply-To: <1ff1278166f8470598d48bddc4363f44@git.apache.org> References: <1ff1278166f8470598d48bddc4363f44@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [24/36] cxf git commit: [CXF-6833] Adding a HelloWorld async server test archived-at: Sun, 01 May 2016 19:36:21 -0000 [CXF-6833] Adding a HelloWorld async server test Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/4786e832 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/4786e832 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/4786e832 Branch: refs/heads/master-jaxrs-2.1 Commit: 4786e832573f1fcc07ed190ab21fdb2820348e4d Parents: 6c32442 Author: Sergey Beryozkin Authored: Fri Apr 29 14:21:39 2016 +0100 Committer: Sergey Beryozkin Committed: Fri Apr 29 14:21:39 2016 +0100 ---------------------------------------------------------------------- .../jaxrs/reactive/JAXRSReactiveTest.java | 7 ++++ .../systest/jaxrs/reactive/ReactiveService.java | 36 ++++++++++++++++++++ 2 files changed, 43 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/4786e832/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/JAXRSReactiveTest.java ---------------------------------------------------------------------- diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/JAXRSReactiveTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/JAXRSReactiveTest.java index 0241fed..c92e8fa 100644 --- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/JAXRSReactiveTest.java +++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/JAXRSReactiveTest.java @@ -42,6 +42,13 @@ public class JAXRSReactiveTest extends AbstractBusClientServerTestBase { String text = wc.accept("text/plain").get(String.class); assertEquals("Hello, world!", text); } + @Test + public void testGetHelloWorldAsyncText() throws Exception { + String address = "http://localhost:" + PORT + "/reactive/textAsync"; + WebClient wc = WebClient.create(address); + String text = wc.accept("text/plain").get(String.class); + assertEquals("Hello, world!", text); + } } http://git-wip-us.apache.org/repos/asf/cxf/blob/4786e832/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ReactiveService.java ---------------------------------------------------------------------- diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ReactiveService.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ReactiveService.java index 87ab35a..7127214 100644 --- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ReactiveService.java +++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/reactive/ReactiveService.java @@ -23,8 +23,11 @@ package org.apache.cxf.systest.jaxrs.reactive; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; +import javax.ws.rs.container.AsyncResponse; +import javax.ws.rs.container.Suspended; import rx.Observable; +import rx.Subscriber; @Path("/reactive") @@ -37,6 +40,39 @@ public class ReactiveService { return Observable.just("Hello, world!"); } + @GET + @Produces("text/plain") + @Path("textAsync") + public void getTextAsync(@Suspended final AsyncResponse ar) { + Observable.just("Hello, ").map(s -> s + "world!") + .subscribe(new AsyncResponseSubscriber(ar)); + + } + + private class AsyncResponseSubscriber extends Subscriber { + + private StringBuilder sb = new StringBuilder(); + private AsyncResponse ar; + + AsyncResponseSubscriber(AsyncResponse ar) { + this.ar = ar; + } + @Override + public void onCompleted() { + ar.resume(sb.toString()); + } + + @Override + public void onError(Throwable arg0) { + // TODO Auto-generated method stub + } + + @Override + public void onNext(String s) { + sb.append(s); + } + + } }