axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ngalla...@apache.org
Subject svn commit: r485844 - in /webservices/axis2/trunk/java/modules/jaxws: src/org/apache/axis2/jaxws/client/async/ test/org/apache/axis2/jaxws/dispatch/
Date Mon, 11 Dec 2006 19:47:31 GMT
Author: ngallardo
Date: Mon Dec 11 11:47:31 2006
New Revision: 485844

URL: http://svn.apache.org/viewvc?view=rev&rev=485844
Log:
AXIS2-1860
Contributor: Mike Rheinhiemer

Mike's patch for throwing the right exception type.

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/AsyncCallback.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/DispatchTestConstants.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/StringDispatch.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java?view=diff&rev=485844&r1=485843&r2=485844
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java
Mon Dec 11 11:47:31 2006
@@ -95,11 +95,10 @@
         latch.await();
         
         if (hasFault()) {
-            throw new ExecutionException(fault);
+            throw new ExecutionException(ExceptionFactory.makeWebServiceException(fault));
         }
         if (response == null) {
-            WebServiceException wse = new WebServiceException("null response");
-            throw new ExecutionException(wse);
+            throw new ExecutionException(ExceptionFactory.makeWebServiceException("null response"));
         }
         
         // TODO: Check the type of the object to make sure it corresponds with
@@ -119,11 +118,10 @@
         latch.await(timeout, unit);
         
         if (hasFault()) {
-            throw new ExecutionException(fault);
+            throw new ExecutionException(ExceptionFactory.makeWebServiceException(fault));
         }
         if (response == null) {
-            WebServiceException wse = new WebServiceException("null response");
-            throw new ExecutionException(wse);
+            throw new ExecutionException(ExceptionFactory.makeWebServiceException("null response"));
         }
         
         // TODO: Check the type of the object to make sure it corresponds with

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/AsyncCallback.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/AsyncCallback.java?view=diff&rev=485844&r1=485843&r2=485844
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/AsyncCallback.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/AsyncCallback.java
Mon Dec 11 11:47:31 2006
@@ -14,9 +14,9 @@
         try {
             value = response.get();
         } catch (InterruptedException e) {
-            e.printStackTrace();
+            exception = e;
         } catch (ExecutionException e) {
-            e.printStackTrace();
+            exception = e;
         }
     }
     

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/DispatchTestConstants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/DispatchTestConstants.java?view=diff&rev=485844&r1=485843&r2=485844
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/DispatchTestConstants.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/DispatchTestConstants.java
Mon Dec 11 11:47:31 2006
@@ -23,6 +23,7 @@
 public class DispatchTestConstants {
 
     public static final String URL = "http://localhost:8080/axis2/services/EchoService";
+    public static final String BADURL = "http://this.is.not.a.valid.hostname.at.all.no.way:9999/wacky";
     public static final QName QNAME_SERVICE = new QName("http://ws.apache.org/axis2", "EchoService");
     public static final QName QNAME_PORT = new QName("http://ws.apache.org/axis2", "EchoServiceSOAP11port0");
 

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/StringDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/StringDispatch.java?view=diff&rev=485844&r1=485843&r2=485844
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/StringDispatch.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/StringDispatch.java
Mon Dec 11 11:47:31 2006
@@ -18,11 +18,14 @@
  */
 package org.apache.axis2.jaxws.dispatch;
 
+import java.net.UnknownHostException;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 
 import javax.xml.ws.Dispatch;
 import javax.xml.ws.Response;
 import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceException;
 
 import junit.framework.TestCase;
 
@@ -249,4 +252,91 @@
         System.out.println(">> Invoking one-way Dispatch");
         dispatch.invokeOneWay(DispatchTestConstants.sampleSoapMessage);
 	}
+    
+    
+    public void testSyncPayloadMode_badHostName() {
+        System.out.println("---------------------------------------");
+        System.out.println("test: " + getName());
+        
+        // Initialize the JAX-WS client artifacts
+        Service svc = Service.create(DispatchTestConstants.QNAME_SERVICE);
+        svc.addPort(DispatchTestConstants.QNAME_PORT, null, DispatchTestConstants.BADURL);
+        Dispatch<String> dispatch = svc.createDispatch(DispatchTestConstants.QNAME_PORT,

+                String.class, Service.Mode.PAYLOAD);
+        
+        // Invoke the Dispatch
+        Throwable ttemp = null;
+        try {
+            System.out.println(">> Invoking sync Dispatch");
+            String response = dispatch.invoke(DispatchTestConstants.sampleBodyContent);
+        } catch (Throwable t) {
+            assertTrue(t instanceof WebServiceException);
+            assertTrue(t.getCause() instanceof UnknownHostException);
+            ttemp = t;
+        }
+        assertNotNull(ttemp);
+
+    }
+    
+    public void testAsyncCallbackMessageMode_badHostName() throws Exception {
+        System.out.println("---------------------------------------");
+        System.out.println("test: " + getName());
+        
+        // Initialize the JAX-WS client artifacts
+        Service svc = Service.create(DispatchTestConstants.QNAME_SERVICE);
+        svc.addPort(DispatchTestConstants.QNAME_PORT, null, DispatchTestConstants.BADURL);
+        Dispatch<String> dispatch = svc.createDispatch(DispatchTestConstants.QNAME_PORT,

+                String.class, Service.Mode.MESSAGE);
+
+        // Create the callback for async responses
+        AsyncCallback<String> callback = new AsyncCallback<String>();
+        
+        System.out.println(">> Invoking async (callback) Dispatch with Message Mode");
+        Future<?> monitor = dispatch.invokeAsync(DispatchTestConstants.sampleSoapMessage,
callback);
+    
+        while (!monitor.isDone()) {
+            System.out.println(">> Async invocation still not complete");
+            Thread.sleep(1000);
+        }
+        
+        if (callback.hasError()) {
+            Throwable t = callback.getError();
+            assertTrue(t instanceof ExecutionException);
+            assertTrue(t.getCause() instanceof WebServiceException);
+            assertTrue(t.getCause().getCause() instanceof UnknownHostException);
+        } else {
+            fail("Should have retrieved an UnknownHostException from callback");
+        }
+    }
+    
+    public void testAsyncPollingPayloadMode_badHostName() throws Exception {
+        System.out.println("---------------------------------------");
+        System.out.println("test: " + getName());
+        
+        // Initialize the JAX-WS client artifacts
+        Service svc = Service.create(DispatchTestConstants.QNAME_SERVICE);
+        svc.addPort(DispatchTestConstants.QNAME_PORT, null, DispatchTestConstants.BADURL);
+        Dispatch<String> dispatch = svc.createDispatch(DispatchTestConstants.QNAME_PORT,

+                String.class, Service.Mode.PAYLOAD);
+
+        System.out.println(">> Invoking async (polling) Dispatch");
+        Response<String> asyncResponse = dispatch.invokeAsync(DispatchTestConstants.sampleBodyContent);
+            
+        while (!asyncResponse.isDone()) {
+            System.out.println(">> Async invocation still not complete");
+            Thread.sleep(1000);
+        }
+        
+        Throwable ttemp = null;
+        try {
+            asyncResponse.get();
+        } catch (Throwable t) {
+            assertTrue(t instanceof ExecutionException);
+            assertTrue(t.getCause() instanceof WebServiceException);
+            assertTrue(t.getCause().getCause() instanceof UnknownHostException);
+            ttemp = t;
+        }
+        assertNotNull(ttemp);
+    }
+    
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message