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/wsdl/uddiv2 InquiryServiceTestCase.java
Date Wed, 15 Sep 2004 10:13:22 GMT
dims        2004/09/15 03:13:22

  Modified:    java/test/functional TestJAXMSamples.java
               java/test/wsdl/uddiv2 InquiryServiceTestCase.java
  Log:
  Add some exception handling for connection failure.
  
  Revision  Changes    Path
  1.24      +48 -24    ws-axis/java/test/functional/TestJAXMSamples.java
  
  Index: TestJAXMSamples.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/test/functional/TestJAXMSamples.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- TestJAXMSamples.java	6 Jul 2004 19:00:55 -0000	1.23
  +++ TestJAXMSamples.java	15 Sep 2004 10:13:21 -0000	1.24
  @@ -86,10 +86,12 @@
               if (t != null) {
                   t.printStackTrace();
                   if (t instanceof AxisFault) {
  -                    if (((AxisFault) t).detail instanceof SocketException) {
  -                        System.out.println("Connect failure caused JAXM DelayedStockQuote
to be skipped.");
  -                        return;
  -                    }
  +                  AxisFault af = (AxisFault) t;
  +                  if ((af.detail instanceof SocketException)
  +							|| (af.getFaultCode().getLocalPart().equals("HTTP"))) {
  +						System.out.println("Connect failure caused JAXM DelayedStockQuote to be skipped.");
  +						return;
  +					}
                   }
                   throw new Exception("Fault returned from test: " + t);
               } else {
  @@ -103,26 +105,48 @@
       } // testGetQuote
       
       public void testJWSFault() throws Exception {
  -        SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance();
  -        SOAPConnection con = scFactory.createConnection();
  -
  -        MessageFactory factory = MessageFactory.newInstance();
  -        SOAPMessage message = factory.createMessage();
  -
  -        SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
  -        SOAPBody body = envelope.getBody();
  -
  -        Name bodyName = envelope.createName("echo");
  -        SOAPBodyElement bodyElement = body.addBodyElement(bodyName);
  -
  -        Name name = envelope.createName("arg0");
  -        SOAPElement symbol = bodyElement.addChildElement(name);
  -        symbol.addTextNode("Hello");
  -
  -        URLEndpoint endpoint = new URLEndpoint("http://localhost:8080/jws/FaultTest.jws");
  -        SOAPMessage response = con.call(message, endpoint);
  -        SOAPBody respBody = response.getSOAPPart().getEnvelope().getBody();
  -        assertTrue(respBody.hasFault());
  +        try {
  +	        SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance();
  +	        SOAPConnection con = scFactory.createConnection();
  +	
  +	        MessageFactory factory = MessageFactory.newInstance();
  +	        SOAPMessage message = factory.createMessage();
  +	
  +	        SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
  +	        SOAPBody body = envelope.getBody();
  +	
  +	        Name bodyName = envelope.createName("echo");
  +	        SOAPBodyElement bodyElement = body.addBodyElement(bodyName);
  +	
  +	        Name name = envelope.createName("arg0");
  +	        SOAPElement symbol = bodyElement.addChildElement(name);
  +	        symbol.addTextNode("Hello");
  +	
  +	        URLEndpoint endpoint = new URLEndpoint("http://localhost:8080/jws/FaultTest.jws");
  +	        SOAPMessage response = con.call(message, endpoint);
  +	        SOAPBody respBody = response.getSOAPPart().getEnvelope().getBody();
  +	        assertTrue(respBody.hasFault());
  +        } catch (javax.xml.soap.SOAPException e) {
  +            Throwable t = e.getCause();
  +            if (t != null) {
  +                t.printStackTrace();
  +                if (t instanceof AxisFault) {
  +                  AxisFault af = (AxisFault) t;
  +                  if ((af.detail instanceof SocketException)
  +							|| (af.getFaultCode().getLocalPart().equals("HTTP"))) {
  +						System.out.println("Connect failure caused testJWSFault to be skipped.");
  +						return;
  +					}
  +                }
  +                throw new Exception("Fault returned from test: " + t);
  +            } else {
  +                e.printStackTrace();
  +                throw new Exception("Exception returned from test: " + e);
  +            }
  +        } catch (Throwable t) {
  +            t.printStackTrace();
  +            throw new Exception("Fault returned from test: " + t);
  +        }
       }
   
       public static void main(String args[]) throws Exception {
  
  
  
  1.4       +17 -3     ws-axis/java/test/wsdl/uddiv2/InquiryServiceTestCase.java
  
  Index: InquiryServiceTestCase.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/test/wsdl/uddiv2/InquiryServiceTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- InquiryServiceTestCase.java	2 Sep 2004 12:15:58 -0000	1.3
  +++ InquiryServiceTestCase.java	15 Sep 2004 10:13:22 -0000	1.4
  @@ -7,6 +7,10 @@
   
   package test.wsdl.uddiv2;
   
  +import java.net.SocketException;
  +
  +import org.apache.axis.AxisFault;
  +
   public class InquiryServiceTestCase extends junit.framework.TestCase {
       public InquiryServiceTestCase(java.lang.String name) {
           super(name);
  @@ -45,9 +49,19 @@
               for(int i=0;i<infos2.length;i++){
                   System.out.println(infos2[i].getBusinessKey());
               }
  -        }
  -        catch (test.wsdl.uddiv2.api_v2.DispositionReport e1) {
  -            throw new junit.framework.AssertionFailedError("error Exception caught: " +
e1);
  +        } catch (test.wsdl.uddiv2.api_v2.DispositionReport e1) {
  +           	throw new junit.framework.AssertionFailedError("error Exception caught: " +
e1);
  +        } catch (Exception e) {
  +            e.printStackTrace();
  +			if (e instanceof AxisFault) {
  +				AxisFault af = (AxisFault) e;
  +				if ((af.detail instanceof SocketException)
  +						|| (af.getFaultCode().getLocalPart().equals("HTTP"))) {
  +					System.out.println("Connect failure caused testJWSFault to be skipped.");
  +					return;
  +				}
  +			}
  +			throw new Exception("Fault returned from test: " + e);
           }
       }
   }
  
  
  

Mime
View raw message