axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: xml-axis/java/test/functional TestFaultsSample.java FunctionalTests.java
Date Wed, 28 May 2003 18:34:18 GMT
dims        2003/05/28 11:34:18

  Modified:    java/src/org/apache/axis AxisFault.java
               java/src/org/apache/axis/client Call.java
               java/src/org/apache/axis/message SOAPFault.java
                        SOAPFaultBuilder.java SOAPFaultDetailsBuilder.java
               java/test/functional FunctionalTests.java
  Added:       java/samples/faults Employee.java EmployeeClient.java
                        EmployeeInfo.java NoSuchEmployeeFault.java
                        build.xml deploy.wsdd undeploy.wsdd
               java/test/functional TestFaultsSample.java
  Log:
  Fix and test case for Bug 19682 - non-AxisFault exceptions don't have details serialized
  
  Revision  Changes    Path
  1.1                  xml-axis/java/samples/faults/Employee.java
  
  Index: Employee.java
  ===================================================================
  /**
   * Employee.java
   *
   * This file was auto-generated from WSDL
   * by the Apache Axis WSDL2Java emitter.
   */
  
  package samples.faults;
  
  public class Employee {
      private java.lang.String employeeID;
      private java.lang.String employeeName;
  
      public Employee() {
      }
  
      public java.lang.String getEmployeeID() {
          return employeeID;
      }
  
      public void setEmployeeID(java.lang.String employeeID) {
          this.employeeID = employeeID;
      }
  
      public java.lang.String getEmployeeName() {
          return employeeName;
      }
  
      public void setEmployeeName(java.lang.String employeeName) {
          this.employeeName = employeeName;
      }
  }
  
  
  
  1.1                  xml-axis/java/samples/faults/EmployeeClient.java
  
  Index: EmployeeClient.java
  ===================================================================
  package samples.faults;
  
  import org.apache.axis.encoding.ser.BeanSerializerFactory;
  import org.apache.axis.encoding.ser.BeanDeserializerFactory;
  import org.apache.axis.AxisFault;
  import org.apache.axis.utils.Options;
  import org.apache.axis.transport.http.SimpleAxisWorker;
  import org.apache.axis.description.OperationDesc;
  
  import javax.xml.rpc.ServiceFactory;
  import javax.xml.rpc.Service;
  import javax.xml.rpc.Call;
  import javax.xml.rpc.encoding.TypeMappingRegistry;
  import javax.xml.rpc.encoding.TypeMapping;
  import javax.xml.namespace.QName;
  import java.net.URL;
  import java.util.Map;
  import java.util.Iterator;
  
  import samples.faults.Employee;
  
  public class EmployeeClient {
      public static void main(String[] args) throws Exception {
          Options opts = new Options(args);
          String uri = "http://faults.samples";
          String serviceName = "EmployeeInfoService";
          ServiceFactory serviceFactory = ServiceFactory.newInstance();
          Service service = serviceFactory.createService(new QName(uri, serviceName));
          
          TypeMappingRegistry registry = service.getTypeMappingRegistry();
          TypeMapping map = registry.getDefaultTypeMapping();
          
          QName employeeQName = new QName("http://faults.samples", "Employee");
          map.register(Employee.class, employeeQName, new BeanSerializerFactory(Employee.class,
employeeQName), new BeanDeserializerFactory(Employee.class, employeeQName));
  
          QName faultQName = new QName("http://faults.samples", "NoSuchEmployeeFault");
          map.register(NoSuchEmployeeFault.class, faultQName, new BeanSerializerFactory(NoSuchEmployeeFault.class,
faultQName), new BeanDeserializerFactory(NoSuchEmployeeFault.class, faultQName));
          
          Call call = service.createCall();
          call.setTargetEndpointAddress(new URL(opts.getURL()).toString());
          call.setProperty(Call.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE);
          call.setProperty(Call.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
          call.setProperty(Call.SOAPACTION_URI_PROPERTY, "http://faults.samples");
          call.setOperationName( new QName(uri, "getEmployee") );
  
          String[] args2 = opts.getRemainingArgs();
          System.out.println("Trying :" + args2[0]);
          Employee emp = (Employee) call.invoke(new Object[]{ args2[0] });
          System.out.println("Got :" + emp.getEmployeeID());
      }
  }
  
  
  
  1.1                  xml-axis/java/samples/faults/EmployeeInfo.java
  
  Index: EmployeeInfo.java
  ===================================================================
  package samples.faults;
  
  import samples.faults.Employee;
  
  import java.util.Collection;
  import java.util.HashMap;
  
  public class EmployeeInfo {
      static HashMap map = new HashMap();
      static {
          Employee emp = new Employee();
          emp.setEmployeeID("#001");
          emp.setEmployeeName("Bill Gates");
          map.put(emp.getEmployeeID(), emp);
      }
  
      public void addEmployee(Employee in) {
          map.put(in.getEmployeeID(), in);
      }
  
      public Employee getEmployee(java.lang.String id) throws NoSuchEmployeeFault {
          Employee emp = (Employee) map.get(id);
          if (emp == null) {
              NoSuchEmployeeFault fault = new NoSuchEmployeeFault();
              fault.setInfo("Could not find employee:" + id);
              throw fault;
          }
          return emp;
      }
  
      public Employee[] getEmployees() {
          Collection values = map.values();
          Employee[] emps = new Employee[values.size()];
          values.toArray(emps);
          return emps;
      }
  }
  
  
  
  1.1                  xml-axis/java/samples/faults/NoSuchEmployeeFault.java
  
  Index: NoSuchEmployeeFault.java
  ===================================================================
  /**
   * NoSuchEmployeeFault.java
   *
   * This file was auto-generated from WSDL
   * by the Apache Axis WSDL2Java emitter.
   */
  
  package samples.faults;
  
  import java.rmi.RemoteException;
  
  public class NoSuchEmployeeFault extends RemoteException  implements java.io.Serializable
{
      private java.lang.String info;
  
      public NoSuchEmployeeFault() {
      }
  
      public NoSuchEmployeeFault(
             java.lang.String info) {
          this.info = info;
      }
  
      public java.lang.String getInfo() {
          return info;
      }
  
      public void setInfo(java.lang.String info) {
          this.info = info;
      }
  }
  
  
  
  1.1                  xml-axis/java/samples/faults/build.xml
  
  Index: build.xml
  ===================================================================
  <?xml version="1.0" ?>
  <!DOCTYPE project [
          <!ENTITY properties SYSTEM "file:../../xmls/properties.xml">
          <!ENTITY paths  SYSTEM "file:../../xmls/path_refs.xml">
          <!ENTITY taskdefs SYSTEM "file:../../xmls/taskdefs.xml">
          <!ENTITY taskdefs_post_compile SYSTEM "file:../../xmls/taskdefs_post_compile.xml">
          <!ENTITY targets SYSTEM "file:../../xmls/targets.xml">
  ]>
  
  <!-- ===================================================================
  <description>
     Test/Sample Component file for Axis
  
  Notes:
     This is a build file for use with the Jakarta Ant build tool.
  
  Prerequisites:
  
     jakarta-ant from http://jakarta.apache.org
  
  Build Instructions:
     To compile
          ant compile
     To execute
          ant run
  
  Author:
    Matt Seibert mseibert@us.ibm.com
  
  Copyright:
    Copyright (c) 2002-2003 Apache Software Foundation.
  </description>
  ==================================================================== -->
  
  <project default="compile">
  <property name="axis.home" location="../.." />
  <property name="componentName" value="samples/faults" />
  
          &properties;
          &paths;
          &taskdefs;
          &taskdefs_post_compile;
  	&targets;
  
  <target name="clean"/>
  
  <target name="copy" depends="setenv"/>
  
  <target name="compile" depends="copy">
    <javac srcdir="${axis.home}" destdir="${build.dest}" debug="${debug}" fork="${javac.fork}">
      <classpath>
          <path refid="classpath"/>
      </classpath>
      <include name="samples/faults/**/*.java"/>
    </javac>
  </target>
  
  <target name="deploy"/>
  
  <target name="run"/>
  
  <target name="undeploy"/>
  
  </project>
  
  
  
  1.1                  xml-axis/java/samples/faults/deploy.wsdd
  
  Index: deploy.wsdd
  ===================================================================
  <deployment xmlns="http://xml.apache.org/axis/wsdd/"
              xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
  
   <service name="Employee" provider="java:RPC">
    <namespace>http://faults.samples</namespace>
    <parameter name="className" value="samples.faults.EmployeeInfo"/>
    <parameter name="allowedMethods" value="addEmployee getEmployees getEmployee"/>
    <parameter name="scope" value="Session"/>
       <operation name="addEmployee" qname="operNS:addEmployee" xmlns:operNS="http://faults.samples"
>
         <parameter name="in" type="tns:Employee" xmlns:tns="http://faults.samples"/>
       </operation>
       
       <operation name="getEmployee" qname="operNS:getEmployee" xmlns:operNS="http://faults.samples"
returnQName="getEmployeeReturn" returnType="rtns:Employee" xmlns:rtns="http://faults.samples"
>
         <parameter name="id" type="tns:string" xmlns:tns="http://www.w3.org/2001/XMLSchema"/>
         <fault name="NoSuchEmployeeFault" qname="fns:fault" xmlns:fns="http://localhost:8080/ch09/services/Employee"
class="samples.faults.NoSuchEmployeeFault" type="tns:NoSuchEmployeeFault" xmlns:tns="http://faults.samples"/>
       </operation>
       
       <operation name="getEmployees" qname="operNS:getEmployees" xmlns:operNS="http://faults.samples"
returnQName="getEmployeesReturn" returnType="rtns:ArrayOf_tns1_Employee" xmlns:rtns="http://localhost:8080/ch09/services/Employee"
>
       </operation>
  
       <typeMapping
         xmlns:ns="http://faults.samples"
         qname="ns:NoSuchEmployeeFault"
         type="java:samples.faults.NoSuchEmployeeFault"
         serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
         deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
         encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
       />
       <typeMapping
         xmlns:ns="http://localhost:8080/ch09/services/Employee"
         qname="ns:ArrayOf_tns1_Employee"
         type="java:samples.faults.Employee[]"
         serializer="org.apache.axis.encoding.ser.ArraySerializerFactory"
         deserializer="org.apache.axis.encoding.ser.ArrayDeserializerFactory"
         encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
       />
       <typeMapping
         xmlns:ns="http://faults.samples"
         qname="ns:Employee"
         type="java:samples.faults.Employee"
         serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
         deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
         encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
       />
  
   </service>
  </deployment>
  
  
  
  1.1                  xml-axis/java/samples/faults/undeploy.wsdd
  
  Index: undeploy.wsdd
  ===================================================================
  <undeployment xmlns="http://xml.apache.org/axis/wsdd/">
   <service name="Employee"/>
  </undeployment>
  
  
  
  1.77      +13 -2     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.76
  retrieving revision 1.77
  diff -u -r1.76 -r1.77
  --- AxisFault.java	28 May 2003 14:21:55 -0000	1.76
  +++ AxisFault.java	28 May 2003 18:34:17 -0000	1.77
  @@ -106,6 +106,9 @@
       /** SOAP headers which should be serialized with the Fault */
       protected ArrayList faultHeaders = null;
   
  +    /** wrapped remote exception */
  +    protected Throwable detail2 = null;
  +    
       /**
        * Make an AxisFault based on a passed Exception.  If the Exception is
        * already an AxisFault, simply use that.  Otherwise, wrap it in an
  @@ -200,7 +203,7 @@
           super ("", target);
           // ? SOAP 1.2 or 1.1 ?
           setFaultCodeAsString( Constants.FAULT_SERVER_USER );
  -
  +        detail2 = target;
           initFromException(target);
       }
   
  @@ -779,4 +782,12 @@
           }
       }
   
  -};
  +    /**
  +     * Returns the wrapped remote exception (the <i>cause</i>).
  +     *
  +     * @return  the wrapped remote exception, which may be <tt>null</tt>.
  +     */
  +    public Throwable getWrapped() {
  +        return detail2;
  +    }
  +}
  
  
  
  1.206     +38 -0     xml-axis/java/src/org/apache/axis/client/Call.java
  
  Index: Call.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/Call.java,v
  retrieving revision 1.205
  retrieving revision 1.206
  diff -u -r1.205 -r1.206
  --- Call.java	22 Apr 2003 19:34:04 -0000	1.205
  +++ Call.java	28 May 2003 18:34:18 -0000	1.206
  @@ -94,6 +94,7 @@
   import org.apache.axis.wsdl.symbolTable.Parameter;
   import org.apache.axis.wsdl.symbolTable.Parameters;
   import org.apache.axis.wsdl.symbolTable.SymbolTable;
  +import org.apache.axis.wsdl.symbolTable.FaultInfo;
   import org.apache.axis.wsdl.toJava.Utils;
   import org.apache.commons.logging.Log;
   
  @@ -121,6 +122,7 @@
   import java.util.Map;
   import java.util.StringTokenizer;
   import java.util.Vector;
  +import java.rmi.RemoteException;
   
   /**
    * Axis' JAXRPC Dynamic Invocation Interface implementation of the Call
  @@ -1330,6 +1332,32 @@
               QName paramType = Utils.getXSIType(p);
               this.addParameter( p.getQName(), paramType, modes[p.getMode()]);
           }
  +        
  +        Map faultMap = bEntry.getFaults();
  +        // Get the list of faults for this operation
  +        ArrayList faults = (ArrayList) faultMap.get(bop);
  +
  +        // check for no faults
  +        if (faults == null) {
  +            return;
  +        }
  +        // For each fault, register its information
  +        for (Iterator faultIt = faults.iterator(); faultIt.hasNext();) {
  +            FaultInfo info = (FaultInfo) faultIt.next();
  +            QName qname = info.getQName();
  +            javax.wsdl.Message message = info.getMessage();
  +
  +            // if no parts in fault, skip it!
  +            if (qname == null) {
  +                continue;
  +            }
  +            try {
  +                Class clazz = getTypeMapping().getClassForQName(info.getXMLType());
  +                addFault(qname, clazz, info.getXMLType(), true);
  +            } catch (Exception e) {
  +                //TODO: ???
  +            }
  +        }        
   
           // set output type
           if (parameters.returnParam != null) {
  @@ -1578,6 +1606,13 @@
           try {
               return this.invoke(params);
           }
  +        catch (AxisFault af) {
  +            this.operationName = origOpName;
  +            if(af.getWrapped() != null && af.getWrapped() instanceof RemoteException)
{
  +                throw ((RemoteException)af.getWrapped());
  +            }
  +            throw af;
  +        }
           catch (java.rmi.RemoteException re) {
               this.operationName = origOpName;
               throw re;
  @@ -1662,6 +1697,9 @@
               return res;
           }
           catch( AxisFault af) {
  +            if(af.getWrapped() != null && af.getWrapped() instanceof RemoteException)
{
  +                throw ((RemoteException)af.getWrapped());
  +            }
               throw af;
           }
           catch( Exception exp ) {
  
  
  
  1.19      +20 -13    xml-axis/java/src/org/apache/axis/message/SOAPFault.java
  
  Index: SOAPFault.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPFault.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- SOAPFault.java	22 Apr 2003 19:35:16 -0000	1.18
  +++ SOAPFault.java	28 May 2003 18:34:18 -0000	1.19
  @@ -180,18 +180,9 @@
               }
               
               // get the QName for this faults detail element
  -            Class cls = fault.getClass();
  -            QName qname = null;
  -            if (! cls.equals(AxisFault.class)) {
  -				FaultDesc faultDesc = null;
  -                OperationDesc op = context.getMessageContext().getOperation();
  -                if(op != null) {
  -					faultDesc = op.getFaultByClass(cls);
  -                }
  -                
  -				if (faultDesc != null) {
  -                    qname = faultDesc.getQName();
  -                }
  +            QName qname = getFaultQName(fault.getClass(), context);
  +            if (qname == null && fault.getWrapped() != null) {
  +                qname = getFaultQName(fault.getWrapped().getClass(), context);
               }
               if (qname == null) {
                   // not the greatest, but...
  @@ -216,7 +207,23 @@
           
           context.endElement();
       }
  -    
  +
  +    private QName getFaultQName(Class cls, SerializationContext context) {
  +        QName qname = null;       
  +        if (! cls.equals(AxisFault.class)) {
  +            FaultDesc faultDesc = null;
  +            OperationDesc op = context.getMessageContext().getOperation();
  +            if(op != null) {
  +                faultDesc = op.getFaultByClass(cls);
  +            }
  +                
  +            if (faultDesc != null) {
  +                qname = faultDesc.getQName();
  +            }
  +        }
  +        return qname;
  +    }
  +
       public AxisFault getFault()
       {
           return fault;
  
  
  
  1.33      +13 -4     xml-axis/java/src/org/apache/axis/message/SOAPFaultBuilder.java
  
  Index: SOAPFaultBuilder.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPFaultBuilder.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- SOAPFaultBuilder.java	22 Apr 2003 19:35:16 -0000	1.32
  +++ SOAPFaultBuilder.java	28 May 2003 18:34:18 -0000	1.33
  @@ -71,6 +71,7 @@
   import java.util.ArrayList;
   import java.util.HashMap;
   import java.util.Vector;
  +import java.rmi.RemoteException;
   
   /** 
    * Build a Fault body element.
  @@ -198,10 +199,18 @@
                           // We need to create the exception,
                           // passing the data to the constructor.
                           Class argClass = ConvertWrapper(faultData.getClass());
  -                        Constructor con =
  -                                faultClass.getConstructor(
  -                                        new Class[] { argClass });
  -                        f = (AxisFault) con.newInstance(new Object[] { faultData });
  +                        try {
  +                            Constructor con =
  +                                    faultClass.getConstructor(
  +                                            new Class[] { argClass });
  +                            f = (AxisFault) con.newInstance(new Object[] { faultData });
  +                        } catch(Exception e){
  +                            // Don't do anything here, since a problem above means
  +                            // we'll just fall through and use a plain AxisFault.
  +                        }
  +                        if (f == null && faultData instanceof RemoteException)
{
  +                            f = AxisFault.makeFault((RemoteException)faultData);    
  +                        }
                       }
                   }
                   // If we have an AxisFault, set the fields
  
  
  
  1.10      +29 -18    xml-axis/java/src/org/apache/axis/message/SOAPFaultDetailsBuilder.java
  
  Index: SOAPFaultDetailsBuilder.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPFaultDetailsBuilder.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SOAPFaultDetailsBuilder.java	22 Apr 2003 19:35:17 -0000	1.9
  +++ SOAPFaultDetailsBuilder.java	28 May 2003 18:34:18 -0000	1.10
  @@ -133,41 +133,52 @@
           MessageContext msgContext = context.getMessageContext();
           SOAPConstants soapConstants = msgContext.getSOAPConstants();
           OperationDesc op = msgContext.getOperation();
  +        Class faultClass = null;
  +        QName faultXmlType = null;
           if (op != null) {
               FaultDesc faultDesc = op.getFaultByQName(qn);
               // allow fault type to be denoted in xsi:type
               if (faultDesc == null) {
  -                QName type = context.getTypeFromAttributes(namespace,
  +                faultXmlType = context.getTypeFromAttributes(namespace,
                                                              name,
                                                              attributes); 
  -                if (type != null) {
  -                    faultDesc = op.getFaultByXmlType(type);
  +                if (faultXmlType != null) {
  +                    faultDesc = op.getFaultByXmlType(faultXmlType);
                   }
  +            } else {
  +                faultXmlType = faultDesc.getXmlType();    
               }
               if (faultDesc != null) {
                   // Set the class
                   try {
  -                    Class faultClass = ClassUtils.forName(faultDesc.getClassName());
  -                    builder.setFaultClass(faultClass);
  +                    faultClass = ClassUtils.forName(faultDesc.getClassName());
                   } catch (ClassNotFoundException e) {
                       // Just create an AxisFault, no custom exception
                   }
  -                builder.setWaiting(true);
  -                // register callback for the data, use the xmlType from fault info
  -                Deserializer dser = null;
  -                if (attributes.getValue(soapConstants.getAttrHref()) == null) {
  -                    dser = context.getDeserializerForType(faultDesc.getXmlType());
  -                } else {
  -                    dser = new DeserializerImpl();
  -                    dser.setDefaultType(faultDesc.getXmlType());
  -                }
  -                if (dser != null) {
  -                    dser.registerValueTarget(new CallbackTarget(this, "faultData"));
  -                }
  -                return (SOAPHandler)dser;
               }
  +        } else {
  +            faultXmlType = context.getTypeFromAttributes(namespace,
  +                                                       name,
  +                                                       attributes); 
  +            faultClass = context.getTypeMapping().getClassForQName(faultXmlType);     
      
           }
           
  +        if(faultClass != null && faultXmlType != null) {
  +            builder.setFaultClass(faultClass);
  +            builder.setWaiting(true);
  +            // register callback for the data, use the xmlType from fault info
  +            Deserializer dser = null;
  +            if (attributes.getValue(soapConstants.getAttrHref()) == null) {
  +                dser = context.getDeserializerForType(faultXmlType);
  +            } else {
  +                dser = new DeserializerImpl();
  +                dser.setDefaultType(faultXmlType);
  +            }
  +            if (dser != null) {
  +                dser.registerValueTarget(new CallbackTarget(this, "faultData"));
  +            }
  +            return (SOAPHandler)dser;
  +        }
           return null;
       }
   
  
  
  
  1.25      +3 -0      xml-axis/java/test/functional/FunctionalTests.java
  
  Index: FunctionalTests.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/functional/FunctionalTests.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- FunctionalTests.java	11 Dec 2002 22:40:16 -0000	1.24
  +++ FunctionalTests.java	28 May 2003 18:34:18 -0000	1.25
  @@ -61,6 +61,9 @@
           
           // test.rpc test
           suite.addTestSuite(TestIF3SOAP.class);
  +        
  +        // samples.fault test
  +        suite.addTestSuite(TestFaultsSample.class);
   
           // Attachments service test.
           try{
  
  
  
  1.1                  xml-axis/java/test/functional/TestFaultsSample.java
  
  Index: TestFaultsSample.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package test.functional;
  
  import junit.framework.TestCase;
  import org.apache.axis.client.AdminClient;
  import org.apache.axis.components.logger.LogFactory;
  import org.apache.commons.logging.Log;
  import samples.faults.EmployeeClient;
  
  
  
  /** Test the faults sample code.
   */
  public class TestFaultsSample extends TestCase {
      static Log log =
              LogFactory.getLog(TestFaultsSample.class.getName());
  
      public TestFaultsSample(String name) {
          super(name);
      }
      
      public void doTestDeploy () throws Exception {
          String[] args = { "samples/faults/deploy.wsdd" };
          AdminClient.main(args);
      }
      
      public void doTest1 () throws Exception {
          String[] args = { "#001" };
          EmployeeClient.main(args);
      }
      
      public void doTest2 () throws Exception {
          String[] args = { "#002" };
          try {
              EmployeeClient.main(args);
          } catch (samples.faults.NoSuchEmployeeFault nsef) {
              return;
          }
          fail("Should not reach here");
      }
  
      public void testFaultsService () throws Exception {
          try {
              log.info("Testing faults sample.");
              log.info("Testing deployment...");
              doTestDeploy();
              log.info("Testing service...");
              doTest1();
              doTest2();
              log.info("Test complete.");
          }
          catch( Exception e ) {
              e.printStackTrace();
              throw new Exception("Fault returned from test: "+e);
          }
      }
  
      public static void main(String[] args) throws Exception {
          TestFaultsSample tester = new TestFaultsSample("test");
          tester.testFaultsService();
      }
  }
  
  
  
  

Mime
View raw message