axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jongjinc...@apache.org
Subject cvs commit: ws-axis/java/test/wsdl/arrays3 AddrBookServiceImpl.java Phone.java build.xml AddressBookImpl.java AddrBookService.java AddrBookServiceImplServiceTestCase.java Address.java StateType.java
Date Wed, 23 Mar 2005 02:24:30 GMT
jongjinchoi    2005/03/22 18:24:30

  Added:       java/test/wsdl/arrays3 AddrBookServiceImpl.java Phone.java
                        build.xml AddressBookImpl.java AddrBookService.java
                        AddrBookServiceImplServiceTestCase.java
                        Address.java StateType.java
  Log:
  add testcase for AXIS-1891
  
  Revision  Changes    Path
  1.1                  ws-axis/java/test/wsdl/arrays3/AddrBookServiceImpl.java
  
  Index: AddrBookServiceImpl.java
  ===================================================================
  package test.wsdl.arrays3;
  
  public class AddrBookServiceImpl implements AddrBookService {
      AddressBookImpl addressBook;
  
      public AddrBookServiceImpl() {
          addressBook = new AddressBookImpl();
      }
  
      public void addEntry(String name, Address address) {
          addressBook.addEntry(name, address);
      }
  
      public Address[] getAddressFromNames(String[] name) {
          return addressBook.getAddressFromNames(name);
      }
  
      public Address getAddressFromName(String name) {
          return addressBook.getAddressFromName(name);
      }
  
      public Address[] echoAddresses(Address[] addrs) {
          return addrs;
      }
  }
  
  
  
  1.1                  ws-axis/java/test/wsdl/arrays3/Phone.java
  
  Index: Phone.java
  ===================================================================
  package test.wsdl.arrays3;
  
  public class Phone  implements java.io.Serializable {
      private int areaCode;
      private java.lang.String exchange;
      private java.lang.String number;
  
      public Phone() {
      }
  
      /**
       * Gets the areaCode value for this Phone.
       * 
       * @return areaCode
       */
      public int getAreaCode() {
          return areaCode;
      }
  
  
      /**
       * Sets the areaCode value for this Phone.
       * 
       * @param areaCode
       */
      public void setAreaCode(int areaCode) {
          this.areaCode = areaCode;
      }
  
  
      /**
       * Gets the exchange value for this Phone.
       * 
       * @return exchange
       */
      public java.lang.String getExchange() {
          return exchange;
      }
  
  
      /**
       * Sets the exchange value for this Phone.
       * 
       * @param exchange
       */
      public void setExchange(java.lang.String exchange) {
          this.exchange = exchange;
      }
  
  
      /**
       * Gets the number value for this Phone.
       * 
       * @return number
       */
      public java.lang.String getNumber() {
          return number;
      }
  
  
      /**
       * Sets the number value for this Phone.
       * 
       * @param number
       */
      public void setNumber(java.lang.String number) {
          this.number = number;
      }
  
  }
  
  
  
  1.1                  ws-axis/java/test/wsdl/arrays3/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="test/wsdl/arrays3" />
          &properties;
          &paths;
          &taskdefs;
          &taskdefs_post_compile;
          &targets;
  
  <target name="clean">
      <echo message="Removing ${build.dir}/classes/${componentName} and ${build.dir}/work/${componentName}"
/>
      <delete dir="${build.dir}/classes/${componentName}"/>
      <delete dir="${build.dir}/work/${componentName}"/>
  </target>
  
  <target name="copy" depends="setenv"/>
  
  <target name="compile" depends="copy">
    <echo message="Compiling test.wsdl.arrays3"/>
      <!-- arrays3 Test -->
      <!-- To test Java Value Types, copy over the base and subclasses -->
      <copy todir="${build.dir}/work/test/wsdl/arrays3" overwrite="yes">
        <fileset dir="${test.dir}/wsdl/arrays3">
          <include name="*.java"/>
        </fileset>
      </copy>
  
      <!-- Compile the Web Service -->
      <javac srcdir="${build.dir}/work" destdir="${build.dest}" debug="${debug}" nowarn="${nowarn}"
source="${source}" fork="${javac.fork}">
        <classpath refid="classpath" />
        <include name="test/wsdl/arrays3/**.java" />
        <exclude name="test/wsdl/arrays3/*TestCase.java" />
      </javac>
  
      <!-- Now create the wsdd and server-side java classes (helpers, ArrayOfPhones) -->
      <mkdir dir="${build.dir}/work/test/wsdl/arrays3/generated"/>
  
      <java2wsdl output="${axis.home}/build/work/test/wsdl/arrays3/generated/arrays3.wsdl"
                 className= "test.wsdl.arrays3.AddrBookServiceImpl"
                 useInheritedMethods="false"
                 namespace="http://arrays3.test"
                 location="http://localhost:8080/axis/services/arrays3"
                 style="WRAPPED"
                 use="literal"
                 deploy="true">
          <mapping namespace="http://arrays3.test" package="test.wsdl.arrays3"/>
      </java2wsdl>
  
      <copy todir="${build.dir}/work/test/wsdl/arrays3" overwrite="yes">
        <fileset dir="${build.dir}/work/test/wsdl/arrays3/generated">
          <include name="**/*.wsdd"/>
        </fileset>
      </copy>
  
      <!-- Generate java files of the client side from the new WSDL -->
      <wsdl2java url="${axis.home}/build/work/test/wsdl/arrays3/generated/arrays3.wsdl"
                 output="${axis.home}/build/work"
                 verbose="no"
                 testcase="no">
          <mapping namespace="http://arrays3.test" package="test.wsdl.arrays3.testclient"/>
      </wsdl2java>
  
      <copy todir="${build.dir}/work/test/wsdl/arrays3" overwrite="yes">
        <fileset dir="${axis.home}/test/wsdl/arrays3">
          <include name="*TestCase.java"/>
        </fileset>
      </copy>
      
      <javac srcdir="${build.dir}/work" destdir="${build.dest}" nowarn="${nowarn}" source="${source}"
fork="${javac.fork}"
             debug="${debug}">
        <classpath refid="classpath" />
        <include name="test/wsdl/arrays3/*TestCase.java" />
        <include name="test/wsdl/arrays3/testclient/*.java" />
        <include name="test/wsdl/arrays3/generated/**/*.java" />
    </javac>
  </target>
  
  <target name="run" >
    <antcall target="execute-Component" />
  </target>
  
  </project>
  
  
  
  1.1                  ws-axis/java/test/wsdl/arrays3/AddressBookImpl.java
  
  Index: AddressBookImpl.java
  ===================================================================
  package test.wsdl.arrays3;
  
  import java.util.Hashtable;
  import java.util.Map;
  
  
  public class AddressBookImpl 
  {
      private static Map addresses = new Hashtable();
  
      public void addEntry(String name, Address address) 
      {
          this.addresses.put(name, address);
      }
      
      public Address getAddressFromName(String name)
      {
          return (Address) this.addresses.get(name);
      }
      
  
      public Address[] getAddressFromNames(String[] name) {
          if (name == null) return null;
          Address[] result = new Address[name.length];
          for(int i=0; i< name.length; i++) {
              result[i] = getAddressFromName(name[i]);
          }
          return result;
      } 
  
  }
  
  
  
  1.1                  ws-axis/java/test/wsdl/arrays3/AddrBookService.java
  
  Index: AddrBookService.java
  ===================================================================
  package test.wsdl.arrays3;
  
  public interface AddrBookService extends java.rmi.Remote {
      public void addEntry(String name, Address address) throws java.rmi.RemoteException;
      public Address[] getAddressFromNames(String[] names) throws java.rmi.RemoteException;
      public Address getAddressFromName(String name) throws java.rmi.RemoteException;
      public Address[] echoAddresses(Address[] addrs) throws java.rmi.RemoteException;
  }
  
  
  
  1.1                  ws-axis/java/test/wsdl/arrays3/AddrBookServiceImplServiceTestCase.java
  
  Index: AddrBookServiceImplServiceTestCase.java
  ===================================================================
  /**
   * AddrBookServiceImplServiceTestCase.java
   *
   * This file was auto-generated from WSDL
   * by the Apache Axis #axisVersion# #today# WSDL2Java emitter.
   */
  
  package test.wsdl.arrays3;
  
  import junit.framework.AssertionFailedError;
  
  public class AddrBookServiceImplServiceTestCase extends junit.framework.TestCase {
      public AddrBookServiceImplServiceTestCase(java.lang.String name) {
          super(name);
      }
  
      public void testAddressBookWSDL() throws Exception {
          javax.xml.rpc.ServiceFactory serviceFactory = javax.xml.rpc.ServiceFactory.newInstance();
          java.net.URL url = new java.net.URL(new test.wsdl.arrays3.testclient.AddrBookServiceImplServiceLocator().getarrays3Address()
+ "?WSDL");
          javax.xml.rpc.Service service = serviceFactory.createService(url, new test.wsdl.arrays3.testclient.AddrBookServiceImplServiceLocator().getServiceName());
          assertTrue(service != null);
      }
  
      public void testFunctional() throws Exception {
          test.wsdl.arrays3.testclient.Arrays3SoapBindingStub binding;
          try {
              binding = (test.wsdl.arrays3.testclient.Arrays3SoapBindingStub)
                            new test.wsdl.arrays3.testclient.AddrBookServiceImplServiceLocator().getarrays3();
          }
          catch (javax.xml.rpc.ServiceException jre) {
              if(jre.getLinkedCause()!=null)
                  jre.getLinkedCause().printStackTrace();
              throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught:
" + jre);
          }
          assertNotNull("binding is null", binding);
  
          test.wsdl.arrays3.testclient.Phone ph1 = new test.wsdl.arrays3.testclient.Phone();
          ph1.setAreaCode(765);
          ph1.setExchange("494");
          ph1.setNumber("4900");
  
          test.wsdl.arrays3.testclient.Phone ph2 = new test.wsdl.arrays3.testclient.Phone();
          ph2.setAreaCode(765);
          ph2.setExchange("494");
          ph2.setNumber("4901");
  
          test.wsdl.arrays3.testclient.Phone ph3 = new test.wsdl.arrays3.testclient.Phone();
          ph3.setAreaCode(765);
          ph3.setExchange("494");
          ph3.setNumber("4902");
  
          test.wsdl.arrays3.testclient.StateType state = new test.wsdl.arrays3.testclient.StateType();
          state.setState("IN");
  
          test.wsdl.arrays3.testclient.Address addr = new test.wsdl.arrays3.testclient.Address();
          addr.setCity("West Lafayette");
          addr.setState(state);
          addr.setStreetName("University Drive");
          addr.setStreetNum(1);
          addr.setZip(47907);
          addr.setPhoneNumber(ph1);
          test.wsdl.arrays3.testclient.ArrayOfPhone arrph = new test.wsdl.arrays3.testclient.ArrayOfPhone();
          arrph.setItem(new test.wsdl.arrays3.testclient.Phone[] { ph2, ph3});
          addr.setOtherPhones(arrph);
  
          test.wsdl.arrays3.testclient.Address[] addrs = null;
  
          addrs = binding.getAddressFromNames(null);
          assertNull("addrs is not null", addrs);
          // if (addrs != null) System.out.println("addrs.length = " + addrs.length);
  
          addrs = binding.getAddressFromNames(new String[] { });
          assertNull("addrs is not null", addrs);
          // if (addrs != null) System.out.println("addrs.length = " + addrs.length);
  
          addrs = binding.getAddressFromNames(new String[] { "unknown", "unregistered" });
          assertEquals("addrs.length should be 2", addrs.length, 2);
          System.out.println("addrs.length = " + addrs.length);
  
  
          binding.addEntry("Purdue Boilermaker", addr);
          test.wsdl.arrays3.testclient.Address retAddr1 = 
              binding.getAddressFromName("Purdue Boilermaker");
  
          binding.addEntry("Boilermaker Purdue", addr);
          test.wsdl.arrays3.testclient.Address retAddrs[] = 
              binding.getAddressFromNames(new String[] { "Purdue Boilermaker", "Boilermaker
Purdue" });
  
          retAddrs = binding.echoAddresses(null);
          assertNull("retAddrs is not null", retAddrs);
  
          retAddrs = binding.echoAddresses(new test.wsdl.arrays3.testclient.Address[] { });
          assertNull("retAddrs is not null", retAddrs);
  
          retAddrs = binding.echoAddresses(new test.wsdl.arrays3.testclient.Address[] { addr
});
          assertEquals("retAddrs.length should be 1", 1, retAddrs.length);
          assertTrue("addr does not match", compareAddress(addr, retAddrs[0]));
  
          addr.setOtherPhones(null);
          retAddrs = binding.echoAddresses(new test.wsdl.arrays3.testclient.Address[] { addr
});
          assertEquals("retAddrs.length should be 1", 1, retAddrs.length);
          assertTrue("addr does not match", compareAddress(addr, retAddrs[0]));
          assertNull("retAddrs[0].getOtherPhones() should be null", retAddrs[0].getOtherPhones());
         
          test.wsdl.arrays3.testclient.ArrayOfPhone arrph1 = new test.wsdl.arrays3.testclient.ArrayOfPhone();
          arrph1.setItem(new test.wsdl.arrays3.testclient.Phone[] { });
          addr.setOtherPhones(arrph1);
          retAddrs = binding.echoAddresses(new test.wsdl.arrays3.testclient.Address[] { addr
});
          assertEquals("retAddrs.length should be 1", 1, retAddrs.length);
  
          // length-0 array echoes as null now. 
          // So don't check object equality but check that value is null.
          
          // assertTrue("addr does not match", compareAddress(addr, retAddrs[0]));
          assertNull("retAddrs[0].getOtherPhones() should be null", retAddrs[0].getOtherPhones());
  
          addr.setOtherPhones(arrph);
          retAddrs = binding.echoAddresses(new test.wsdl.arrays3.testclient.Address[] { addr
});
          assertEquals("addrs.length should be 1", 1, retAddrs.length);
          assertTrue("addr does not match", compareAddress(addr, retAddrs[0]));
  
          retAddrs = binding.echoAddresses(new test.wsdl.arrays3.testclient.Address[] { addr,
addr });
          assertEquals("addrs.length should be 2", 2, retAddrs.length);
          assertTrue("addr does not match", compareAddress(addr, retAddrs[0]));
          assertTrue("addr does not match", compareAddress(addr, retAddrs[1]));
  
          test.wsdl.arrays3.testclient.Address[] retAddrs2 = binding.echoAddresses(retAddrs);
          assertEquals("addrs.length should be 2", 2, retAddrs2.length);
          assertTrue("addr does not match", compareAddress(retAddrs[0], retAddrs2[0]));
          assertTrue("addr does not match", compareAddress(retAddrs[1], retAddrs2[1]));
      }
  
  
      public boolean compareAddress(test.wsdl.arrays3.testclient.Address addr1, test.wsdl.arrays3.testclient.Address
addr2) {
          if (addr1 == null && addr2 != null) {
              throw new AssertionFailedError("");
          }
          if (addr1 != null && addr2 == null) {
              throw new AssertionFailedError("");
          }
          if (addr1 == null && addr2 == null) {
              return true;
          }
  
          if (!addr1.getCity().equals(addr2.getCity()))  {
              throw new AssertionFailedError("");
          }
  
          if (!addr1.getStreetName().equals(addr2.getStreetName()))  {
              throw new AssertionFailedError("");
          }
  
          if (addr1.getStreetNum() != addr2.getStreetNum()) {
              throw new AssertionFailedError("");
          }
  
          if (addr1.getZip() != addr2.getZip()) {
              throw new AssertionFailedError("");
          }
  
          if (!comparePhone(addr1.getPhoneNumber(), addr2.getPhoneNumber())) {
              throw new AssertionFailedError("");
          }
  
          if (!compareStateType(addr1.getState(), addr2.getState())) {
              throw new AssertionFailedError("");
          }
  
          if (!compareArrayOfPhone(addr1.getOtherPhones(), addr2.getOtherPhones())) {
              throw new AssertionFailedError("");
          }
  
          return true;
      }
  
      public boolean compareArrayOfPhone(test.wsdl.arrays3.testclient.ArrayOfPhone aop1, 
              test.wsdl.arrays3.testclient.ArrayOfPhone aop2) {
          if (aop1 == null && aop2 != null) {
              throw new AssertionFailedError("");
          }
          if (aop1 != null && aop2 == null) {
              throw new AssertionFailedError("");
          }
          if (aop1 == null && aop2 == null) {
              return true;
          }
          return comparePhoneArray(aop1.getItem(), aop2.getItem()); 
      }
  
      public boolean comparePhoneArray(test.wsdl.arrays3.testclient.Phone[] arr1, 
              test.wsdl.arrays3.testclient.Phone[] arr2) {
          if (arr1 == null && arr2 != null) {
              throw new AssertionFailedError("");
          }
          if (arr1 != null && arr2 == null) {
              throw new AssertionFailedError("");
          }
          if (arr1 == null && arr2 == null) {
              return true;
          }
          if (arr1.length != arr2.length) {
              throw new AssertionFailedError("");
          }
          for (int i = 0; i < arr1.length; i++) {
              if (comparePhone(arr1[i], arr2[i]) == false) {
                  throw new AssertionFailedError("");
              }
          }
          return true;
      }
  
      public boolean comparePhone(test.wsdl.arrays3.testclient.Phone phone1, test.wsdl.arrays3.testclient.Phone
phone2) {
          if (phone1 == null && phone2 != null) {
              throw new AssertionFailedError("");
          }
          if (phone1 != null && phone2 == null) {
              throw new AssertionFailedError("");
          }
          if (phone1 == null && phone2 == null) {
              return true;
          }
  
          if (phone1.getAreaCode() != phone2.getAreaCode()) {
              throw new AssertionFailedError("");
          }
  
          if (!phone1.getExchange().equals(phone2.getExchange()))  {
              throw new AssertionFailedError("");
          }
          if (!phone1.getNumber().equals(phone2.getNumber()))  {
              throw new AssertionFailedError("");
          }
  
          return true;
      }
  
      public boolean compareStateType(test.wsdl.arrays3.testclient.StateType st1, test.wsdl.arrays3.testclient.StateType
st2) {
          if (st1 == null && st2 != null) {
              throw new AssertionFailedError("");
          }
          if (st1 != null && st2 == null) {
              throw new AssertionFailedError("");
          }
          if (st1 == null && st2 == null) {
              return true;
          }
          if (!st1.getState().equals(st2.getState()))  {
              throw new AssertionFailedError("");
          }
          return true; 
      }
  
  
  }
  
  
  
  1.1                  ws-axis/java/test/wsdl/arrays3/Address.java
  
  Index: Address.java
  ===================================================================
  package test.wsdl.arrays3;
  
  public class Address  implements java.io.Serializable {
      private String city;
      private Phone phoneNumber;
      private StateType state;
      private String streetName;
      private int streetNum;
      private int zip;
      private Phone[] otherPhones;
  
      public Address() {
      }
  
      /**
       * Gets the city value for this Address.
       * 
       * @return city
       */
      public java.lang.String getCity() {
          return city;
      }
  
  
      /**
       * Sets the city value for this Address.
       * 
       * @param city
       */
      public void setCity(java.lang.String city) {
          this.city = city;
      }
  
  
      /**
       * Gets the phoneNumber value for this Address.
       * 
       * @return phoneNumber
       */
      public Phone getPhoneNumber() {
          return phoneNumber;
      }
  
  
      /**
       * Sets the phoneNumber value for this Address.
       * 
       * @param phoneNumber
       */
      public void setPhoneNumber(Phone phoneNumber) {
          this.phoneNumber = phoneNumber;
      }
  
  
      /**
       * Gets the state value for this Address.
       * 
       * @return state
       */
      public StateType getState() {
          return state;
      }
  
  
      /**
       * Sets the state value for this Address.
       * 
       * @param state
       */
      public void setState(StateType state) {
          this.state = state;
      }
  
  
      /**
       * Gets the streetName value for this Address.
       * 
       * @return streetName
       */
      public java.lang.String getStreetName() {
          return streetName;
      }
  
  
      /**
       * Sets the streetName value for this Address.
       * 
       * @param streetName
       */
      public void setStreetName(java.lang.String streetName) {
          this.streetName = streetName;
      }
  
  
      /**
       * Gets the streetNum value for this Address.
       * 
       * @return streetNum
       */
      public int getStreetNum() {
          return streetNum;
      }
  
  
      /**
       * Sets the streetNum value for this Address.
       * 
       * @param streetNum
       */
      public void setStreetNum(int streetNum) {
          this.streetNum = streetNum;
      }
  
  
      /**
       * Gets the zip value for this Address.
       * 
       * @return zip
       */
      public int getZip() {
          return zip;
      }
  
  
      /**
       * Sets the zip value for this Address.
       * 
       * @param zip
       */
      public void setZip(int zip) {
          this.zip = zip;
      }
  
      public void setOtherPhones(Phone[] phones) {
          otherPhones = phones;
      }
  
      public Phone[] getOtherPhones() {
          return otherPhones;
      }
  }
  
  
  
  1.1                  ws-axis/java/test/wsdl/arrays3/StateType.java
  
  Index: StateType.java
  ===================================================================
  package test.wsdl.arrays3;
  
  public class StateType  implements java.io.Serializable {
      private java.lang.String state;
  
      public StateType() {
      }
  
      public StateType(
             java.lang.String state) {
             this.state = state;
      }
  
  
      /**
       * Gets the state value for this StateType.
       * 
       * @return state
       */
      public java.lang.String getState() {
          return state;
      }
  
  
      /**
       * Sets the state value for this StateType.
       * 
       * @param state
       */
      public void setState(java.lang.String state) {
          this.state = state;
      }
  
  }
  
  
  

Mime
View raw message