You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ff...@apache.org on 2007/05/23 08:26:20 UTC

svn commit: r540855 - /incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java

Author: ffang
Date: Tue May 22 23:26:19 2007
New Revision: 540855

URL: http://svn.apache.org/viewvc?view=rev&rev=540855
Log:
[CXF-544] add test to prove JAXWS Client Proxy use executor assigned to JAXWS Service in async invocations

Modified:
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java?view=diff&rev=540855&r1=540854&r2=540855
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerTest.java Tue May 22 23:26:19 2007
@@ -20,6 +20,7 @@
 package org.apache.cxf.systest.jaxws;
 
 
+
 import java.io.InputStream;
 import java.lang.reflect.UndeclaredThrowableException;
 import java.net.HttpURLConnection;
@@ -29,9 +30,11 @@
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executor;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
+import java.util.logging.Logger;
 
 import javax.xml.namespace.QName;
 import javax.xml.ws.AsyncHandler;
@@ -48,10 +51,8 @@
 import org.apache.cxf.binding.soap.Soap11;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.dynamic.DynamicClientFactory;
-//import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.helpers.XMLUtils;
 import org.apache.cxf.helpers.XPathUtils;
-//import org.apache.cxf.jaxws.ServiceImpl;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.hello_world_soap_http.BadRecordLitFault;
@@ -70,6 +71,7 @@
 
 public class ClientServerTest extends AbstractBusClientServerTestBase {
   
+    static final Logger LOG = Logger.getLogger(ClientServerTest.class.getName());
     private final QName serviceName = new QName("http://apache.org/hello_world_soap_http",
                                                 "SOAPService");    
     private final QName portName = new QName("http://apache.org/hello_world_soap_http",
@@ -416,12 +418,52 @@
     }
     
     @Test
-    public void testAsyncCallWithHandler() throws Exception {
+    public void testAsyncCallUseProperAssignedExecutor() throws Exception {
         URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
         assertNotNull(wsdl);
         
         SOAPService service = new SOAPService(wsdl, serviceName);
         
+        class TestExecutor implements Executor {
+            
+            private int count;
+            
+            public void execute(Runnable command) {
+                count++;
+                LOG.info("asyn call time " + count);
+                command.run();
+            }
+            
+            public int getCount() {
+                return count;
+            }
+        }
+        Executor executor = new TestExecutor();
+        service.setExecutor(executor);
+        assertNotNull(service);
+        assertSame(executor, service.getExecutor());
+        
+        
+        assertEquals(((TestExecutor)executor).getCount(), 0);
+        try {
+            Greeter greeter = (Greeter)service.getPort(portName, Greeter.class);
+            for (int i = 0; i < 5; i++) {
+                greeter.greetMeAsync("asyn call" + i);
+            }
+        } catch (UndeclaredThrowableException ex) {
+            throw (Exception)ex.getCause();
+        }
+        
+        assertEquals(((TestExecutor)executor).getCount(), 5);
+    }
+
+    
+    @Test
+    public void testAsyncCallWithHandler() throws Exception {
+        URL wsdl = getClass().getResource("/wsdl/hello_world.wsdl");
+        assertNotNull(wsdl);
+        
+        SOAPService service = new SOAPService(wsdl, serviceName);
         assertNotNull(service);
         
         MyHandler h = new MyHandler();