axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject cvs commit: ws-axis/java/test/wsdl/echo2 Echo2ServiceTestCase.java
Date Mon, 18 Apr 2005 17:17:12 GMT
gdaniels    2005/04/18 10:17:12

  Modified:    java/src/org/apache/axis/deployment/wsdd WSDDConstants.java
                        WSDDOperation.java WSDDParameter.java
               java/src/org/apache/axis/wsdl/toJava JavaDeployWriter.java
                        JavaStubWriter.java Utils.java
               java/test/wsdl/echo2 Echo2ServiceTestCase.java
  Log:
  Flesh out echo2 test case to actually check the XML, and also make
  it work.
  
  Pass itemQName info through the generated Stub and also the WSDD
  when appropriate, which allows the server to do the right thing when
  serializing arrays.
  
  This isn't 100% right yet, in that the xsi:type on the maxOccurs test for
  echo2 shouldn't be "soapenc:Array", but it's close (and heck, .NET
  ignores xsi:type attributes anyway... :))
  
  NOTE : Checking this in without a successful all-tests run, because the
  terra server (for test/wsdl/terra) seems broken - damned external
  dependencies. :(
  
  Revision  Changes    Path
  1.36      +2 -0      ws-axis/java/src/org/apache/axis/deployment/wsdd/WSDDConstants.java
  
  Index: WSDDConstants.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/deployment/wsdd/WSDDConstants.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- WSDDConstants.java	22 Jun 2004 16:58:17 -0000	1.35
  +++ WSDDConstants.java	18 Apr 2005 17:17:12 -0000	1.36
  @@ -137,6 +137,8 @@
       public static final String ATTR_LOCKED = "locked";
       public static final String ATTR_RETQNAME = "returnQName";
       public static final String ATTR_RETTYPE = "returnType";
  +    public static final String ATTR_RETITEMQNAME = "returnItemQName";
  +    public static final String ATTR_ITEMQNAME = "itemQName";    
       public static final String ATTR_MODE = "mode";
       public static final String ATTR_INHEADER = "inHeader";
       public static final String ATTR_OUTHEADER = "outHeader";
  
  
  
  1.31      +14 -0     ws-axis/java/src/org/apache/axis/deployment/wsdd/WSDDOperation.java
  
  Index: WSDDOperation.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/deployment/wsdd/WSDDOperation.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- WSDDOperation.java	22 Jun 2004 16:58:18 -0000	1.30
  +++ WSDDOperation.java	18 Apr 2005 17:17:12 -0000	1.31
  @@ -84,6 +84,12 @@
               desc.setReturnHeader(JavaUtils.isTrueExplicitly(retHStr));
           }
   
  +        String retItemQName = e.getAttribute(ATTR_RETITEMQNAME);
  +        if (retItemQName != null && !retItemQName.equals("")) {
  +            ParameterDesc param = desc.getReturnParamDesc();
  +            param.setItemQName(XMLUtils.getQNameFromString(retItemQName, e));
  +        }
  +
           String soapAction = e.getAttribute(ATTR_SOAPACTION);
           if (soapAction != null) {
               desc.setSoapAction(soapAction);
  @@ -147,6 +153,14 @@
                                  "CDATA", 
                                  context.qName2String(desc.getElementQName()));
           }
  +
  +        QName retItemQName = desc.getReturnParamDesc().getItemQName();
  +        if (retItemQName != null) {
  +            attrs.addAttribute("", ATTR_RETITEMQNAME, ATTR_RETITEMQNAME,
  +                               "CDATA",
  +                               context.qName2String(retItemQName));
  +        }
  +
           if (desc.getSoapAction() != null) {
               attrs.addAttribute("", ATTR_SOAPACTION, ATTR_SOAPACTION, "CDATA", desc.getSoapAction());
           }
  
  
  
  1.19      +13 -2     ws-axis/java/src/org/apache/axis/deployment/wsdd/WSDDParameter.java
  
  Index: WSDDParameter.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/deployment/wsdd/WSDDParameter.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- WSDDParameter.java	25 Feb 2004 14:02:34 -0000	1.18
  +++ WSDDParameter.java	18 Apr 2005 17:17:12 -0000	1.19
  @@ -67,7 +67,12 @@
           if (typeStr != null && !typeStr.equals("")) {
               parameter.setTypeQName(XMLUtils.getQNameFromString(typeStr, e));
           }
  -        
  +
  +        String itemQNameStr = e.getAttribute(ATTR_ITEMQNAME);
  +        if (itemQNameStr != null && !itemQNameStr.equals("")) {
  +            parameter.setItemQName(XMLUtils.getQNameFromString(itemQNameStr, e));
  +        }
  +
           Element docElem = getChildElement(e, ELEM_WSDD_DOC);
           if (docElem != null) {
               WSDDDocumentation documentation = new WSDDDocumentation(docElem);
  @@ -124,7 +129,13 @@
               attrs.addAttribute("", ATTR_TYPE, ATTR_TYPE, "CDATA",
                                  context.qName2String(typeQName));            
           }
  -        
  +
  +        QName itemQName = parameter.getItemQName();
  +        if (itemQName != null) {
  +            attrs.addAttribute("", ATTR_ITEMQNAME, ATTR_ITEMQNAME, "CDATA",
  +                               context.qName2String(itemQName));
  +        }
  +
           context.startElement(getElementName(), attrs);
           
           if (parameter.getDocumentation() != null) {
  
  
  
  1.91      +17 -0     ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java
  
  Index: JavaDeployWriter.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java,v
  retrieving revision 1.90
  retrieving revision 1.91
  diff -u -r1.90 -r1.91
  --- JavaDeployWriter.java	21 Mar 2005 12:37:20 -0000	1.90
  +++ JavaDeployWriter.java	18 Apr 2005 17:17:12 -0000	1.91
  @@ -571,6 +571,16 @@
                       + "\"");
           }
   
  +        Parameter retParam = params.returnParam;
  +        if (retParam != null) {
  +            QName returnItemQName = Utils.getItemQName(retParam.getType());
  +            if (returnItemQName != null) {
  +                pw.print(" returnItemQName=\"");
  +                pw.print(Utils.genQNameAttributeString(returnItemQName, "tns"));
  +                pw.print("\"");
  +            }
  +        }
  +
           if (SOAPAction != null) {
               pw.print(" soapAction=\""
                       + SOAPAction
  @@ -629,6 +639,13 @@
                   pw.print(" outHeader=\"true\"");
               }
   
  +            QName itemQName = Utils.getItemQName(param.getType());
  +            if (itemQName != null) {
  +                pw.print(" itemQName=\"");
  +                pw.print(Utils.genQNameAttributeString(itemQName, "tns"));
  +                pw.print("\"");
  +            }
  +
               pw.println("/>");
           }
   
  
  
  
  1.146     +16 -10    ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java
  
  Index: JavaStubWriter.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java,v
  retrieving revision 1.145
  retrieving revision 1.146
  diff -u -r1.145 -r1.146
  --- JavaStubWriter.java	12 Apr 2005 22:18:16 -0000	1.145
  +++ JavaStubWriter.java	18 Apr 2005 17:17:12 -0000	1.146
  @@ -627,11 +627,8 @@
                              paramTypeText + ", " +
                              javaType +
                              isInHeader + ", " + isOutHeader + ");");
  -                TypeEntry te = p.getType();
  -                if (te instanceof DefinedElement) {
  -                    te = te.getRefType();
  -                }
  -                QName itemQName = te.getItemQName();
  +
  +                QName itemQName = Utils.getItemQName(p.getType());
                   if (itemQName != null) {
                       pw.println("        param.setItemQName(" +
                                  Utils.getNewQName(itemQName) + ");");
  @@ -641,13 +638,14 @@
               }
   
               // set output type
  -            if (parameters.returnParam != null) {
  +            Parameter returnParam = parameters.returnParam;
  +            if (returnParam != null) {
   
                   // Get the QName for the return Type
  -                QName returnType = Utils.getXSIType(parameters.returnParam);
  +                QName returnType = Utils.getXSIType(returnParam);
   
                   // Get the javaType
  -                String javaType = Utils.getParameterTypeName(parameters.returnParam);
  +                String javaType = Utils.getParameterTypeName(returnParam);
   
                   if (javaType == null) {
                       javaType = "";
  @@ -659,16 +657,24 @@
                           + Utils.getNewQName(returnType) + ");");
                   pw.println("        oper.setReturnClass(" + javaType + ");");
   
  -                QName returnQName = parameters.returnParam.getQName();
  +                QName returnQName = returnParam.getQName();
   
                   if (returnQName != null) {
                       pw.println("        oper.setReturnQName("
                               + Utils.getNewQNameWithLastLocalPart(returnQName) + ");");
                   }
   
  -                if (parameters.returnParam.isOutHeader()) {
  +                if (returnParam.isOutHeader()) {
                       pw.println("        oper.setReturnHeader(true);");
                   }
  +
  +                QName itemQName = Utils.getItemQName(returnParam.getType());
  +                if (itemQName != null) {
  +                    pw.println("        param = oper.getReturnParamDesc();");
  +                    pw.println("        param.setItemQName(" +
  +                               Utils.getNewQName(itemQName) + ");");
  +                }
  +
               } else {
                   pw.println(
                           "        oper.setReturnType(org.apache.axis.encoding.XMLType.AXIS_VOID);");
  
  
  
  1.93      +7 -0      ws-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java
  
  Index: Utils.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/toJava/Utils.java,v
  retrieving revision 1.92
  retrieving revision 1.93
  diff -u -r1.92 -r1.93
  --- Utils.java	8 Feb 2005 18:44:36 -0000	1.92
  +++ Utils.java	18 Apr 2005 17:17:12 -0000	1.93
  @@ -1298,4 +1298,11 @@
                   && type.getNode().getLocalName().equals(
                           "attributeGroup"))));
       }
  +
  +    public static QName getItemQName(TypeEntry te) {
  +        if (te instanceof DefinedElement) {
  +            te = te.getRefType();
  +        }
  +        return te.getItemQName();
  +    }
   }    // class Utils
  
  
  
  1.2       +31 -3     ws-axis/java/test/wsdl/echo2/Echo2ServiceTestCase.java
  
  Index: Echo2ServiceTestCase.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/test/wsdl/echo2/Echo2ServiceTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Echo2ServiceTestCase.java	17 Apr 2005 02:25:53 -0000	1.1
  +++ Echo2ServiceTestCase.java	18 Apr 2005 17:17:12 -0000	1.2
  @@ -12,6 +12,10 @@
   import org.apache.axis.encoding.ser.BeanDeserializerFactory;
   import org.apache.axis.encoding.ser.BeanSerializerFactory;
   import org.apache.axis.message.SOAPBody;
  +import org.apache.axis.message.MessageElement;
  +
  +import java.util.List;
  +import java.util.Iterator;
   
   public class Echo2ServiceTestCase extends junit.framework.TestCase {
       public Echo2ServiceTestCase(java.lang.String name) {
  @@ -102,13 +106,37 @@
           // Time out after a minute
           binding.setTimeout(60000);
           // Test operation
  +        String [] args = new String[] {"one", "two", "", null};
   		java.lang.String[] value = null;
           value = binding
  -                .echoArrayOfString_MaxOccursUnbounded(new String[]{"one", "two", "", null});
  -        // TBD - validate results
  +                .echoArrayOfString_MaxOccursUnbounded(args);
  +
  +        // Validate results - NOTE: This checks the XML directly, so if
  +        // any changes are made to the WSDL/code for this test, equivalent
  +        // changes must be made in this code.
           Service service = (Service)binding._getService();
           SOAPBody body = (SOAPBody)service.getCall().getResponseMessage().getSOAPBody();
  -        System.out.println(body.toString());
  +        MessageElement element;
  +        QName responseQName = new QName("urn:echo2.wsdl.test", "echoArrayOfString_MaxOccursUnboundedResponse");
  +        QName returnQName = new QName("", "return");
  +        QName itemQName = new QName("", "varStringArray");
  +        element = body.getChildElement(responseQName);
  +        assertNotNull("Couldn't find response element", element);
  +        element = element.getChildElement(returnQName);
  +        assertNotNull("Couldn't find return element", element);
  +        Iterator elements = element.getChildElements(itemQName);
  +        assertNotNull("Couldn't find items", elements);
  +        int count = 0;
  +        while (elements.hasNext()) {
  +            element = (MessageElement) elements.next();
  +            count++;
  +        }
  +        assertEquals("Wrong # of items", 4, count);
  +
  +        // OK, now that we know the XML looked right, just for yuks check the values
  +        for (int i = 0; i < value.length; i++) {
  +            assertEquals("Item " + i + " didn't match!", args[i], value[i]);
  +        }
       }
   
       public void test3Echo2EchoArrayOfString_SoapEncArray() throws Exception {
  
  
  

Mime
View raw message