axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: ws-axis/java/test/client TestCall.java
Date Tue, 09 Dec 2003 21:21:39 GMT
dims        2003/12/09 13:21:39

  Modified:    java/test/client TestCall.java
  Log:
  Add try/catch and timeout.
  
  Revision  Changes    Path
  1.2       +29 -9     ws-axis/java/test/client/TestCall.java
  
  Index: TestCall.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/test/client/TestCall.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestCall.java	28 Nov 2003 03:57:51 -0000	1.1
  +++ TestCall.java	9 Dec 2003 21:21:39 -0000	1.2
  @@ -63,6 +63,8 @@
   import org.apache.axis.handlers.BasicHandler;
   
   import java.net.URL;
  +import java.net.ConnectException;
  +import java.io.InterruptedIOException;
   
   public class TestCall extends TestCase {
       public TestCall(String name) {
  @@ -77,15 +79,33 @@
       }
   
       /* Test case for Bug 23031 - No deserializer found for ns1:ArrayOfstring */
  -    public void testWeatherService() throws Exception {
  -        Call call = new Call(new URL("http://live.capescience.com:80/ccx/GlobalWeather"));
  -        call.setUseSOAPAction(true);
  -        call.setSOAPActionURI("capeconnect:GlobalWeather:StationInfo#listCountries");
  -        call.setOperationName(new javax.xml.namespace.QName("capeconnect:GlobalWeather:StationInfo",
"listCountries"));
  -        String[] c = (String[]) call.invoke(new Object[]{});
  -        System.out.println(c.length);
  -        for (int i = 0; i < c.length; i++) {
  -            System.out.println(c[i]);
  +    public void testWeatherService() {
  +        try {
  +            Call call = new Call(new URL("http://live.capescience.com:80/ccx/GlobalWeather"));
  +            call.setUseSOAPAction(true);
  +            call.setSOAPActionURI("capeconnect:GlobalWeather:StationInfo#listCountries");
  +            call.setTimeout(new Integer(15*1000));
  +            call.setOperationName(new javax.xml.namespace.QName("capeconnect:GlobalWeather:StationInfo",
"listCountries"));
  +            String[] c = (String[]) call.invoke(new Object[]{});
  +            System.out.println(c.length);
  +            for (int i = 0; i < c.length; i++) {
  +                System.out.println(c[i]);
  +            }
  +        }  catch (java.rmi.RemoteException re) {
  +            if (re instanceof AxisFault) {
  +                AxisFault fault = (AxisFault) re;
  +                if (fault.detail instanceof ConnectException ||
  +                    fault.detail instanceof InterruptedIOException ||
  +                    (fault.getFaultString().indexOf("Connection timed out") != -1) ||
  +                    fault.getFaultCode().getLocalPart().equals("HTTP")) {
  +                    System.err.println("getTemp HTTP error: " + fault);
  +                    return;
  +                }
  +            }
  +            throw new junit.framework.AssertionFailedError("Remote Exception caught: "
+ re);
  +        }  catch (java.io.IOException ioe) {
  +            System.err.println("testWeatherService connect error: " + ioe);
  +            return;
           }
       }
   }
  
  
  

Mime
View raw message