axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject cvs commit: xml-axis/java/test/wsdl/marrays MArrayTest.wsdl MArrayTestsSOAPBindingImpl.java MArrayTestsServiceTestCase.java
Date Mon, 11 Feb 2002 19:02:54 GMT
scheu       02/02/11 11:02:54

  Modified:    java/src/org/apache/axis/encoding
                        DefaultTypeMappingImpl.java
               java/src/org/apache/axis/encoding/ser ArrayDeserializer.java
               java/src/org/apache/axis/utils JavaUtils.java
               java/test/encoding TestDeser.java
               java/test/wsdl/marrays MArrayTest.wsdl
                        MArrayTestsSOAPBindingImpl.java
                        MArrayTestsServiceTestCase.java
  Log:
  The following changes are made to support
  the automatic conversion of deserialized arrays
  into the expected array object.
  
  1) In the Array Deserializer, the JavaUtils:convert
  method is now invoked during valueComplete() to
  convert the array class into an appropriate array object.
  (Additional changes were made to the deserializer
  to find the the appropriate array class.  Changes
  were also made to reduce the lines to less than 80 chars.)
  
  2) JavaUtils:convert(arg, destClass) was written
  to assume that the arg object is a List (not an array).
  Changes are made to support arg objects that are arrays.
  Thus the new (more robust) code can now convert:
     arrays -> other arrays
     arrays -> classes that implement List
  
  3) The runtime now returns arrays instead of ArrayList
  objects.  I needed to make minor changes to some of the
  tests to automatically convert to the expected ArrayList
  or Vector objects.
  
  4) Added a test to marrays that tests an echo of a
  HashMap with a value which is an array.
  
  I tested the code with ant all-tests and ran
  Sam's interop tests.
  
  Revision  Changes    Path
  1.9       +0 -1      xml-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java
  
  Index: DefaultTypeMappingImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DefaultTypeMappingImpl.java	8 Feb 2002 23:18:53 -0000	1.8
  +++ DefaultTypeMappingImpl.java	11 Feb 2002 19:02:53 -0000	1.9
  @@ -196,7 +196,6 @@
                      new Base64DeserializerFactory(byte[].class,
                                              Constants.XSD_BASE64),true);
   
  -
           // If SOAP 1.1 over the wire, map wrapper classes to XSD primitives.
           myRegister(Constants.XSD_STRING,     java.lang.String.class, 
                      null, null, true); 
  
  
  
  1.5       +133 -64   xml-axis/java/src/org/apache/axis/encoding/ser/ArrayDeserializer.java
  
  Index: ArrayDeserializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/ArrayDeserializer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ArrayDeserializer.java	8 Feb 2002 23:14:44 -0000	1.4
  +++ ArrayDeserializer.java	11 Feb 2002 19:02:53 -0000	1.5
  @@ -96,7 +96,8 @@
    * Multi-reference stuff:
    * @author Rich Scheuerle (scheu@us.ibm.com)
    */
  -public class ArrayDeserializer extends DeserializerImpl implements Deserializer  {
  +public class ArrayDeserializer extends DeserializerImpl 
  +    implements Deserializer  {
   
       static Category category =
               Category.getInstance(ArrayDeserializer.class.getName());
  @@ -107,19 +108,19 @@
       int length;
       Class arrayClass = null;
       ArrayList mDimLength = null;  // If set, array of multi-dim lengths 
  -    ArrayList mDimFactor = null;  // If set, array of factors for multi-dim arrays
  +    ArrayList mDimFactor = null;  // If set, array of factors for multi-dim []
       HashSet waiting = new HashSet();  // List of indices waiting for completion
   
   
       /**
        * 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 & the value is not nil)
        * DeserializerImpl provides default behavior, which simply
        * involves obtaining a correct Deserializer and plugging its handler.
        * @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 attrs on the element...used to get the type
        * @param context is the DeserializationContext
        */
       public void onStartElement(String namespace, String localName,
  @@ -154,7 +155,8 @@
           // default xsi:type value is used.
   
           if (category.isDebugEnabled()) {
  -            category.debug(JavaUtils.getMessage("enter00", "ArrayDeserializer.startElement()"));
  +            category.debug(JavaUtils.getMessage(
  +               "enter00", "ArrayDeserializer.startElement()"));
           }
   
           // Get the qname for the array type=, set it to null if
  @@ -163,9 +165,9 @@
                                                           localName,
                                                           attributes);
           if (typeQName != null && 
  -            Constants.isSOAP_ENC(typeQName.getNamespaceURI()) &&
  -            typeQName.getLocalPart().equals("Array"))
  +            Constants.equals(Constants.SOAP_ARRAY, typeQName)) {
               typeQName = null;
  +        }
   
           // Now get the arrayType value 
           QName arrayTypeValue = context.getQNameFromString(
  @@ -173,20 +175,28 @@
                                            Constants.URI_CURRENT_SOAP_ENC,
                                            Constants.ATTR_ARRAY_TYPE));
   
  -        // The first part of the arrayType expression is the default item type qname.
  +        // The first part of the arrayType expression is 
  +        // the default item type qname.
           // The second part is the dimension information
           String dimString = null;
  +        QName innerQName = null;
  +        String innerDimString = "";
           if (arrayTypeValue != null) {
  -            String arrayTypeValueNamespaceURI = arrayTypeValue.getNamespaceURI();
  -            String arrayTypeValueLocalPart = arrayTypeValue.getLocalPart();
  -            int leftBracketIndex = arrayTypeValueLocalPart.lastIndexOf('[');
  -            int rightBracketIndex = arrayTypeValueLocalPart.lastIndexOf(']');
  +            String arrayTypeValueNamespaceURI = 
  +                arrayTypeValue.getNamespaceURI();
  +            String arrayTypeValueLocalPart = 
  +                arrayTypeValue.getLocalPart();
  +            int leftBracketIndex = 
  +                arrayTypeValueLocalPart.lastIndexOf('[');
  +            int rightBracketIndex = 
  +                arrayTypeValueLocalPart.lastIndexOf(']');
               if (leftBracketIndex == -1
                   || rightBracketIndex == -1
                   || rightBracketIndex < leftBracketIndex)
                   {
                       throw new IllegalArgumentException(
  -                      JavaUtils.getMessage("badArrayType00", "" + arrayTypeValue));
  +                      JavaUtils.getMessage("badArrayType00", 
  +                                           "" + arrayTypeValue));
                   }
               
               dimString = 
  @@ -197,7 +207,14 @@
               
               // If multi-dim array set to soapenc:Array
               if (arrayTypeValueLocalPart.endsWith("]")) {
  -                defaultItemType = new QName(Constants.URI_CURRENT_SOAP_ENC, "Array");
  +                defaultItemType = 
  +                    new QName(Constants.URI_CURRENT_SOAP_ENC, "Array");
  +                innerQName = new QName(
  +                    arrayTypeValueNamespaceURI,
  +                    arrayTypeValueLocalPart.substring(0,
  +                        arrayTypeValueLocalPart.indexOf("["))); 
  +                innerDimString = arrayTypeValueLocalPart.substring(
  +                    arrayTypeValueLocalPart.indexOf("["));
               } else {
                   defaultItemType = new QName(arrayTypeValueNamespaceURI,
                                               arrayTypeValueLocalPart);
  @@ -205,9 +222,10 @@
           }
   
           // If no type QName and no defaultItemType qname, use xsd:anyType
  -        if (defaultItemType == null && typeQName == null)
  -            defaultItemType = new QName(Constants.URI_CURRENT_SCHEMA_XSD, "anyType");
  -        
  +        if (defaultItemType == null && typeQName == null) {
  +            defaultItemType = 
  +                new QName(Constants.URI_CURRENT_SCHEMA_XSD, "anyType");
  +        }
           
           // Determine the class type for the array.
           arrayClass = null;
  @@ -215,19 +233,31 @@
               arrayClass = context.getTypeMapping().
                   getClassForQName(typeQName);
           } else {
  -            Class arrayItemClass = context.getTypeMapping().
  -                getClassForQName(defaultItemType);
  +            // type= information is not sufficient.
  +            // Get an array of the default item type.
  +            Class arrayItemClass = null;
  +            QName compQName = defaultItemType;
  +            String dims = "[]";
  +            // Nested array, use the innermost qname
  +            if (innerQName != null) {
  +                compQName = innerQName;
  +                dims += innerDimString;                
  +            }
  +            arrayItemClass = context.getTypeMapping().
  +                getClassForQName(compQName);
               if (arrayItemClass != null) {
                   try {
                       ClassLoader cl = 
  -                            context.getMessageContext().getClassLoader();
  +                        context.getMessageContext().getClassLoader();
                       arrayClass = Class.forName(
                         JavaUtils.getLoadableClassName(
  -                         JavaUtils.getTextClassName(arrayItemClass.getName()) + "[]"),
  -                         true, cl);   
  +                        JavaUtils.getTextClassName(arrayItemClass.getName()) +
  +                        dims),
  +                      true, cl);   
                   } catch (Exception e) {
                       throw new SAXException(
  -                       JavaUtils.getMessage("noComponent00",  "" + defaultItemType));
  +                       JavaUtils.getMessage("noComponent00",  
  +                                            "" + defaultItemType));
                   }
               }
           }
  @@ -244,21 +274,25 @@
           else {
               try
               {
  -                StringTokenizer tokenizer = new StringTokenizer(dimString, "[],");
  +                StringTokenizer tokenizer = new StringTokenizer(dimString,
  +                                                                "[],");
   
                   length = Integer.parseInt(tokenizer.nextToken());
   
                   if (tokenizer.hasMoreTokens())
                       {
                           // If the array is passed as a multi-dimensional array
  -                        // (i.e. int[2][3]) then store all of the mult-dim lengths.
  +                        // (i.e. int[2][3]) then store all of the 
  +                        // mult-dim lengths.
                           // The valueReady method uses this array to set the
                           // proper mult-dim element.
                           mDimLength = new ArrayList();
                           mDimLength.add(new Integer(length));
                           
                           while(tokenizer.hasMoreTokens()) {
  -                            mDimLength.add(new Integer(Integer.parseInt(tokenizer.nextToken())));
  +                            mDimLength.add(
  +                                new Integer(
  +                                    Integer.parseInt(tokenizer.nextToken())));
                           }
                       }
   
  @@ -295,12 +329,16 @@
                           JavaUtils.getMessage("badOffset00", offset));
               }
   
  -            curIndex = convertToIndex(offset.substring(leftBracketIndex + 1,rightBracketIndex),
  -                                      "badOffset00");
  +            curIndex = 
  +                convertToIndex(offset.substring(leftBracketIndex + 1,
  +                                                rightBracketIndex),
  +                               "badOffset00");
           }
           
           if (category.isDebugEnabled()) {
  -            category.debug(JavaUtils.getMessage("exit00", "ArrayDeserializer.startElement()"));
  +            category.debug(
  +                JavaUtils.getMessage("exit00",
  +                                     "ArrayDeserializer.startElement()"));
           }
       }
       
  @@ -324,10 +362,13 @@
           throws SAXException
       {
           if (category.isDebugEnabled()) {
  -            category.debug(JavaUtils.getMessage("enter00", "ArrayDeserializer.onStartChild()"));
  +            category.debug(
  +                JavaUtils.getMessage("enter00", 
  +                                     "ArrayDeserializer.onStartChild()"));
           }
   
  -        // If the position attribute is set, use it to update the current index
  +        // If the position attribute is set, 
  +        // use it to update the current index
           if (attributes != null) {
               String pos =
                   Constants.getValue(attributes,
  @@ -345,12 +386,14 @@
                               JavaUtils.getMessage("badPosition00", pos));
                   }
                   
  -                curIndex = convertToIndex(pos.substring(leftBracketIndex + 1,rightBracketIndex),
  -                                          "badPosition00");
  +                curIndex = 
  +                    convertToIndex(pos.substring(leftBracketIndex + 1,
  +                                                 rightBracketIndex),
  +                                   "badPosition00");
               }
   
  -            // If the xsi:nil attribute, set the value to null and return since
  -            // there is nothing to deserialize.
  +            // If the xsi:nil attribute, set the value to null 
  +            // and return since there is nothing to deserialize.
               if (context.isNil(attributes)) {
                   setValue(null, new Integer(curIndex++));
                   return null;
  @@ -388,13 +431,16 @@
   
           // Register the callback value target, and
           // keep track of this index so we know when it has been set.
  -        dSer.registerValueTarget(new DeserializerTarget(this, new Integer(curIndex)));
  +        dSer.registerValueTarget(
  +            new DeserializerTarget(this, new Integer(curIndex)));
           waiting.add(new Integer(curIndex));
   
           curIndex++;
           
           if (category.isDebugEnabled()) {
  -            category.debug(JavaUtils.getMessage("exit00", "ArrayDeserializer.onStartChild()"));
  +            category.debug(
  +                JavaUtils.getMessage("exit00", 
  +                                     "ArrayDeserializer.onStartChild()"));
           }
           return (SOAPHandler) dSer;
       }
  @@ -424,8 +470,10 @@
       public void setValue(Object value, Object hint) throws SAXException
       { 
           if (category.isDebugEnabled()) {
  -            category.debug(JavaUtils.getMessage("gotValue00", "ArrayDeserializer", "["
+ hint +
  -                               "] = " + value));
  +            category.debug(
  +                JavaUtils.getMessage("gotValue00", 
  +                                     "ArrayDeserializer", "[" + hint +
  +                                     "] = " + value));
           }
           ArrayList list = (ArrayList)this.value;
           int offset = ((Integer)hint).intValue();
  @@ -465,21 +513,30 @@
               }
           }
           // If all indices are accounted for, the array is complete.
  -        // Try converting the value (probably an ArrayListExtension)
  -        // into the expected array.
  -        // valueComplete is invoked to inform all referents that the
  -        // value of the array is ready.
           waiting.remove(hint);
           if (isEnded && waiting.size()==0) {
  -            try {
  -                if (arrayClass != null) {
  -                    value = JavaUtils.convert(value, arrayClass);
  -                }
  -            } catch (Exception e) {}
               valueComplete();
           }
       }
  -    
  +
  +    /**
  +     * When valueComplete() is invoked on the array, 
  +     * first convert the array value into the expected array.
  +     * Then call super.valueComplete() to inform referents
  +     * that the array value is ready.
  +     **/
  +    public void valueComplete() throws SAXException
  +    { 
  +        if (componentsReady()) {
  +           try {
  +                if (arrayClass != null) {
  +                    value = JavaUtils.convert(value, arrayClass);
  +                } 
  +           } catch (Exception e) {}
  +        }     
  +         super.valueComplete();
  +    }
  +
       /**
        * Converts the given string to an index.
        * Assumes the string consists of a brackets surrounding comma 
  @@ -492,15 +549,18 @@
        * @param exceptKey exception message key
        * @return index 
        */
  -    private int convertToIndex(String text, String exceptKey) throws SAXException {
  +    private int convertToIndex(String text, String exceptKey)
  +        throws SAXException {
           StringTokenizer tokenizer = new StringTokenizer(text, "[],");
           int index = 0;
           try {
               if (mDimLength == null) {
                   // Normal Case: Single dimension
                   index = Integer.parseInt(tokenizer.nextToken());
  -                if (tokenizer.hasMoreTokens())
  -                    throw new SAXException(JavaUtils.getMessage(exceptKey, text));
  +                if (tokenizer.hasMoreTokens()) {
  +                    throw new SAXException(
  +                        JavaUtils.getMessage(exceptKey, text));
  +                }
               }
               else {
                   // Multiple Dimensions: 
  @@ -510,17 +570,20 @@
                       // Problem if the number of dimensions specified exceeds
                       // the number of dimensions of arrayType
                       dim++;
  -                    if (dim >= mDimLength.size())
  -                        throw new SAXException(JavaUtils.getMessage(exceptKey, text));
  -
  +                    if (dim >= mDimLength.size()) {
  +                        throw new SAXException(
  +                            JavaUtils.getMessage(exceptKey, text));
  +                    }
                       // Get the next token and convert to integer
                       int workIndex = Integer.parseInt(tokenizer.nextToken());
   
                       // Problem if the index is out of range.                     
                       if (workIndex < 0 || 
  -                        workIndex >= ((Integer)mDimLength.get(dim)).intValue())
  -                        throw new SAXException(JavaUtils.getMessage(exceptKey, text));
  -                    
  +                        workIndex >= 
  +                            ((Integer)mDimLength.get(dim)).intValue()) {
  +                        throw new SAXException(
  +                            JavaUtils.getMessage(exceptKey, text));
  +                    }
                       work.add(new Integer(workIndex));
                   }
                   index = toSingleIndex(work); // Convert to single index
  @@ -586,7 +649,8 @@
   
           int single = 0;
           for (int i=0; i < indexArray.size(); i++) {
  -            single += ((Integer)mDimFactor.get(i)).intValue()*((Integer)indexArray.get(i)).intValue();
  +            single += ((Integer)mDimFactor.get(i)).intValue()*
  +                ((Integer)indexArray.get(i)).intValue();
           }
           return single;
       }
  @@ -598,7 +662,8 @@
        * converted array values.  This class is essential to support
        * arrays that are multi-referenced.
        **/
  -    public class ArrayListExtension extends ArrayList implements JavaUtils.ConvertCache
{
  +    public class ArrayListExtension extends ArrayList 
  +        implements JavaUtils.ConvertCache {
           private HashMap table = null;
           private Class arrayClass = null;  // The array class.
           /**
  @@ -607,20 +672,24 @@
           ArrayListExtension(Class arrayClass) {
               super();
               this.arrayClass = arrayClass;
  -            // Don't use the array class as a hint if it can't be instantiated
  +            // Don't use the array class as a hint 
  +            // if it can't be instantiated
               if (arrayClass == null ||
                   arrayClass.isInterface() ||
  -                java.lang.reflect.Modifier.isAbstract(arrayClass.getModifiers())) {
  +                java.lang.reflect.Modifier.isAbstract(
  +                    arrayClass.getModifiers())) {
                   arrayClass = null;
               }                
           }
           ArrayListExtension(Class arrayClass, int length) {
               super(length);
               this.arrayClass = arrayClass;
  -            // Don't use the array class as a hint if it can't be instantiated
  +            // Don't use the array class as a hint 
  +            // if it can't be instantiated
               if (arrayClass == null ||
                   arrayClass.isInterface() ||
  -                java.lang.reflect.Modifier.isAbstract(arrayClass.getModifiers())) {
  +                java.lang.reflect.Modifier.isAbstract(
  +                    arrayClass.getModifiers())) {
                   arrayClass = null;
               } 
           }
  
  
  
  1.28      +48 -15    xml-axis/java/src/org/apache/axis/utils/JavaUtils.java
  
  Index: JavaUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/JavaUtils.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- JavaUtils.java	8 Feb 2002 23:05:21 -0000	1.27
  +++ JavaUtils.java	11 Feb 2002 19:02:53 -0000	1.28
  @@ -113,7 +113,10 @@
               category.debug( getMessage("convert00",
                   arg.getClass().getName(), destClass.getName()));
           }
  -        
  +
  +        if (destClass == null) {
  +            return arg;
  +        }
   
           // See if a previously converted value is stored in the argument.
           Object destValue = null;
  @@ -141,7 +144,8 @@
   
   
           // Return if no conversion is available
  -        if (!(arg instanceof List) && 
  +        if (!(arg instanceof List || 
  +              (arg != null && arg.getClass().isArray())) && 
               ((destHeldType == null && argHeldType == null) ||
                (destHeldType != null && argHeldType != null))) {
               return arg;
  @@ -186,16 +190,31 @@
               }
           }
               
  -        List list = (List)arg;
  -        int length = list.size();
  -        
  +        if (arg == null) {
  +            return arg;
  +        }
  +
  +        // The arg may be an array or List
  +        int length = 0;
  +        if (arg.getClass().isArray()) {
  +            length = Array.getLength(arg);
  +        } else {
  +            length = ((List) arg).size();
  +        }
           if (destClass.isArray()) {
               if (destClass.getComponentType().isPrimitive()) {
                   
                   Object array = Array.newInstance(destClass.getComponentType(),
                                                    length);
  -                for (int i = 0; i < length; i++) {
  -                    Array.set(array, i, list.get(i));
  +                // Assign array elements
  +                if (arg.getClass().isArray()) {
  +                    for (int i = 0; i < length; i++) {
  +                        Array.set(array, i, Array.get(arg, i));
  +                    }                                
  +                } else {  
  +                    for (int i = 0; i < length; i++) {
  +                        Array.set(array, i, ((List) arg).get(i));
  +                    }
                   }
                   destValue = array;
                   
  @@ -208,10 +227,18 @@
                       return arg;
                   }
   
  -                // Use convert to assign array elements.                        
  -                for (int i=0; i < length; i++) {
  -                    array[i] = convert(list.get(i), destClass.getComponentType()); 
  -                }
  +                // Use convert to assign array elements.
  +                if (arg.getClass().isArray()) {
  +                    for (int i = 0; i < length; i++) {
  +                        array[i] = convert(Array.get(arg, i), 
  +                                           destClass.getComponentType());
  +                    }                                
  +                } else {  
  +                    for (int i = 0; i < length; i++) {
  +                        array[i] = convert(((List) arg).get(i), 
  +                                           destClass.getComponentType());
  +                    }
  +                }   
                   destValue = array;
               }
           }
  @@ -223,10 +250,16 @@
                   // Couldn't build one for some reason... so forget it.
                   return arg;
               }
  -            
  -            for (int j = 0; j < ((List)arg).size(); j++) {
  -                newList.add(list.get(j));
  -            }
  +
  +            if (arg.getClass().isArray()) {
  +                for (int j = 0; j < length; j++) {
  +                    newList.add(Array.get(arg, j));
  +                }                                
  +            } else {
  +                for (int j = 0; j < length; j++) {
  +                    newList.add(((List) arg).get(j));
  +                }                
  +            }                
               destValue = newList;
           }
           else {
  
  
  
  1.26      +5 -5      xml-axis/java/test/encoding/TestDeser.java
  
  Index: TestDeser.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/encoding/TestDeser.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- TestDeser.java	7 Feb 2002 23:23:12 -0000	1.25
  +++ TestDeser.java	11 Feb 2002 19:02:53 -0000	1.26
  @@ -244,7 +244,7 @@
                          "<item xsi:type=\"xsd:string\">abc</item>" +
                          "<item xsi:type=\"xsd:string\">def</item>" +
                       "</result>",
  -                    v);
  +                    v, true);
       }
       
       public void testSparseArray1() throws Exception {
  @@ -259,7 +259,7 @@
                          "<item xsi:type=\"xsd:string\">abc</item>" +
                          "<item xsi:type=\"xsd:string\">def</item>" +
                       "</result>",
  -                    list);
  +                    list, true);
       }
       
       public void testSparseArray2() throws Exception {
  @@ -273,7 +273,7 @@
         "<item soapenc:position=\"[0]\" xsi:type=\"xsd:string\">abc</item>" +
         "<item soapenc:position=\"[2]\" xsi:type=\"xsd:string\">def</item>" +
                       "</result>",
  -                    list);
  +                    list, true);
       }
   
       public void testArrayWithNilInt() throws Exception {
  @@ -287,7 +287,7 @@
                          "<item xsi:nil=\"true\"/>" +
                          "<item xsi:type=\"xsd:int\">3</item>" +
                       "</result>",
  -                    list);
  +                    list, true);
       }
       
       public void testArrayWithNilString() throws Exception {
  @@ -301,7 +301,7 @@
                          "<item xsi:nil=\"true\"/>" +
                          "<item xsi:type=\"xsd:string\">def</item>" +
                       "</result>",
  -                    list);
  +                    list, true);
       }
       
       public void testMap() throws Exception {
  
  
  
  1.2       +26 -0     xml-axis/java/test/wsdl/marrays/MArrayTest.wsdl
  
  Index: MArrayTest.wsdl
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/marrays/MArrayTest.wsdl,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MArrayTest.wsdl	18 Dec 2001 21:29:04 -0000	1.1
  +++ MArrayTest.wsdl	11 Feb 2002 19:02:53 -0000	1.2
  @@ -7,6 +7,7 @@
                xmlns:xsd="http://www.w3.org/1999/XMLSchema"
                xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
                xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding"
  +             xmlns:soapy="http://xml.apache.org/xml-soap"
                xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
                xmlns="http://schemas.xmlsoap.org/wsdl/">
   
  @@ -104,6 +105,14 @@
     <message name="testFooArrayResponse">
       <part name="out" type="typens:Array3F"/>
     </message>
  +
  +  <message name="testMapFooArrayRequest">
  +    <part name="in" type="soapy:Map"/>
  +  </message>
  +  <message name="testMapFooArrayResponse">
  +    <part name="out" type="soapy:Map"/>
  +  </message>
  +
     <!-- port type declns -->
     <portType name="MArrayTests">
       <operation name="testIntArray">
  @@ -114,6 +123,10 @@
         <input message="tns:testFooArrayRequest"/>
         <output message="tns:testFooArrayResponse"/>
       </operation>
  +    <operation name="testMapFooArray">
  +      <input message="tns:testMapFooArrayRequest"/>
  +      <output message="tns:testMapFooArrayResponse"/>
  +    </operation>
     </portType>
   
     <!-- binding declns -->
  @@ -134,6 +147,19 @@
         </output>
       </operation>
       <operation name="testFooArray">
  +      <soap:operation soapAction=""/>
  +      <input>
  +        <soap:body use="encoded"
  +                   namespace="urn:MArrayTests"
  +                   encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  +      </input>
  +      <output>
  +        <soap:body use="encoded"
  +                   namespace="urn:MArrayTests"
  +                   encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  +      </output>
  +    </operation>
  +    <operation name="testMapFooArray">
         <soap:operation soapAction=""/>
         <input>
           <soap:body use="encoded"
  
  
  
  1.2       +4 -0      xml-axis/java/test/wsdl/marrays/MArrayTestsSOAPBindingImpl.java
  
  Index: MArrayTestsSOAPBindingImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/marrays/MArrayTestsSOAPBindingImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MArrayTestsSOAPBindingImpl.java	18 Dec 2001 21:29:04 -0000	1.1
  +++ MArrayTestsSOAPBindingImpl.java	11 Feb 2002 19:02:53 -0000	1.2
  @@ -42,4 +42,8 @@
           }
           return in;
       }
  +    public java.util.HashMap testMapFooArray(java.util.HashMap map)
  +        throws java.rmi.RemoteException {
  +        return map;
  +    }
   }
  
  
  
  1.5       +22 -0     xml-axis/java/test/wsdl/marrays/MArrayTestsServiceTestCase.java
  
  Index: MArrayTestsServiceTestCase.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/marrays/MArrayTestsServiceTestCase.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MArrayTestsServiceTestCase.java	5 Feb 2002 16:22:40 -0000	1.4
  +++ MArrayTestsServiceTestCase.java	11 Feb 2002 19:02:53 -0000	1.5
  @@ -7,6 +7,9 @@
   
   package test.wsdl.marrays;
   
  +import java.util.HashMap;
  +import java.util.Map;
  +
   public class MArrayTestsServiceTestCase extends junit.framework.TestCase {
       public MArrayTestsServiceTestCase(String name) {
           super(name);
  @@ -125,6 +128,25 @@
               throw new junit.framework.AssertionFailedError("Remote Exception caught: "
+ re );
           }
           */
  +
  +        try {
  +            // Test 3F: Some of the Foo elements are multi-referenced.   
  +            HashMap map = new HashMap();
  +            Foo[] array = new Foo[1];
  +            array[0] = new Foo();
  +            array[0].setValue(123);
  +            map.put("hello", array);
  +            
  +            HashMap rc;
  +
  +            rc = binding.testMapFooArray(map);
  +            assertTrue("Test Map Failed (a)", rc != null);
  +            assertTrue("Test Map Failed (b)", rc.get("hello").getClass().isArray());
  +            Foo[] rcArray = (Foo[]) rc.get("hello");
  +            assertTrue("Test Map Failed (c)", rcArray.length == 1 && rcArray[0].getValue()
== 123);
  +        } catch (java.rmi.RemoteException re) {
  +            throw new junit.framework.AssertionFailedError("Remote Exception caught: "
+ re );
  +        }
       }
   
       public void fill(int[][][] array) {
  
  
  

Mime
View raw message