axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject cvs commit: xml-axis/java/test/functional TestMessageSample.java
Date Fri, 13 Dec 2002 20:38:05 GMT
gdaniels    2002/12/13 12:38:04

  Modified:    java/src/org/apache/axis/description OperationDesc.java
               java/src/org/apache/axis/encoding
                        SerializationContextImpl.java
               java/src/org/apache/axis/message RPCParam.java
               java/src/org/apache/axis/utils JavaUtils.java
               java/test/functional TestMessageSample.java
  Log:
  * Fix bug:
  
    http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15328
  
    Correctly push()/pop() when registering namespaces in
    SerializationContextImpl.  This should now really be fixed?
  
  * Invert expected + actual args in Message test (grrrr), and reset
    expected string since we are incrementing the ns index
  
  * When checking for polymorphic types in RPCParam, ignore the
    Holder/Held relationship - i.e. don't force xsi:type for
    this case
  
  * Fix getOutputParamByQName() in OperationDesc to scan past any
    non-output params with the desired QName.  This problem was
    brought to light by the wrapped_holders test once the xsi:
    type problem above was fixed
  
  * Tiny speedup in JavaUtils.getHolderValueType()
  
  Revision  Changes    Path
  1.29      +11 -12    xml-axis/java/src/org/apache/axis/description/OperationDesc.java
  
  Index: OperationDesc.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/description/OperationDesc.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- OperationDesc.java	11 Dec 2002 22:38:13 -0000	1.28
  +++ OperationDesc.java	13 Dec 2002 20:38:03 -0000	1.29
  @@ -359,20 +359,19 @@
       {
           ParameterDesc param = null;
   
  -        param = getParamByQName(qname);
  -
  -        if (param != null && param.getMode() == ParameterDesc.IN) {
  -            param = null;
  +        for (Iterator i = parameters.iterator(); i.hasNext();) {
  +            param = (ParameterDesc) i.next();
  +            if (param.getQName().equals(qname) &&
  +                    param.getMode() != ParameterDesc.IN)
  +                return param;
           }
   
  -        if ((param == null) || (param.getMode() == ParameterDesc.IN)) {
  -            if (null == returnDesc.getQName() ){
  -                param= new ParameterDesc( returnDesc); //Create copy
  -                param.setQName(qname);
  -            }
  -            else if ( qname.equals(returnDesc.getQName())) {
  -                param = returnDesc;
  -            }
  +        if (null == returnDesc.getQName() ){
  +            param= new ParameterDesc( returnDesc); //Create copy
  +            param.setQName(qname);
  +        }
  +        else if ( qname.equals(returnDesc.getQName())) {
  +            param = returnDesc;
           }
   
           return param;
  
  
  
  1.86      +47 -37    xml-axis/java/src/org/apache/axis/encoding/SerializationContextImpl.java
  
  Index: SerializationContextImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/SerializationContextImpl.java,v
  retrieving revision 1.85
  retrieving revision 1.86
  diff -u -r1.85 -r1.86
  --- SerializationContextImpl.java	11 Dec 2002 22:38:14 -0000	1.85
  +++ SerializationContextImpl.java	13 Dec 2002 20:38:04 -0000	1.86
  @@ -160,6 +160,7 @@
        */
       private HashMap multiRefValues = null;
       private int multiRefIndex = -1;
  +    private boolean noNamespaceMappings = true;
   
       class MultiRefItem {
           String id;
  @@ -425,6 +426,10 @@
           }
   
           if ((uri != null) && (prefix != null)) {
  +            if (noNamespaceMappings) {
  +                nsStack.push();
  +                noNamespaceMappings = false;
  +            }
               nsStack.add(uri, prefix);
           }
       }
  @@ -810,7 +815,7 @@
                              "CDATA",
                              encodingStyle);
   
  -        // Make a copy of the keySet because it could be updated 
  +        // Make a copy of the keySet because it could be updated
           // during processing
           HashSet keys = new HashSet();
           keys.addAll(multiRefValues.keySet());
  @@ -926,25 +931,30 @@
               }
           }
   
  -        for (Mapping map=nsStack.topOfFrame(); map!=null; map=nsStack.next()) {
  -            StringBuffer sb = new StringBuffer("xmlns");
  -            if (map.getPrefix().length() > 0) {
  -                sb.append(':');
  -                sb.append(map.getPrefix());
  -            }
  -            if ((vecQNames==null) || (vecQNames.indexOf(sb.toString())==-1)) {
  -                writer.write(' ');
  -                sb.append("=\"");
  -                sb.append(map.getNamespaceURI());
  -                sb.append('"');
  -                writer.write(sb.toString());
  +        if (noNamespaceMappings) {
  +            nsStack.push();
  +        } else {
  +            for (Mapping map=nsStack.topOfFrame(); map!=null; map=nsStack.next()) {
  +                StringBuffer sb = new StringBuffer("xmlns");
  +                if (map.getPrefix().length() > 0) {
  +                    sb.append(':');
  +                    sb.append(map.getPrefix());
  +                }
  +                if ((vecQNames==null) || (vecQNames.indexOf(sb.toString())==-1)) {
  +                    writer.write(' ');
  +                    sb.append("=\"");
  +                    sb.append(map.getNamespaceURI());
  +                    sb.append('"');
  +                    writer.write(sb.toString());
  +                }
               }
  +
  +            noNamespaceMappings = true;
           }
   
           writingStartTag = true;
   
           elementStack.push(elementQName);
  -        nsStack.push();
   
           onlyXML=true;
       }
  @@ -1167,7 +1177,7 @@
               }
   
               // Set currentXMLType to the one desired one.
  -            // Note for maxOccurs usage this xmlType is the 
  +            // Note for maxOccurs usage this xmlType is the
               // type of the component not the type of the array.
               currentXMLType = xmlType;
   
  @@ -1179,17 +1189,17 @@
   
               // Try getting a serializer for the prefered xmlType
               QNameHolder actualXMLType = new QNameHolder();
  -            Serializer ser = getSerializer(javaType, xmlType, 
  +            Serializer ser = getSerializer(javaType, xmlType,
                                              actualXMLType);
   
               if ( ser != null ) {
                   // Send the xmlType if indicated or if
  -                // the actual xmlType is different than the 
  +                // the actual xmlType is different than the
                   // prefered xmlType
  -                if (shouldSendType || 
  -                    (xmlType != null && 
  +                if (shouldSendType ||
  +                    (xmlType != null &&
                        (!xmlType.equals(actualXMLType.value)))) {
  -                    attributes = setTypeAttribute(attributes, 
  +                    attributes = setTypeAttribute(attributes,
                                                     actualXMLType.value);
                   }
   
  @@ -1209,9 +1219,9 @@
                   return;
               }
   
  -            // if no serializer was configured try to find one dynamically using WSDLJava

  +            // if no serializer was configured try to find one dynamically using WSDLJava
               // generated metadata
  -            try { 
  +            try {
                   Method method = value.getClass().getMethod(
                           "getSerializer", getSerializerClasses);
                   if (method != null) {
  @@ -1221,10 +1231,10 @@
                       if (typedesc != null) {
                           QName qname = typedesc.getXmlType();
                           if (qname != null) {
  -                            attributes = setTypeAttribute(attributes, 
  +                            attributes = setTypeAttribute(attributes,
                                                             qname);
                           }
  -                    } 
  +                    }
                       serializer.serialize(elemQName, attributes, value, this);
                       return;
                   }
  @@ -1248,10 +1258,10 @@
       /**
        * Walk the interfaces of a class looking for a serializer for that
        * interface.  Include any parent interfaces in the search also.
  -     * 
  -     */ 
  -    private SerializerFactory getSerializerFactoryFromInterface(Class javaType, 
  -                                                                QName xmlType, 
  +     *
  +     */
  +    private SerializerFactory getSerializerFactoryFromInterface(Class javaType,
  +                                                                QName xmlType,
                                                                   TypeMapping tm)
       {
           SerializerFactory  serFactory  = null ;
  @@ -1265,22 +1275,22 @@
                       serFactory = getSerializerFactoryFromInterface(iface, xmlType, tm);
                   if (serFactory != null)
                       break;
  -                   
  +
               }
           }
           return serFactory;
       }
  -    
  +
       /**
        * getSerializer
        * Attempts to get a serializer for the indicated javaType and xmlType.
        * @param javaType is the type of the object
        * @param xmlType is the preferred qname type.
  -     * @param actualXMLType is set to a QNameHolder or null.  
  +     * @param actualXMLType is set to a QNameHolder or null.
        *                     If a QNameHolder, the actual xmlType is returned.
        * @return found class/serializer or null
        **/
  -    private Serializer getSerializer(Class javaType, QName xmlType, 
  +    private Serializer getSerializer(Class javaType, QName xmlType,
                                        QNameHolder actualXMLType) {
           SerializerFactory  serFactory  = null ;
           TypeMapping tm = getTypeMapping();
  @@ -1295,7 +1305,7 @@
   
               // Walk my interfaces...
               serFactory = getSerializerFactoryFromInterface(javaType, xmlType, tm);
  -            
  +
               // Finally, head to my superclass
               if (serFactory != null)
                   break;
  @@ -1307,18 +1317,18 @@
           Serializer ser = null;
           if ( serFactory != null ) {
               ser = (Serializer) serFactory.getSerializerAs(Constants.AXIS_SAX);
  -            
  +
               if (actualXMLType != null) {
                   // Get the actual qname xmlType from the factory.
                   // If not found via the factory, fall back to a less
                   // performant solution.
                   if (serFactory instanceof BaseSerializerFactory) {
  -                    actualXMLType.value = 
  +                    actualXMLType.value =
                           ((BaseSerializerFactory) serFactory).getXMLType();
                   }
                   if (actualXMLType.value == null) {
  -                    actualXMLType.value = 
  -                        ((TypeMappingImpl) tm).getXMLType(javaType, 
  +                    actualXMLType.value =
  +                        ((TypeMappingImpl) tm).getXMLType(javaType,
                                                             xmlType);
                   }
               }
  
  
  
  1.53      +6 -3      xml-axis/java/src/org/apache/axis/message/RPCParam.java
  
  Index: RPCParam.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/RPCParam.java,v
  retrieving revision 1.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- RPCParam.java	11 Dec 2002 22:38:20 -0000	1.52
  +++ RPCParam.java	13 Dec 2002 20:38:04 -0000	1.53
  @@ -58,6 +58,7 @@
   import org.apache.axis.description.ParameterDesc;
   import org.apache.axis.encoding.SerializationContext;
   import org.apache.axis.utils.Messages;
  +import org.apache.axis.utils.JavaUtils;
   import org.apache.commons.logging.Log;
   
   import javax.xml.namespace.QName;
  @@ -213,9 +214,11 @@
                   javaType = paramDesc.getJavaType() != null ?
                       paramDesc.getJavaType(): javaType;
               } else if (!(javaType.equals(paramDesc.getJavaType()))) {
  -                // This must (assumedly) be a polymorphic type - in ALL
  -                // such cases, we must send an xsi:type attribute.
  -                wantXSIType = Boolean.TRUE;
  +                if (!(javaType.equals(
  +                        JavaUtils.getHolderValueType(paramDesc.getJavaType()))))
  +                    // This must (assumedly) be a polymorphic type - in ALL
  +                    // such cases, we must send an xsi:type attribute.
  +                    wantXSIType = Boolean.TRUE;
               }
               xmlType = paramDesc.getTypeQName();
           }
  
  
  
  1.87      +1 -1      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.86
  retrieving revision 1.87
  diff -u -r1.86 -r1.87
  --- JavaUtils.java	11 Dec 2002 22:38:27 -0000	1.86
  +++ JavaUtils.java	13 Dec 2002 20:38:04 -0000	1.87
  @@ -861,7 +861,7 @@
           if (type != null) {
               Class[] intf = type.getInterfaces();
               boolean isHolder = false;
  -            for (int i=0; i<intf.length; i++) {
  +            for (int i=0; i<intf.length && !isHolder; i++) {
                   if (intf[i] == javax.xml.rpc.holders.Holder.class) {
                       isHolder = true;
                   }
  
  
  
  1.12      +4 -4      xml-axis/java/test/functional/TestMessageSample.java
  
  Index: TestMessageSample.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/functional/TestMessageSample.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- TestMessageSample.java	11 Dec 2002 22:40:16 -0000	1.11
  +++ TestMessageSample.java	13 Dec 2002 20:38:04 -0000	1.12
  @@ -81,13 +81,13 @@
           String[] args = { };
           String res = (new TestMsg()).doit(args);
           String expected="Res elem[0]=<ns1:e1 xmlns:ns1=\"urn:foo\">Hello</ns1:e1>"

  -                        +"Res elem[1]=<ns1:e1 xmlns:ns1=\"urn:foo\">World</ns1:e1>"
  -                        +"Res elem[2]=<ns1:e3 xmlns:ns1=\"urn:foo\">"
  +                        +"Res elem[1]=<ns2:e1 xmlns:ns2=\"urn:foo\">World</ns2:e1>"
  +                        +"Res elem[2]=<ns3:e3 xmlns:ns3=\"urn:foo\">"
                           +"<![CDATA["
                           +"Text with\n\tImportant  <b>  whitespace </b> and
tags! "
                           +"]]>"
  -                        +"</ns1:e3>";                        
  -        assertEquals("test result elements", res, expected);
  +                        +"</ns3:e3>";
  +        assertEquals("test result elements", expected, res);
       }
       
       public void doTestUndeploy () throws Exception {
  
  
  

Mime
View raw message