You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2009/05/15 17:13:58 UTC

svn commit: r775184 - /cxf/trunk/systests/src/test/java/org/apache/cxf/systest/dispatch/DispatchClientServerTest.java

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);