Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 35257 invoked from network); 15 May 2009 15:14:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 15 May 2009 15:14:21 -0000 Received: (qmail 92351 invoked by uid 500); 15 May 2009 15:14:21 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 92288 invoked by uid 500); 15 May 2009 15:14:21 -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 92279 invoked by uid 99); 15 May 2009 15:14:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 May 2009 15:14:21 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 May 2009 15:14:19 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 11B31238888C; Fri, 15 May 2009 15:13:59 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r775184 - /cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java Date: Fri, 15 May 2009 15:13:58 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090515151359.11B31238888C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dkulp Date: Fri May 15 15:13:58 2009 New Revision: 775184 URL: http://svn.apache.org/viewvc?rev=775184&view=rev Log: Add some timeouts and add a testcase for an async fault Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java?rev=775184&r1=775183&r2=775184&view=diff ============================================================================== --- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java (original) +++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java Fri May 15 15:13:58 2009 @@ -21,6 +21,7 @@ import java.io.InputStream; import java.net.URL; +import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import javax.xml.bind.JAXBContext; @@ -50,6 +51,7 @@ import org.apache.cxf.interceptor.LoggingOutInterceptor; import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; import org.apache.cxf.testutil.common.AbstractBusTestServerBase; +import org.apache.hello_world_soap_http.BadRecordLitFault; import org.apache.hello_world_soap_http.GreeterImpl; import org.apache.hello_world_soap_http.SOAPService; import org.apache.hello_world_soap_http.types.GreetMe; @@ -95,6 +97,17 @@ BusFactory.getDefaultBus().getOutInterceptors().add(new LoggingOutInterceptor()); BusFactory.getDefaultBus().getInInterceptors().add(new LoggingInInterceptor()); } + + private void waitForFuture(Future fd) throws Exception { + int count = 0; + while (!fd.isDone()) { + ++count; + if (count > 500) { + fail("Did not finish in 10 seconds"); + } + Thread.sleep(20); + } + } @Test public void testSOAPMessage() throws Exception { @@ -144,9 +157,8 @@ TestSOAPMessageHandler tsmh = new TestSOAPMessageHandler(); Future f = disp.invokeAsync(soapReqMsg3, tsmh); assertNotNull(f); - while (!f.isDone()) { - // wait - } + waitForFuture(f); + String expected3 = "Hello TestSOAPInputMessage3"; assertEquals("Response should be : Hello TestSOAPInputMessage3", expected3, tsmh.getReplyBuffer().trim()); @@ -209,9 +221,7 @@ TestDOMSourceHandler tdsh = new TestDOMSourceHandler(); Future fd = disp.invokeAsync(domReqMsg3, tdsh); assertNotNull(fd); - while (!fd.isDone()) { - // wait - } + waitForFuture(fd); String expected3 = "Hello TestSOAPInputMessage3"; assertEquals("Response should be : Hello TestSOAPInputMessage3", expected3, tdsh.getReplyBuffer().trim()); @@ -287,9 +297,7 @@ TestDOMSourceHandler tdsh = new TestDOMSourceHandler(); Future fd = disp.invokeAsync(domReqMsg3, tdsh); assertNotNull(fd); - while (!fd.isDone()) { - // wait - } + waitForFuture(fd); String expected3 = "Hello TestSOAPInputMessage3"; assertEquals("Response should be : Hello TestSOAPInputMessage3", expected3, tdsh.getReplyBuffer().trim()); @@ -329,11 +337,24 @@ TestJAXBHandler tjbh = new TestJAXBHandler(); Future fd = disp.invokeAsync(greetMe, tjbh); assertNotNull(fd); - while (!fd.isDone()) { - // wait - } + waitForFuture(fd); + String responseValue3 = ((GreetMeResponse)tjbh.getResponse()).getResponseType(); assertTrue("Expected string, " + expected, expected.equals(responseValue3)); + + org.apache.hello_world_soap_http.types.TestDocLitFault fr = + new org.apache.hello_world_soap_http.types.TestDocLitFault(); + fr.setFaultType(BadRecordLitFault.class.getSimpleName()); + + tjbh = new TestJAXBHandler(); + fd = disp.invokeAsync(fr, tjbh); + waitForFuture(fd); + try { + fd.get(); + fail("did not get expected exception"); + } catch (ExecutionException ex) { + //expected + } } @Test @@ -426,9 +447,8 @@ TestSAXSourceHandler tssh = new TestSAXSourceHandler(); Future fd = disp.invokeAsync(saxSourceReq3, tssh); assertNotNull(fd); - while (!fd.isDone()) { - //wait - } + waitForFuture(fd); + String expected3 = "Hello TestSOAPInputMessage3"; SAXSource saxSourceResp3 = tssh.getSAXSource(); assertNotNull(saxSourceResp3); @@ -495,16 +515,8 @@ TestSAXSourceHandler tssh = new TestSAXSourceHandler(); Future fd = disp.invokeAsync(saxSourceReq3, tssh); assertNotNull(fd); - - int count = 0; - while (!fd.isDone()) { - if (count > 100) { - fail("Did not finish in 10 seconds"); - } - //wait - Thread.sleep(100); - count++; - } + waitForFuture(fd); + String expected3 = "Hello TestSOAPInputMessage3"; SAXSource saxSourceResp3 = tssh.getSAXSource(); assertNotNull(saxSourceResp3); @@ -549,9 +561,8 @@ TestStreamSourceHandler tssh = new TestStreamSourceHandler(); Future fd = disp.invokeAsync(streamSourceReq3, tssh); assertNotNull(fd); - while (!fd.isDone()) { - //wait - } + waitForFuture(fd); + String expected3 = "Hello TestSOAPInputMessage3"; StreamSource streamSourceResp3 = tssh.getStreamSource(); assertNotNull(streamSourceResp3); @@ -600,9 +611,8 @@ TestStreamSourceHandler tssh = new TestStreamSourceHandler(); Future fd = disp.invokeAsync(streamSourceReq3, tssh); assertNotNull(fd); - while (!fd.isDone()) { - //wait - } + waitForFuture(fd); + String expected3 = "Hello TestSOAPInputMessage3"; StreamSource streamSourceResp3 = tssh.getStreamSource(); assertNotNull(streamSourceResp3);