You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ru...@apache.org on 2001/08/11 03:44:39 UTC

cvs commit: xml-axis/java/test/functional TestTransportSample.java

rubys       01/08/10 18:44:39

  Modified:    java/samples/transport FileSender.java FileTest.java
               java/src/org/apache/axis AxisFault.java
               java/test/functional TestTransportSample.java
  Log:
  Make doTestIBM handle DNS errors (again!) and timeouts.
  
  Revision  Changes    Path
  1.4       +9 -0      xml-axis/java/samples/transport/FileSender.java
  
  Index: FileSender.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/samples/transport/FileSender.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FileSender.java	2001/06/21 02:45:31	1.3
  +++ FileSender.java	2001/08/11 01:44:39	1.4
  @@ -57,6 +57,7 @@
   
   import java.io.* ;
   import java.lang.Thread ;
  +import java.util.Date ;
   
   import org.apache.axis.Message ;
   import org.apache.axis.AxisFault ;
  @@ -89,6 +90,11 @@
       catch( Exception e ) {
         e.printStackTrace();
       }
  +    
  +    long timeout = Long.MAX_VALUE;
  +    if (msgContext.getTimeout()!=0) 
  +      timeout=(new Date()).getTime()+msgContext.getTimeout();
  +
       for (;;) {
         try {
           Thread.sleep( 100 );
  @@ -106,8 +112,11 @@
           break ;
         }
         catch( Exception e ) {
  +        if ((new Date().getTime())>=timeout) throw new AxisFault("timeout");
  +
           // File not there - just loop
         }
  +
       }
       nextNum++ ;
     }
  
  
  
  1.10      +1 -0      xml-axis/java/samples/transport/FileTest.java
  
  Index: FileTest.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/samples/transport/FileTest.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- FileTest.java	2001/07/07 14:25:07	1.9
  +++ FileTest.java	2001/08/11 01:44:39	1.10
  @@ -42,6 +42,7 @@
       call.set(Transport.USER, opts.getUser() );
       call.set(Transport.PASSWORD, opts.getPassword() );
       call.setTransport( new FileTransport() );
  +    call.setTimeout(10000);
     
       Float res = new Float(0.0F);
       res = (Float) call.invoke( "urn:xmltoday-delayed-quotes",
  
  
  
  1.26      +8 -1      xml-axis/java/src/org/apache/axis/AxisFault.java
  
  Index: AxisFault.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/AxisFault.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- AxisFault.java	2001/08/08 18:48:59	1.25
  +++ AxisFault.java	2001/08/11 01:44:39	1.26
  @@ -57,6 +57,7 @@
   
   import java.io.* ;
   import java.util.* ;
  +import java.lang.reflect.InvocationTargetException ;
   
   import javax.xml.parsers.* ;
   import org.w3c.dom.* ;
  @@ -96,6 +97,11 @@
       public AxisFault(Exception e) {
           String  str ;
   
  +        if (e instanceof InvocationTargetException) {
  +            Throwable t = ((InvocationTargetException)e).getTargetException();
  +            if (t != null && t instanceof Exception) e = (Exception) t;
  +        }
  +
           setFaultCode( Constants.FAULT_SERVER_GENERAL );
           setFaultString( e.toString() );
           
  @@ -107,7 +113,8 @@
           
           Document doc = XMLUtils.newDocument();
           Element elem = doc.createElement("stackTrace");
  -        Node textNode = doc.createTextNode(writer.getBuffer().toString());
  +        String text = XMLUtils.xmlEncodeString(writer.getBuffer().toString());
  +        Node textNode = doc.createTextNode(text);
           elem.appendChild(textNode);
           
           Element [] details = new Element [] { elem };
  
  
  
  1.8       +8 -4      xml-axis/java/test/functional/TestTransportSample.java
  
  Index: TestTransportSample.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/functional/TestTransportSample.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TestTransportSample.java	2001/06/27 04:45:16	1.7
  +++ TestTransportSample.java	2001/08/11 01:44:39	1.8
  @@ -100,11 +100,15 @@
               FileTest.main(args);
           } catch (AxisFault e) {
               String fault = e.getFaultString();
  -            if (fault == null || fault.indexOf("java.net.UnknownHost")<0)
  +            if (fault == null) throw e;
  +            if (fault.indexOf("java.net.UnknownHost")<0) {
  +                int start = fault.indexOf(": ");
  +                System.out.println(fault.substring(start+2));
  +            } else if (fault.equals("timeout")) {
  +                System.out.println("timeout");
  +            } else {
                   throw e;
  -            int start = fault.indexOf(": ");
  -            int eol   = fault.indexOf('\n', start+1);
  -            System.out.println(fault.substring(start+2, eol));
  +            }
           }
       }