axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bu...@us.ibm.com
Subject Re: You changed the sequence test? (was: Re: cvs commit: xml-axis/java/test/wsdl/sequence SequenceService.java deploy.wsdd readme.txt SequenceTest.wsdl SequenceTestServiceTestCase.java buildComponent.xml SequenceInfo.java SequenceTestSoapBindingImpl.java)
Date Tue, 30 Jul 2002 12:54:08 GMT

What happened here?  My note was empty!  Is Lotus notes screwing up my
fonts again?  Made them of size 0?  Colored them white?  Let me try
again...

Just one comment, Glen.  You've simplified the sequence test.  That means
it doesn't test what it used to.  I won't argue whether it tested the
proper thing - I don't really know that test well - I don't know what Rich
intended with it.  I just want to flag your change so that he can take a
look at it once he gets back from vacation.

Russell Butek
butek@us.ibm.com


Russell Butek/Austin/IBM@IBMUS on 07/30/2002 07:23:25 AM

Please respond to axis-dev@xml.apache.org

To:    axis-dev@xml.apache.org
cc:
Subject:    You changed the sequence test? (was: Re: cvs commit: xml-
       axis/java/test/wsdl/sequence SequenceService.java deploy.wsdd
       readme.txt SequenceTest.wsdl SequenceTestServiceTestCase.java
       buildComponent.xml SequenceInfo.java SequenceTestSoapBindingImpl.
       java)




Russell Butek
butek@us.ibm.com

Please respond to axis-dev@xml.apache.org

To:   xml-axis-cvs@apache.org
cc:
Subject:    cvs commit: xml-axis/java/test/wsdl/sequence SequenceService.
java deploy.wsdd readme.txt SequenceTest.wsdl SequenceTestServiceTestCase.
java buildComponent.xml SequenceInfo.java SequenceTestSoapBindingImpl.java



gdaniels    2002/07/29 23:16:04


   Modified:    java/src/org/apache/axis/encoding/ser BeanDeserializer.java
   BeanPropertyTarget.java
               java/src/org/apache/axis/message BodyBuilder.java
               java/src/org/apache/axis/utils BeanPropertyDescriptor.java
               BeanUtils.java
               java/test/wsdl Wsdl2javaTestSuite.xml
               java/test/wsdl/arrays PersonalInfoBookServiceTestCase.java
               java/test/wsdl/sequence SequenceTest.wsdl
   SequenceTestServiceTestCase.java buildComponent.xml
   Added:       java/src/org/apache/axis/utils FieldPropertyDescriptor.java
               java/test/wsdl/sequence SequenceService.java deploy.wsdd
               readme.txt
   Removed:     java/test/wsdl/sequence SequenceInfo.java
   SequenceTestSoapBindingImpl.java
   Log:
   Several changes which came up while investigating a problem
   serializing <sequence>s in the correct order.

   * Fixed sequence test

   Sequence test now tests the actual XML produced, instead of
   going through a deserialization test with a custom class which
   was obscuring the actual generated class produced by WSDL2Java.

   There is also a possible test here which confirms that the schema
   generated from our generated Java classes still has the right
   <sequence> declaration, but since that wasn't being done, the
   roundtripping through Java2WSDL again didn't make sense to me.

   End result, test is much simpler now and actually tests what it
   seems to be intending to.  (and has a readme.txt)

   * Revamped BeanPropertyDescriptor for cleanliness and shrinkage

   The old version of this class was repeating a lot of work which is
   done for us automatically by the bean framework itself.  For
   instance, keeping track of indexed properties - this just works
   via the standard PropertyDescriptor class, so this new version
   takes advantage of that fact and simply wraps the PD.

   One might wonder why we need this class at all if it's just
   a wrapper - two answers.  First, we do some cool stuff with array
   maintenance, and second, we use this same interface to deal with
   publically accessible fields, something that standard PD's can't
   do.  Speaking of which...

   * Deal with Fields with an explicit subclass of BPD

   This removes the need for a lot of if statements and cleans
   up the code a good deal.  Now we just make sure to create
   a FieldPropertyDescriptor where we used to use the Field
   constructor of the BeanPropertyDescriptor.  Now the vtable
   does our branching for us with no conditionals.

   * BeanUtils vastly simplified

   This I'd really appreciate comments on.  I pulled out the
   code that does the "manual" run through the introspected
   methods of our target class, and instead just start with
   the PropertyDescriptors returned by the Introspector,
   adding only the public Fields.

   As I understand it the purpose of the code that was there
   before was to try to order the generated descriptor
   in something close to the order that things are defined
   in the... Java source, perhaps?  I don't think there's
   any guarantee that a given compiler will order things
   in any particular way, so I don't see the point of
   bothering.

   All tests pass fine without this code, but if people
   can explain to me why what it did was useful, I'll be
   happy to put it back.

   * BeanDeserializer only uses indexed BPT when appropriate

   We now only use the indexed version of the BeanPropertyTarget
   when the deserializer found for a given QName is NOT the
   ArrayDeserializer.  If we have the ArrayDeserializer, we know
   this is a SOAP array, which will have an outer "wrapper"
   element, and whose value will be a single array object (i.e.
   a String []).  In this case, we want to use the normal
   BPT because the value which will be set is for the array
   field, not the items of the array.

   NOTE: This will likely fail with arrays of arrays, we should
   a) think about that, and b) write a test for it.

   * Remove some try/catch blocks in test cases, so that we can
   see the actual failures as they happen.

   TODO : I plan to change the TestCase-generating framework, as
   discussed before, to stop putting in the try/catch blocks
   around everything.  Tests should let most Exceptions bubble
   up through.

   * Various bits of cleanup

   NOTES: we don't have enough tests.  There should be a
   grueling regression test for the BPD/BeanUtils related
   classes, amongst other things.  There is also some more
   potential refactoring of BeanPropertyDescriptor /
   FieldDesc / Target which might make sense to lean things
   down even more.

   I'm going to stop writing now before the checkin comments
   get longer than the diffs... :)

   Revision  Changes    Path
   1.41      +48 -26    xml-
   axis/java/src/org/apache/axis/encoding/ser/BeanDeserializer.java

   Index: BeanDeserializer.java
   ===================================================================
   RCS file: /home/cvs/xml-
   axis/java/src/org/apache/axis/encoding/ser/BeanDeserializer.java,v
   retrieving revision 1.40
   retrieving revision 1.41
   diff -u -r1.40 -r1.41
   --- BeanDeserializer.java  23 Jul 2002 12:54:01 -0000    1.40
   +++ BeanDeserializer.java  30 Jul 2002 06:16:04 -0000    1.41
   @@ -1,8 +1,7 @@
   /*
   * The Apache Software License, Version 1.1
   *
   - *
   - * Copyright (c) 2001 The Apache Software Foundation.  All rights
   + * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   @@ -147,7 +146,8 @@
   * @param namespace is the namespace of the element
   * @param localName is the name of the element
   * @param qName is the prefixed qName of the element
   -     * @param attributes are the attributes on the element...used to
   get the type
   +     * @param attributes are the attributes on the element...used to
   get the
   +     *                   type
         * @param context is the DeserializationContext
         */
   public void startElement(String namespace, String localName,
   @@ -223,7 +223,8 @@
            propDesc = (BeanPropertyDescriptor) propertyMap.get(localName);
            }
   -        // try and see if this is an xsd:any namespace="##any" element
   before reporting a problem
   +        // try and see if this is an xsd:any namespace="##any" element
   before
   +        // reporting a problem
            QName qn = null;
            Deserializer dSer = null;
            MessageContext messageContext = context.getMessageContext();
   @@ -234,8 +235,11 @@
   dSer = context.getDeserializerForType(elemQName);
   if (dSer == null)  {
   qn = Constants.XSD_ANY;
   -                    // make sure that the Element Deserializer
   deserializes the current element and not the child
   -                    messageContext.setProperty(ElementDeserializer.
   DESERIALIZE_CURRENT_ELEMENT, Boolean.TRUE);
   +                    // make sure that the Element Deserializer
   deserializes
   +                    // the current element and not the child
   +                    messageContext.setProperty(ElementDeserializer.
   +                                                    DESERIALIZE_CURRENT_ELEMENT,
   +                                               Boolean.TRUE);
                  } else {
                  qn = elemQName;
   }
   @@ -254,7 +258,8 @@
            // Look at the type attribute specified.  If this fails,
            // use the javaType of the property to get the type qname.
            if (qn == null) {
   -            qn = context.getTypeFromAttributes(namespace, localName,
   attributes);
   +            qn = context.getTypeFromAttributes(namespace, localName,
   +                                               attributes);
            }

   // get the deserializer
   @@ -274,28 +279,41 @@
            }

   if (propDesc.isWriteable()) {
   -            if (!propDesc.isIndexed()) {
   -                // Success!  Register the target and deserializer.
   -                collectionIndex = -1;
   -                dSer.registerValueTarget(
   -                                         new BeanPropertyTarget(value,
   propDesc));
   +            // If this is an indexed property, and the deserializer we
   found
   +            // was NOT the ArrayDeserializer, this is a non-SOAP array:
   +            // <bean>
   +            //   <field>value1</field>
   +            //   <field>value2</field>
   +            // ...
   +            // In this case, we want to use the collectionIndex and
   make sure
   +            // the deserialized value for the child element goes into
   the
   +            // right place in the collection.
   +            if (propDesc.isIndexed() && !(dSer instanceof
   ArrayDeserializer)) {
   +                    collectionIndex++;
   +                    dSer.registerValueTarget(new
   BeanPropertyTarget(value,
   +                                                    propDesc,
   collectionIndex));
   } else {
   -                // Success! This is a collection of properties so use
   the index
   -                collectionIndex++;
   -                dSer.registerValueTarget(
   -                                         new BeanPropertyTarget(value,
   -                                            propDesc,
   -                                            collectionIndex));
   +                // If we're here, the element maps to a single field
   value,
   +                // whether that be a "basic" type or an array, so use
   the
   +                // normal (non-indexed) BeanPropertyTarget form.
   +                collectionIndex = -1;
   +                dSer.registerValueTarget(new BeanPropertyTarget(value,
   +                                                                propDesc));

            }
            }
            return (SOAPHandler)dSer;
      }

   -     public BeanPropertyDescriptor getObjectPropertyDesc(QName qname,
   DeserializationContext context) {
   -        for (Iterator iterator = propertyMap.values().iterator();
   iterator.hasNext();) {
   -            BeanPropertyDescriptor propertyDesc =
   (BeanPropertyDescriptor) iterator.next();
   +     public BeanPropertyDescriptor
   +             getObjectPropertyDesc(QName qname,
   +                                   DeserializationContext context) {
   +        for (Iterator iterator = propertyMap.values().iterator();
   +             iterator.hasNext();) {
   +            BeanPropertyDescriptor propertyDesc =
   +                    (BeanPropertyDescriptor) iterator.next();
   // try to find xsd:any namespace="##any" property
   -            if (propertyDesc.getName().equals("any") && propertyDesc.
   getType().getName().equals("java.lang.Object")) {
   +            if (propertyDesc.getName().equals("any") &&
   +                propertyDesc.getType().getName().equals("java.lang.
   Object")) {
               return propertyDesc;
               }
   }
   @@ -306,11 +324,13 @@
         * Set the bean properties that correspond to element attributes.
         *
         * This method is invoked after startElement when the element
         requires
   -     * deserialization (i.e. the element is not an href and the value
   is not nil.)
   +     * deserialization (i.e. the element is not an href and the value
   is not
   +     * nil.)
         * @param namespace is the namespace of the element
         * @param localName is the name of the element
         * @param qName is the prefixed qName of the element
   -     * @param attributes are the attributes on the element...used to
   get the type
   +     * @param attributes are the attributes on the element...used to
   get the
   +     *                   type
         * @param context is the DeserializationContext
         */
   public void onStartElement(String namespace, String localName,
   @@ -357,7 +377,8 @@
                  QName qn = tm.getTypeQName(type);
                  if (qn == null)
   throw new SAXException(
   -                            JavaUtils.getMessage("unregistered00",
   type.toString()));
   +                            JavaUtils.getMessage("unregistered00",
   +                                                 type.toString()));
                  // get the deserializer
                  Deserializer dSer = context.getDeserializerForType(qn);
   @@ -373,7 +394,8 @@
   // Success!  Create an object from the string and set
   // it in the bean
   try {
   -                    dSer.onStartElement(namespace, localName, qName,
   attributes, context);
   +                    dSer.onStartElement(namespace, localName, qName,
   +                                        attributes, context);
                        Object val = ((SimpleDeserializer)dSer).
                        makeValue(attributes.getValue(i));
                        bpd.set(value, val);


   1.13      +0 -1      xml-
   axis/java/src/org/apache/axis/encoding/ser/BeanPropertyTarget.java

   Index: BeanPropertyTarget.java
   ===================================================================
   RCS file: /home/cvs/xml-
   axis/java/src/org/apache/axis/encoding/ser/BeanPropertyTarget.java,v
   retrieving revision 1.12
   retrieving revision 1.13
   diff -u -r1.12 -r1.13
   --- BeanPropertyTarget.java      3 Jul 2002 17:50:22 -0000     1.12
   +++ BeanPropertyTarget.java      30 Jul 2002 06:16:04 -0000    1.13
   @@ -55,7 +55,6 @@

   package org.apache.axis.encoding.ser;

   -import org.apache.axis.AxisProperties;
   import org.apache.axis.encoding.Target;
   import org.apache.axis.utils.BeanPropertyDescriptor;
   import org.apache.axis.utils.JavaUtils;



   1.44      +9 -4      xml-
   axis/java/src/org/apache/axis/message/BodyBuilder.java

   Index: BodyBuilder.java
   ===================================================================
   RCS file: /home/cvs/xml-
   axis/java/src/org/apache/axis/message/BodyBuilder.java,v
   retrieving revision 1.43
   retrieving revision 1.44
   diff -u -r1.43 -r1.44
   --- BodyBuilder.java 3 Jul 2002 17:50:29 -0000     1.43
   +++ BodyBuilder.java 30 Jul 2002 06:16:04 -0000    1.44
   @@ -60,9 +60,9 @@
   * @author Glen Daniels (gdaniels@allaire.com)
   */

   -import org.apache.axis.AxisProperties;
   import org.apache.axis.Constants;
   import org.apache.axis.MessageContext;
   +import org.apache.axis.soap.SOAPConstants;
   import org.apache.axis.description.OperationDesc;
   import org.apache.axis.encoding.DeserializationContext;
   import org.apache.axis.enum.Style;
   @@ -149,6 +149,8 @@
   throw new SAXException(e);
            }

   +        Style style = operations == null ? Style.RPC : operations[0].
   getStyle();
   +
            /** Now we make a plain SOAPBodyElement IF we either:
            * a) have an non-root element, or
            * b) have a non-RPC service
   @@ -160,9 +162,7 @@
   handler = new SOAPFaultBuilder((SOAPFault)element,
            context);
            } else if (!gotRPCElement) {
   -            if (isRoot &&
   -                (operations == null ||
   -                 (operations[0].getStyle() != Style.MESSAGE))) {
   +            if (isRoot && (style != Style.MESSAGE)) {
                  gotRPCElement = true;

   try {
   @@ -194,6 +194,11 @@
            }

   if (element == null) {
   +            if (style == Style.RPC &&
   +                    context.getMessageContext().getSOAPConstants() ==
   +                    SOAPConstants.SOAP12_CONSTANTS) {
   +                throw new SAXException("Only one body allowed for SOAP
   1.2 RPC");
   +            }
               element = new SOAPBodyElement(namespace, localName, prefix,
               attributes, context);
               if (element.getFixupDeserializer() != null)


   1.11      +64 -152   xml-
   axis/java/src/org/apache/axis/utils/BeanPropertyDescriptor.java

   Index: BeanPropertyDescriptor.java
   ===================================================================
   RCS file: /home/cvs/xml-
   axis/java/src/org/apache/axis/utils/BeanPropertyDescriptor.java,v
   retrieving revision 1.10
   retrieving revision 1.11
   diff -u -r1.10 -r1.11
   --- BeanPropertyDescriptor.java  12 Jul 2002 22:38:55 -0000    1.10
   +++ BeanPropertyDescriptor.java  30 Jul 2002 06:16:04 -0000    1.11
   @@ -55,139 +55,82 @@
   package org.apache.axis.utils;

   import java.lang.reflect.Array;
   -import java.lang.reflect.Field;
   import java.lang.reflect.InvocationTargetException;
   -import java.lang.reflect.Method;
   +import java.beans.PropertyDescriptor;
   +import java.beans.IndexedPropertyDescriptor;

   import org.apache.axis.components.logger.LogFactory;
   -import org.apache.axis.AxisFault;
   import org.apache.commons.logging.Log;


   /**
   - * This class is essentially a copy of the PropertyDescriptor
   information, except
   - * that the values in it can be modified.
   - * Updated this to include fields that don't have getter/setters.
   + * This class represents a field/property in a value type (a class with
   either
   + * bean-style getters/setters or public fields).
   + *
   + * It is essentially a thin wrapper around the PropertyDescriptor from
   the
   + * JavaBean utilities.  We wrap it with this class so that we can
   create
   + * the subclass FieldPropertyDescriptor and access public fields (who
   + * wouldn't have PropertyDescriptors normally) via the same interface.
   + *
   + * There are also some interesting tricks where indexed properties are
   + * concerned, mostly involving the fact that we manage the arrays here
   + * rather than relying on the value type class to do it itself.
   + *
   * @author Rich Scheuerle <scheu@us.ibm.com>
   + * @author Glen Daniels (gdaniels@apache.org)
   **/
   public class BeanPropertyDescriptor
   {
      protected static Log log =
      LogFactory.getLog(BeanPropertyDescriptor.class.getName());
   -    private String name = null;
   -    private Method getter = null;
   -    private Method setter = null;
   -    private Method getterIndexed = null;
   -    private Method setterIndexed = null;
   -    private Field field = null;
   -    private static final Object[] noArgs = new Object[] {};
   +    protected PropertyDescriptor myPD = null;

   -    /**
   -     * Construct a BPD with getter/setter methods
   -     * Both must be set
   -     * @param _name is the name of the property
   -     * @param _getter is the accessor method
   -     * @param _setter is the modifier method
   -     */
   -    public BeanPropertyDescriptor(String _name,
   -                                  Method _getter,
   -                                  Method _setter) {
   -        name = _name;
   -        getter = _getter;
   -        setter = _setter;
   -        if (_getter == null || _setter == null || _name == null) {
   -            throw new IllegalArgumentException(
   -                    JavaUtils.getMessage(_getter == null ?
   -                                         "badGetter00" :
   -                                         (_setter == null ?
   -                                         "badSetter00" :
   "badProp03")));
   -        }
   -    }
   +    protected static final Object[] noArgs = new Object[] {};

   -    /**
   -     * Construct a BPD with getter/setter methods for
   -     * an indexed property.  All params must be set.
   -     * @param _name is the name of the property
   -     * @param _getter is the accessor method
   -     * @param _setter is the modifier method
   -     * @param _getterIndexed is the accessor method
   -     * @param _setterIndexed is the modifier method
   +    /**
   +     * Constructor (takes a PropertyDescriptor)
   +     *
   +     * @param pd
   */
   -    public BeanPropertyDescriptor(String _name,
   -                                  Method _getter,
   -                                  Method _setter,
   -                                  Method _getterIndexed,
   -                                  Method _setterIndexed) {
   -        this(_name, _getter, _setter);
   -        getterIndexed = _getterIndexed;
   -        setterIndexed = _setterIndexed;
   -        if (_getterIndexed == null || _setterIndexed == null) {
   -            throw new IllegalArgumentException(
   -                    JavaUtils.getMessage(_getterIndexed == null ?
   -                                         "badAccessor00" :
   "badModifier00"));
   -        }
   +    public BeanPropertyDescriptor(PropertyDescriptor pd) {
   +        myPD = pd;
      }

   -    /**
   -     * Construct a BPD with only a getter method
   -     * @param _name is the name of the property
   -     * @param _getter is the accessor method
   +    /**
   +     * Protected constructor for use by our children
   */
   -    public BeanPropertyDescriptor(String _name,
   -                                  Method _getter) {
   -        name = _name;
   -        getter = _getter;
   -        setter = null;
   -        if (_getter == null || _name == null) {
   -            throw new IllegalArgumentException(
   -                    JavaUtils.getMessage(getter == null ?
   -                                         "badGetter00" :
   -                                         "badProp03"));
   -        }
   +    protected BeanPropertyDescriptor() {
      }

   -    /**
   -     * Construct a BPD with a field
   -     * Both must be set
   -     * @param _name is the name of the property
   -     * @param _field is the name of the public instance field
   +    /**
   +     * Get our property name.
   */
   -    public BeanPropertyDescriptor(String _name,
   -                                  Field _field) {
   -        name = _name;
   -        field = _field;
   -        if (_field == null || _name == null) {
   -            throw new IllegalArgumentException(
   -                    JavaUtils.getMessage(_field == null ?
   -                                         "badField00" : "badProp03"));
   -        }
   +    public String getName(){
   +        return myPD.getName();
   }
   -
   -    /**
   +
   +    /**
         * Query if property is readable
         * @return true if readable
         */
   public boolean isReadable() {
   -        return (getter != null ||
   -                field != null);
   +        return (myPD.getReadMethod() != null);
   }
   -    /**
   +
   +    /**
         * Query if property is writeable
         * @return true if writeable
         */
   public boolean isWriteable() {
   -        return (setter != null ||
   -                field != null);
   +        return (myPD.getWriteMethod() != null);
      }
      /**
   * Query if property is indexed.
   -     * Indexed properties require valid setters/getters
         * @return true if indexed methods exist
         */
   public boolean isIndexed() {
   -        return (getterIndexed != null &&
   -                setterIndexed != null);
   +        return (myPD instanceof IndexedPropertyDescriptor);
      }

   /**
   @@ -197,10 +140,8 @@
      */
      public Object get(Object obj)
   throws InvocationTargetException, IllegalAccessException {
   -        if (getter != null) {
   -            return getter.invoke(obj, noArgs);
   -        } else if (field != null) {
   -            return field.get(obj);
   +        if (myPD.getReadMethod() != null) {
   +            return myPD.getReadMethod().invoke(obj, noArgs);
            }
            throw new IllegalAccessException(JavaUtils.
            getMessage("badGetter00"));
   }
   @@ -211,10 +152,8 @@
      */
      public void set(Object obj, Object newValue)
   throws InvocationTargetException, IllegalAccessException {
   -        if (setter != null) {
   -            setter.invoke(obj, new Object[] {newValue});
   -        } else if (field != null) {
   -            field.set(obj, newValue);
   +        if (myPD.getWriteMethod() != null) {
   +            myPD.getWriteMethod().invoke(obj, new Object[] {newValue});
            } else {
            throw new IllegalAccessException(JavaUtils.
            getMessage("badSetter00"));
   }
   @@ -230,9 +169,13 @@
            if (!isIndexed()) {
            return Array.get(get(obj), i);
   } else {
   -            return getterIndexed.invoke(obj, new Object[] { new
   Integer(i)});
   +            IndexedPropertyDescriptor id = (IndexedPropertyDescriptor)
   myPD;
   +            return id.getIndexedReadMethod().invoke(obj,
   +                                                    new Object[] {
   +                                                        new
   Integer(i)});
      }
      }
   +
   /**
         * Set an indexed property value
         * @param obj is the object
   @@ -241,22 +184,27 @@
   */
      public void set(Object obj, int i, Object newValue)
      throws InvocationTargetException, IllegalAccessException {
   +        // Set the new value
   +        if (isIndexed()) {
   +            IndexedPropertyDescriptor id = (IndexedPropertyDescriptor)
   myPD;
   +            growArrayToSize(obj, id.getIndexedPropertyType(), i);
   +            id.getIndexedWriteMethod().invoke(obj,
   +                                              new Object[] {
   +                                                  new Integer(i),
   newValue});
   +        } else {
   +            Array.set(get(obj), i, newValue);
   +        }
   +    }

   +    protected void growArrayToSize(Object obj, Class componentType, int
   i)
   +            throws InvocationTargetException, IllegalAccessException {
            // Get the entire array and make sure it is large enough
            Object array = get(obj);
            if (array == null || Array.getLength(array) <= i) {
   // Construct a larger array of the same type
   -            Class componentType = null;
   -            if (getterIndexed != null) {
   -                componentType = getterIndexed.getReturnType();
   -            } else if (getter != null) {
   -                componentType = getter.getReturnType().
   getComponentType();
   -            } else {
   -                componentType = field.getType().getComponentType();
   -            }
   -            Object newArray =
   -                Array.newInstance(componentType,i+1);
   -
   +            Object newArray =
   +                    Array.newInstance(componentType,i+1);
   +
               // Set the object to use the larger array
               set(obj, newArray);
   @@ -269,21 +217,6 @@
   set(obj, index, Array.get(array, index));
            }
            }
   -
   -        // Set the new value
   -        if (isIndexed()) {
   -            setterIndexed.invoke(obj, new Object[] {new Integer(i),
   newValue});
   -        } else {
   -            Array.set(get(obj), i, newValue);
   -        }
   -    }
   -
   -    /**
   -     * Get the name of a property
   -     * @return String name of the property
   -     */
   -    public String getName() {
   -        return name;
      }

   /**
   @@ -292,30 +225,9 @@
      */
      public Class getType() {
   if (isIndexed()) {
   -            return getterIndexed.getReturnType();
   -        } else if (getter != null) {
   -            return getter.getReturnType();
   +            return ((IndexedPropertyDescriptor)myPD).
   getIndexedPropertyType();
   } else {
   -            return field.getType();
   +            return myPD.getPropertyType();
   }
   -    }
   -
   -    /**
   -     * Get the read Method.
   -     * (This is package visibility so that Bean Utils
   -     * can access this information.  The other methods
   -     * should be used during serialization/deserialization.)
   -     */
   -    Method getReadMethod() {
   -        return getter;
   -    }
   -    /**
   -     * Get the write Method.
   -     * (This is package visibility so that Bean Utils
   -     * can access this information.  The other methods
   -     * should be used during serialization/deserialization.)
   -     */
   -    Method getWriteMethod() {
   -        return setter;
   }
   }



   1.11      +32 -163   xml-axis/java/src/org/apache/axis/utils/BeanUtils.
   java

   Index: BeanUtils.java
   ===================================================================
   RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/BeanUtils.
   java,v
   retrieving revision 1.10
   retrieving revision 1.11
   diff -u -r1.10 -r1.11
   --- BeanUtils.java   12 Jul 2002 22:38:55 -0000    1.10
   +++ BeanUtils.java   30 Jul 2002 06:16:04 -0000    1.11
   @@ -80,13 +80,19 @@
      /**
      * Create a BeanPropertyDescriptor array for the indicated class.
   -     * @param Class javaType
   -     * @param TypeDesc meta-data or null
   -     * @return array of properties in order
   +     * @param javaType
   +     * @return an ordered array of properties
      */
      public static BeanPropertyDescriptor[] getPd(Class javaType) {
      return getPd(javaType, null);
      }
   +
   +    /**
   +     * Create a BeanPropertyDescriptor array for the indicated class.
   +     * @param javaType
   +     * @param typeDesc
   +     * @return an ordered array of properties
   +     */
      public static BeanPropertyDescriptor[] getPd(Class javaType, TypeDesc
      typeDesc) {
      BeanPropertyDescriptor[] pd;
      try {
   @@ -179,173 +185,55 @@
   PropertyDescriptor[] rawPd, Class cls) {
      return processPropertyDescriptors(rawPd, cls, null);
      }
   +
   public static BeanPropertyDescriptor[] processPropertyDescriptors(
                     PropertyDescriptor[] rawPd, Class cls, TypeDesc
                     typeDesc) {

            // Create a copy of the rawPd called myPd
            BeanPropertyDescriptor[] myPd = new
            BeanPropertyDescriptor[rawPd.length];
   -        int index1 = 0;
   -        for (int i=0; i < rawPd.length; i++) {
   -            if (rawPd[i].getReadMethod() != null &&
   -                rawPd[i].getWriteMethod() != null) {
   -                myPd[index1++] = new BeanPropertyDescriptor(rawPd[i].
   getName(),
   -                                                            rawPd[i].
   getReadMethod(),
   -                                                            rawPd[i].
   getWriteMethod());
   -            }
   -        }
   +        ArrayList pd = new ArrayList();

   try {
   -
   -            // Create an Array List
   -            ArrayList pd = new ArrayList();
   -            for (int i=0; i < myPd.length; i++) {
   -                if (myPd[i] != null) {
   -                    pd.add(myPd[i]);
   -                }
   -            }
   -
   -            // Build a new pd array
   -            // defined by the order of the set methods.
   -            // *Note that this is not guaranteed since the getMethods
   -            // is not required to return the methods in the declared
   order;
   -            // however it seems to be the case most of the time.  The
   only way
   -            // to guarantee the correct ordering is if TypeDesc meta-
   data is available.
   -            int index = 0;
   -            ArrayList newPd = new ArrayList();
   -            for (int i=0; i <pd.size(); i++) {
   -                newPd.add(null);
   -            }
   -            Method[] methods = cls.getMethods();
   -            for (int i=0; i < methods.length; i++) {
   -                Method method = methods[i];
   -                if (method.getName().startsWith("set")) {
   -                    boolean found = false;
   -                    for (int j=0; j < pd.size() && !found; j++) {
   -                        if (pd.get(j) != null &&
   -                            ((BeanPropertyDescriptor)pd.get(j)).
   getWriteMethod() != null &&
   -                            ((BeanPropertyDescriptor)pd.get(j)).
   getWriteMethod().equals(method)) {
   -                            found = true;
   -                            newPd.set(index,pd.get(j));
   -                            index++;
   -                        }
   -                    }
   -                }
   -            }
   -            // Now if there are any additional property descriptors,
   add them to the end.
   -            if (index < pd.size()) {
   -                for (int m=0; m < pd.size() && index < pd.size(); m++)
   {
   -                    boolean found = false;
   -                    for (int n=0; n < index && !found; n++) {
   -                        found = (pd.get(m)==newPd.get(n));
   -                    }
   -                    if (!found) {
   -                        newPd.set(index,  pd.get(m));
   -                        index++;
   -                    }
   -                }
   -            }
   -            // If newPd has same number of elements as pd, use newPd.
   -            if (index == pd.size()) {
   -                pd = newPd;
   -            }
   -            myPd = new BeanPropertyDescriptor[pd.size()];
   -            for (int i=0; i <pd.size(); i++) {
   -                myPd[i] = (BeanPropertyDescriptor) pd.get(i);
   -            }
   -            // If the javaType is Throwable, add the getter methods to
   the list.
   -            if (Throwable.class.isAssignableFrom(cls)) {
   -                for (int i=0; i < methods.length; i++) {
   -                    Method method = methods[i];
   -                    if (method.getParameterTypes().length == 0 &&
   -                        method.getReturnType() != void.class &&
   -                        (method.getName().startsWith("get") ||
   -                         ((method.getName().startsWith("is") &&
   -                           method.getReturnType() == boolean.class)))
   &&
   -                        // Specifically prevent the Throwable get
   methods
   -                        !(method.getName().equals("getMessage") ||
   -                          method.getName().
   equals("getLocalizedMessage"))) {
   -                        boolean found = false;
   -                        for (int j=0; j < pd.size() && !found; j++) {
   -                            BeanPropertyDescriptor bpd =
   (BeanPropertyDescriptor) pd.get(j);
   -                            found = method.equals(bpd.getReadMethod());
   -                        }
   -                        if (!found) {
   -                            pd.add(new BeanPropertyDescriptor(
   -                               getPropNameFromReadMethod(method),
   -                               method));
   -                        }
   -                    }
   -                }
   -            }
   -
   -
   -            // Get the methods of the class and look for the special
   set and
   -            // get methods for property "collections"
   -            for (int i=0; i < methods.length; i++) {
   -                if (methods[i].getName().startsWith("set") &&
   -                    methods[i].getParameterTypes().length == 2) {
   -                    for (int j=0; j < methods.length; j++) {
   -                        if ((methods[j].getName().startsWith("get") ||
   -                             methods[j].getName().startsWith("is")) &&
   -                            methods[j].getParameterTypes().length == 1
   &&
   -                            methods[j].getReturnType() == methods[i].
   getParameterTypes()[1] &&
   -                            methods[j].getParameterTypes()[0] == int.
   class &&
   -                            methods[i].getParameterTypes()[0] == int.
   class) {
   -                            for (int k=0; k < pd.size(); k++) {
   -                                BeanPropertyDescriptor bpd =
   -                                    (BeanPropertyDescriptor) pd.get(k);
   -                                if (bpd != null &&
   -                                    bpd.getReadMethod() != null &&
   -                                    bpd.getWriteMethod() != null &&
   -                                    bpd.getReadMethod().getName().
   equals(methods[j].getName()) &&
   -                                    bpd.getWriteMethod().getName().
   equals(methods[i].getName())) {
   -                                    pd.set(k, new
   BeanPropertyDescriptor(bpd.getName(),
   -                                                                        

   bpd.getReadMethod(),
   -                                                                        

   bpd.getWriteMethod(),
   -                                                                        

   methods[j],
   -                                                                        

   methods[i]));
   -                                }
   -                            }
   -                        }
   -                    }
   -                }
   +            for (int i=0; i < rawPd.length; i++) {
   +                pd.add(new BeanPropertyDescriptor(rawPd[i]));
               }

               // Now look for public fields
               Field fields[] = cls.getFields();
   -            if (fields != null && fields.length > 0) {
   +            if (fields != null && fields.length > 0) {
                  // See if the field is in the list of properties
                  // add it if not.
                  for (int i=0; i < fields.length; i++) {
   Field f = fields[i];
   -                    // skip field if it is final, transient, or static
   +                    // skip field if it is final, transient, or static
   if (!(Modifier.isStatic(f.getModifiers()) ||
   -                          Modifier.isFinal(f.getModifiers()) ||
   -                          Modifier.isTransient(f.getModifiers()))) {
   +                            Modifier.isFinal(f.getModifiers()) ||
   +                            Modifier.isTransient(f.getModifiers()))) {
                           String fName = f.getName();
                           boolean found = false;
   -                        for (int j=0; j<pd.size() && !found; j++) {
   -                            String pName =
   -                                ((BeanPropertyDescriptor)pd.get(j)).
   getName();
   +                        for (int j=0; j< rawPd.length && !found; j++) {
   +                            String pName =
   +                                    ((BeanPropertyDescriptor)pd.
   get(j)).getName();
   if (pName.length() == fName.length() &&
   -                                pName.substring(0,1).equalsIgnoreCase(
   -                                    fName.substring(0,1))) {
   +                                    pName.substring(0,1).
   equalsIgnoreCase(
   +                                            fName.substring(0,1))) {
                                    found = pName.length() == 1  ||
                                    pName.substring(1).equals(fName.
                                    substring(1));
                           }
                           }
   +
   if (!found) {
   -                            pd.add(new BeanPropertyDescriptor(f.
   getName(), f));
   +                            pd.add(new FieldPropertyDescriptor(f.
   getName(), f));
                        }
                        }
               }
               }
   // If typeDesc meta data exists, re-order according to the fields
   -            if (typeDesc != null &&
   -                typeDesc.getFields() != null) {
   +            if (typeDesc != null &&
   +                    typeDesc.getFields() != null) {
                  ArrayList ordered = new ArrayList();
                  // Add the TypeDesc elements first
                  FieldDesc[] fds = typeDesc.getFields();
   @@ -353,11 +241,11 @@
   FieldDesc field = fds[i];
   if (field.isElement()) {
   boolean found = false;
   -                        for (int j=0;
   -                             j<pd.size() && !found;
   +                        for (int j=0;
   +                             j<pd.size() && !found;
                              j++) {
                              if (field.getFieldName().equals(
   -                               ((BeanPropertyDescriptor)pd.get(j)).
   getName())) {
   +                                    ((BeanPropertyDescriptor)pd.
   get(j)).getName())) {
                                    ordered.add(pd.remove(j));
                                    found = true;
   }
   @@ -377,30 +265,11 @@
               myPd[i] = (BeanPropertyDescriptor) pd.get(i);
               }
   } catch (Exception e) {
   -            log.error(JavaUtils.getMessage("badPropertyDesc00", cls.
   getName()), e);
   +            log.error(JavaUtils.getMessage("badPropertyDesc00",
   +                                           cls.getName()), e);
            throw new InternalException(e);
            }
   -        return myPd;
   -    }

   -    /**
   -     * Given a read Method (i.e. is or get Method)
   -     * returns the name of the property.
   -     */
   -    private static String getPropNameFromReadMethod(Method method) {
   -        String name = method.getName();
   -        if (name.startsWith("is")) {
   -            name = name.substring(2);
   -        } else {
   -            name = name.substring(3);
   -        }
   -        if (name.length() == 0) {
   -            return null;
   -        } else if (name.length() == 1) {
   -            return Character.toLowerCase(name.charAt(0)) + "";
   -        } else {
   -            return Character.toLowerCase(name.charAt(0)) + name.
   substring(1);
   -        }
   -
   +        return myPd;
   }
   }



   1.1                  xml-
   axis/java/src/org/apache/axis/utils/FieldPropertyDescriptor.java

   Index: FieldPropertyDescriptor.java
   ===================================================================
   /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 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 org.apache.axis.utils;

   import java.lang.reflect.Field;
   import java.lang.reflect.InvocationTargetException;
   import java.lang.reflect.Array;
   import java.beans.PropertyDescriptor;

   /**
   *
   * @author Glen Daniels (gdaniels@apache.org)
   */
   public class FieldPropertyDescriptor extends BeanPropertyDescriptor {
   private Field field = null;
      /**
      * Construct a BPD with a field
      * Both must be set
      * @param _name is the name of the property
         * @param _field is the name of the public instance field
         */
      public FieldPropertyDescriptor(String _name,
      Field _field) {
            field = _field;
            try {
            myPD = new PropertyDescriptor(_name, null, null);
            } catch (Exception e) {
            // ???
            }
            if (_field == null || _name == null) {
               throw new IllegalArgumentException(
               JavaUtils.getMessage(_field == null ?
            "badField00" : "badProp03"));
            }
      }

      public String getName() {
      return field.getName();
      }

      /**
      * Query if property is readable
      * @return true if readable
      */
      public boolean isReadable() {
      return true;
      }

      /**
      * Query if property is writeable
      * @return true if writeable
      */
      public boolean isWriteable() {
      return true;
      }

      /**
      * Query if property is indexed.
      * Indexed properties require valid setters/getters
      * @return true if indexed methods exist
      */
      public boolean isIndexed() {
      return (field.getType().getComponentType() != null);
      }

      /**
      * Get the property value
      * @param obj is the object
      * @return the entire propery value
      */
      public Object get(Object obj)
      throws InvocationTargetException, IllegalAccessException {
      return field.get(obj);
      }

      /**
      * Set the property value
      * @param obj is the object
      * @param newValue is the new value
      */
      public void set(Object obj, Object newValue)
      throws InvocationTargetException, IllegalAccessException {
      field.set(obj, newValue);
      }

      /**
      * Get an indexed property
      * @param obj is the object
      * @param i the index
      * @return the object at the indicated index
      */
      public Object get(Object obj, int i)
      throws InvocationTargetException, IllegalAccessException {
         if (!isIndexed()) {
         throw new IllegalAccessException("Not an indexed property");
         }

         Object array = field.get(obj);
         return Array.get(array, i);
      }

      /**
      * Set an indexed property value
      * @param obj is the object
      * @param i the index
      * @param newValue is the new value
      */
      public void set(Object obj, int i, Object newValue)
      throws InvocationTargetException, IllegalAccessException {
         if (!isIndexed()) {
         throw new IllegalAccessException("Not an indexed field!");
         }
         Class componentType = field.getType().getComponentType();
         growArrayToSize(obj, componentType, i);
         Array.set(get(obj), i, newValue);
      }

      /**
      * Get the type of a property
      * @return the type of the property
      */
      public Class getType() {
      if (isIndexed()) {
         return field.getType().getComponentType();
         } else {
         return field.getType();
         }
   }
   }



   1.119     +3 -26     xml-axis/java/test/wsdl/Wsdl2javaTestSuite.xml

   Index: Wsdl2javaTestSuite.xml
   ===================================================================
   RCS file: /home/cvs/xml-axis/java/test/wsdl/Wsdl2javaTestSuite.xml,v
   retrieving revision 1.118
   retrieving revision 1.119
   diff -u -r1.118 -r1.119
   --- Wsdl2javaTestSuite.xml 26 Jul 2002 15:48:28 -0000    1.118
   +++ Wsdl2javaTestSuite.xml 30 Jul 2002 06:16:04 -0000    1.119
   @@ -263,8 +263,7 @@
      <wsdl2java url="test/wsdl/sequence/SequenceTest.wsdl"
      output="build/work"
      deployscope="session"
   -               serverSide="yes"
   -               skeletonDeploy="yes"
   +               serverSide="no"
                  noimports="no"
                  verbose="no"
                  testcase="no">
   @@ -273,37 +272,15 @@
   <!-- Copy modified files to work directory -->
   <copy todir="${build.dir}/work/test/wsdl/sequence" overwrite="yes">
   <fileset dir="${test.dir}/wsdl/sequence">
   -        <include name="SequenceInfo.java"/>
   +        <include name="SequenceService.java"/>
   +        <include name="deploy.wsdd"/>
      </fileset>
      </copy>
      <!-- Compile Java -->
      <javac srcdir="${build.dir}/work" destdir="${build.dest}"
      debug="${debug}">
         <classpath refid="test-classpath" />
         <include name="test/wsdl/sequence/**.java" />
   -      <exclude name="test/wsdl/sequence/*TestCase.java" />
   -      <exclude name="test/wsdl/sequence/*Impl.java" />
   </javac>
   -    <!-- Now create a WSDL file from the Java classes -->
   -    <java2wsdl output="build/work/test/wsdl/sequence/SequenceTest.wsdl"
   -               className= "test.wsdl.sequence.SequenceTestPortType"
   -               implClass= "test.wsdl.sequence.
   SequenceTestSoapBindingSkeleton"
   -               namespace="urn:SequenceTest2"
   -               location="http://localhost:
   8080/axis/services/SequenceTest">
   -        <mapping namespace="urn:SequenceTest2" package="test.wsdl.
   sequence"/>
   -    </java2wsdl>
   -    <!-- Delete the intermediate files so we recreate over a clean
   slate -->
   -    <delete dir="${build.dir}/classes/test/wsdl/sequence"/>
   -    <!-- Recreate Java files from the new WSDL -->
   -    <wsdl2java url="build/work/test/wsdl/sequence/SequenceTest.wsdl"
   -               output="build/work"
   -               deployscope="session"
   -               serverSide="yes"
   -               skeletonDeploy="yes"
   -               noimports="no"
   -               verbose="no"
   -               testcase="no">
   -        <mapping namespace="urn:SequenceTest2" package="test.wsdl.
   sequence"/>
   -    </wsdl2java>
      <!-- ArrayTest Test -->
      <wsdl2java url="test/wsdl/arrays/ArrayTest.wsdl"


   1.9       +36 -60    xml-
   axis/java/test/wsdl/arrays/PersonalInfoBookServiceTestCase.java

   Index: PersonalInfoBookServiceTestCase.java
   ===================================================================
   RCS file: /home/cvs/xml-
   axis/java/test/wsdl/arrays/PersonalInfoBookServiceTestCase.java,v
   retrieving revision 1.8
   retrieving revision 1.9
   diff -u -r1.8 -r1.9
   --- PersonalInfoBookServiceTestCase.java     30 May 2002 23:46:03 -0000
   1.8
   +++ PersonalInfoBookServiceTestCase.java     30 Jul 2002 06:16:04 -0000
   1.9
   @@ -16,7 +16,7 @@



   -    public void testPersonalInfoBook() {
   +    public void testPersonalInfoBook() throws Exception {
            // Set up some testcase values
            String name = "Joe Geek";
   @@ -43,71 +43,47 @@

            // Get the stub and set Session
            test.wsdl.arrays.PersonalInfoBook binding;
   -        try {
   -            binding = new PersonalInfoBookServiceLocator().
   getPersonalInfoBook();
   -        }
   -        catch (javax.xml.rpc.ServiceException jre) {
   -            throw new junit.framework.AssertionFailedError("JAX-RPC
   ServiceException caught: " + jre );
   -        }
   +        binding = new PersonalInfoBookServiceLocator().
   getPersonalInfoBook();
            assertTrue("binding is null", binding != null);
            ((PersonalInfoBookSOAPBindingStub) binding).setMaintainSession
            (true);
   // Add the name and personal info for Joe Geek
   -        try {
   -            binding.addEntry(name, pi);
   -        } catch (java.rmi.RemoteException re) {
   -            throw new junit.framework.AssertionFailedError("Remote
   Exception caught: " + re );
   -        }
   +        binding.addEntry(name, pi);

   // Now get the personal info and check validity
   -        try {
   -            test.wsdl.arrays.PersonalInfo value = null;
   -            value = binding.getPersonalInfoFromName(name);
   -            assertTrue("Name is corrupted " + value,
   -                       value.getName().equals(pi.getName()));
   -            assertTrue("Movies are corrupted " + value,
   -                       value.getFavoriteMovies()[1].equals(pi.
   getFavoriteMovies()[1]));
   -            assertTrue("Hobbies are corrupted " + value,
   -                       value.getHobbies()[1].equals(pi.getHobbies()
   [1]));
   -            assertTrue("Pets are corrupted " + value,
   -                       value.getPets().elementAt(1).equals(pi.
   getPets().elementAt(1)));
   -            assertTrue("Id is corrupted " + value,
   -                       value.getId()[0] == 0 && value.getId()[1] == 0
   && value.getId()[2] == 7);
   -            assertTrue("Id2 is corrupted " + value,
   -                       value.getId2() == pi.getId2());
   -            assertTrue("Food are corrupted " + value,
   -                       value.getFoods(1).equals(pi.getFoods(1)));
   -            assertTrue("Nickname is corrupted " + value,
   -                       value.getNickName()[1] == pi.getNickName()[1]);
   -
   -        } catch (java.rmi.RemoteException re) {
   -            throw new junit.framework.AssertionFailedError("Remote
   Exception caught: " + re );
   -        }
   -
   -        try {
   -            Vector value = null;
   -            value = binding.getPetsFromName(name);
   -            assertTrue("PetsFromName is broken " + value,
   -                       value.elementAt(1).equals(pi.getPets().
   elementAt(1)));
   -        } catch (java.rmi.RemoteException re) {
   -            throw new junit.framework.AssertionFailedError("Remote
   Exception caught: " + re );
   -        }
   -        try {
   -            int[] value = null;
   -            value = binding.getIDFromName(name);
   -            assertTrue("getIDFromName is brokent " + value,
   -                       value[0] == 0 && value[1] == 0 && value[2] ==
   7);
   -        } catch (java.rmi.RemoteException re) {
   -            throw new junit.framework.AssertionFailedError("Remote
   Exception caught: " + re );
   -        }
   -        try {
   -            int value = -3;
   -            value = binding.getID2FromName(name);
   -            assertTrue("getID2FromName is brokent " + value,
   -                       value == pi.getId2());
   -        } catch (java.rmi.RemoteException re) {
   -            throw new junit.framework.AssertionFailedError("Remote
   Exception caught: " + re );
   -        }
   +        test.wsdl.arrays.PersonalInfo value = null;
   +        value = binding.getPersonalInfoFromName(name);
   +        assertTrue("Name is corrupted " + value,
   +                   value.getName().equals(pi.getName()));
   +        assertTrue("Movies are corrupted " + value,
   +                   value.getFavoriteMovies()[1].equals(pi.
   getFavoriteMovies()[1]));
   +        assertTrue("Hobbies are corrupted " + value,
   +                   value.getHobbies()[1].equals(pi.getHobbies()[1]));
   +        assertTrue("Pets are corrupted " + value,
   +                   value.getPets().elementAt(1).equals(pi.getPets().
   elementAt(1)));
   +        assertTrue("Id is corrupted " + value,
   +                   value.getId()[0] == 0 && value.getId()[1] == 0 &&
   value.getId()[2] == 7);
   +        assertTrue("Id2 is corrupted " + value,
   +                   value.getId2() == pi.getId2());
   +        assertTrue("Food are corrupted " + value,
   +                   value.getFoods(1).equals(pi.getFoods(1)));
   +        assertTrue("Nickname is corrupted " + value,
   +                   value.getNickName()[1] == pi.getNickName()[1]);
   +
   +        Vector value2 = null;
   +        value2 = binding.getPetsFromName(name);
   +        assertTrue("PetsFromName is broken " + value2,
   +                   value2.elementAt(1).equals(pi.getPets().
   elementAt(1)));
   +
   +        int[] value3 = null;
   +        value3 = binding.getIDFromName(name);
   +        assertTrue("getIDFromName is brokent " + value3,
   +                   value3[0] == 0 && value3[1] == 0 && value3[2] == 7);
   +
   +        int value4 = -3;
   +        value4 = binding.getID2FromName(name);
   +        assertTrue("getID2FromName is brokent " + value4,
   +                   value4 == pi.getId2());
   }
   }




   1.4       +2 -4      xml-axis/java/test/wsdl/sequence/SequenceTest.wsdl

   Index: SequenceTest.wsdl
   ===================================================================
   RCS file: /home/cvs/xml-axis/java/test/wsdl/sequence/SequenceTest.wsdl,v
   retrieving revision 1.3
   retrieving revision 1.4
   diff -u -r1.3 -r1.4
   --- SequenceTest.wsdl      31 May 2002 19:08:12 -0000    1.3
   +++ SequenceTest.wsdl      30 Jul 2002 06:16:04 -0000    1.4
   @@ -4,7 +4,7 @@
               targetNamespace="urn:SequenceTest2"
               xmlns:tns="urn:SequenceTest2"
               xmlns:typens="urn:SequenceTest2"
   -             xmlns:xsd="http://www.w3.org/1999/XMLSchema"
   +             xmlns:xsd="http://www.w3.org/2001/XMLSchema"
               xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
               xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
               xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
   @@ -15,8 +15,6 @@
   <xsd:schema targetNamespace="urn:SequenceTest2"
                  xmlns:xsd="http://www.w3.org/1999/XMLSchema">

   -
   -
         <xsd:complexType name="sequenceInfo">
         <xsd:sequence>
   <xsd:element name="zero"  type="xsd:int"/>
   @@ -36,7 +34,7 @@
      </message>

   <message name="testSequenceResponse">
   -    <part name="rc" type="soapenc:int"/>
   +    <part name="return" type="xsd:boolean"/>
      </message>

      <!-- port type declns -->


   1.5       +6 -16     xml-
   axis/java/test/wsdl/sequence/SequenceTestServiceTestCase.java

   Index: SequenceTestServiceTestCase.java
   ===================================================================
   RCS file: /home/cvs/xml-
   axis/java/test/wsdl/sequence/SequenceTestServiceTestCase.java,v
   retrieving revision 1.4
   retrieving revision 1.5
   diff -u -r1.4 -r1.5
   --- SequenceTestServiceTestCase.java   5 Feb 2002 16:22:40 -0000     1.4
   +++ SequenceTestServiceTestCase.java   30 Jul 2002 06:16:04 -0000    1.5
   @@ -1,7 +1,8 @@
   /**
   * SequenceTestServiceTestCase.java
   *
   - * @author: Rich Scheuerle (scheu@us.ibm.com)
   + * @author Rich Scheuerle (scheu@us.ibm.com)
   + * @author Glen Daniels (gdaniels@apache.org)
   */

   package test.wsdl.sequence;
   @@ -11,23 +12,12 @@
      super(name);
      }
   -    public void testSequenceTest() {
   +    public void testSequenceTest() throws Exception {
   test.wsdl.sequence.SequenceTestPortType binding;
   -        try {
   -            binding = new SequenceTestLocator().getSequenceTest();
   -        }
   -        catch (javax.xml.rpc.ServiceException jre) {
   -            throw new junit.framework.AssertionFailedError("JAX-RPC
   ServiceException caught: " + jre );
   -        }
   +        binding = new SequenceTestLocator().getSequenceTest();
   assertTrue("binding is null", binding != null);
   -        try {
   -            Integer value = null;
   -            value = binding.testSequence(new test.wsdl.sequence.
   SequenceInfo());
   -            assertTrue("Test Sequence Failed="+value,
   (value != null));
   -            assertTrue("Test Sequence Failed="+value.intValue() ,
   (value.intValue() == 0));
   -        } catch (java.rmi.RemoteException re) {
   -            throw new junit.framework.AssertionFailedError("Remote
   Exception caught: " + re );
   -        }
   +        assertTrue("Test failed!",
   +                   binding.testSequence(new test.wsdl.sequence.
   SequenceInfo()));
   }
   }




   1.2       +0 -29     xml-axis/java/test/wsdl/sequence/buildComponent.xml

   Index: buildComponent.xml
   ===================================================================
   RCS file: /home/cvs/xml-axis/java/test/wsdl/sequence/buildComponent.xml,
   v
   retrieving revision 1.1
   retrieving revision 1.2
   diff -u -r1.1 -r1.2
   --- buildComponent.xml     22 Jul 2002 20:14:25 -0000    1.1
   +++ buildComponent.xml     30 Jul 2002 06:16:04 -0000    1.2
   @@ -34,40 +34,11 @@
            testcase="no">
            <mapping namespace="urn:SequenceTest2" package="test.wsdl.
            sequence"/>
   </wsdl2java>
   -    <!-- Copy modified files to work directory -->
   -    <copy todir="${build.dir}/work/test/wsdl/sequence" overwrite="yes">
   -      <fileset dir="${test.dir}/wsdl/sequence">
   -        <include name="SequenceInfo.java"/>
   -      </fileset>
   -    </copy>
      <!-- Compile Java -->
      <javac srcdir="${build.dir}/work" destdir="${build.dest}"
      debug="${debug}">
         <classpath refid="classpath" />
         <include name="test/wsdl/sequence/**.java" />
   -      <exclude name="test/wsdl/sequence/*TestCase.java" />
   -      <exclude name="test/wsdl/sequence/*Impl.java" />
   </javac>
   -    <!-- Now create a WSDL file from the Java classes -->
   -    <java2wsdl output="build/work/test/wsdl/sequence/SequenceTest.wsdl"
   -               className= "test.wsdl.sequence.SequenceTestPortType"
   -               implClass= "test.wsdl.sequence.
   SequenceTestSoapBindingSkeleton"
   -               namespace="urn:SequenceTest2"
   -               location="http://localhost:
   8080/axis/services/SequenceTest">
   -        <mapping namespace="urn:SequenceTest2" package="test.wsdl.
   sequence"/>
   -    </java2wsdl>
   -    <!-- Delete the intermediate files so we recreate over a clean
   slate -->
   -    <delete dir="${build.dir}/classes/test/wsdl/sequence"/>
   -    <!-- Recreate Java files from the new WSDL -->
   -    <wsdl2java url="build/work/test/wsdl/sequence/SequenceTest.wsdl"
   -               output="build/work"
   -               deployscope="session"
   -               serverSide="yes"
   -               skeletonDeploy="yes"
   -               noimports="no"
   -               verbose="no"
   -               testcase="no">
   -        <mapping namespace="urn:SequenceTest2" package="test.wsdl.
   sequence"/>
   -    </wsdl2java>
   </target>

   <target name="deploy"/>



   1.1                  xml-axis/java/test/wsdl/sequence/SequenceService.
   java

   Index: SequenceService.java
   ===================================================================
   /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 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.wsdl.sequence;

   import org.w3c.dom.Element;
   import org.w3c.dom.NodeList;
   import org.w3c.dom.Node;
   import org.w3c.dom.Document;
   import org.w3c.dom.Text;
   import org.apache.axis.utils.XMLUtils;

   import java.util.Vector;

   /**
   * Sequence test service.  This is a custom built message-style service
   * which confirms that
   *
   * @author Glen Daniels (gdaniels@apache.org)
   */
   public class SequenceService {
   private String [] names = new String [] { "zero",
                                                "one",
                                                "two",
                                                "three",
                                                "four",
                                                "five" };
      /**
      * This is a message-style service because we're just testing the
      * serialization.
      *
      * @return
      */
      public Element [] testSequence(Vector elems) {
      Element zero = null;
      for (int i = 0; i < elems.size(); i++) {
               zero = findTheZero((Element)elems.get(i));
               if (zero != null)
         break;
         }

         Document retDoc = XMLUtils.newDocument();
         Element [] ret = new Element [1];
         ret[0] = retDoc.createElementNS("urn:SequenceTest",
         "testSequenceResponse");
         boolean success = false;

         Element resultElement;

         if (zero != null) {
         // Check for correct ordering
         int i = 1;
         Node sib = zero.getNextSibling();
         for (i = 1; i < names.length; i++) {
                  while ((sib != null) && !(sib instanceof Element))
                  sib = sib.getNextSibling();

                  if ((sib == null) ||
                  !(names[i].equals(((Element)sib).getLocalName())))
                     break;

               sib = sib.getNextSibling();
               }
               if (i == names.length)
         success = true;
         }

         resultElement = retDoc.createElement("return");

         String resultStr = "false";
         if (success) {
         resultStr = "true";
         }
         Text text = retDoc.createTextNode(resultStr);
         resultElement.appendChild(text);

         ret[0].appendChild(resultElement);
         return ret;
      }

      /**
      * Walk an XML tree, looking for a <zero> element
      * @param start
      * @return
      */
      private Element findTheZero(Element start) {
      if (names[0].equals(start.getLocalName())) {
         return start;
         }
         NodeList nl = start.getChildNodes();
         for (int i = 0; i < nl.getLength(); i++) {
               Node node = nl.item(i);
               if (node instanceof Element) {
                  Element result = findTheZero((Element)node);
                  if (result != null) {
                  return result;
                  }
         }
         }
         return null;
   }
   }



   1.1                  xml-axis/java/test/wsdl/sequence/deploy.wsdd

   Index: deploy.wsdd
   ===================================================================
   <!-- Deployment for sequence test, built manually because the test -->
   <!-- implementation just deals with raw XML                        -->

   <deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http:
   //xml.apache.org/axis/wsdd/providers/java">
   <service name="SequenceTest" style="message">
         <parameter name="className" value="test.wsdl.sequence.
         SequenceService"/>
         <parameter name="allowedMethods" value="testSequence"/>
   </service>
   </deployment>


   1.1                  xml-axis/java/test/wsdl/sequence/readme.txt

   Index: readme.txt
   ===================================================================
   This test confirms that the WSDL2Java / serialization system does the
   right
   thing with <sequence> ordering of XML elements (which map to bean
   fields).

   In the WSDL file, we have a type with six ordered elements.  We build
   this
   into a bean, then use the generated client + bean to call a test
   service.

   The service is NOT generated, but a custom built message-style service
   which
   simply confirms the XML looks right by walking the DOM tree until it
   finds
   the <zero> element, then checking the siblings look right.  It returns a
   boolean true/false which indicates if the run was successful.

   --Glen Daniels
   July 30, 2002




Mime
View raw message