From e721aa978d542d7f7668d9027affaafccfa8bab5 Mon Sep 17 00:00:00 2001 From: edwardsmj Date: Tue, 21 Dec 2010 07:22:12 +0000 Subject: Tweaks and extensions to better match the async service implementation in core + JMS binding git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1051397 13f79535-47bb-0310-9956-ffa450edef68 --- .../test/java/sample/UpperSampleAsyncReferenceImpl.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncReferenceImpl.java') diff --git a/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncReferenceImpl.java b/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncReferenceImpl.java index b6f59515cc..7a86d68043 100644 --- a/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncReferenceImpl.java +++ b/sca-java-2.x/trunk/samples/extending-tuscany/implementation-sample/src/test/java/sample/UpperSampleAsyncReferenceImpl.java @@ -24,8 +24,12 @@ import static sample.Xutil.elem; import static sample.Xutil.text; import static sample.Xutil.xdom; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + import org.w3c.dom.Element; +import sample.Xutil.NodeBuilder; import sample.api.Java; import sample.api.WSDL; import sample.api.WSDLReference; @@ -42,6 +46,7 @@ public class UpperSampleAsyncReferenceImpl { WSDLReference upper; Element response; + CountDownLatch latch = new CountDownLatch( 1 ); public String upper(String s) { out.println("UpperSampleAsyncReferenceImpl.upper(" + s + ")"); @@ -49,16 +54,20 @@ public class UpperSampleAsyncReferenceImpl { // TODO - I'm passing in the non-wrapped version of the parameter // here which doesn't seem right. Need to test that databinding // wraps it correctly - final Element ureq = xdom("http://sample/upper-async", "s", text(s)); + //final Element ureq = xdom("http://sample/upper-async", "s", text(s)); + NodeBuilder node1 = elem("s", text(s)); + final Element ureq = xdom("http://sample/upper-async", "upper", node1); upper.callAsync("upper", ureq); try { Thread.sleep(500); + latch.await(500, TimeUnit.SECONDS); } catch (Exception ex) { // do nothing } - return response.getTextContent(); + if( response != null ) return response.getTextContent(); + else return "upper did not get called back"; } /** @@ -69,5 +78,6 @@ public class UpperSampleAsyncReferenceImpl { public void upperCallback(Element response) { out.println("UpperSampleAsyncReferenceImpl.upperCallback(" + response.getTextContent() + ")"); this.response = response; + latch.countDown(); } } -- cgit v1.2.3