You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2003/10/28 18:44:30 UTC

cvs commit: ws-axis/java/test/wsdl/attrGroup AttrGroupService.wsdl AttrGroupServiceTestCase.java build.xml

dims        2003/10/28 09:44:30

  Added:       java/test/wsdl/attrGroup AttrGroupService.wsdl
                        AttrGroupServiceTestCase.java build.xml
  Log:
  Testcase for Bug 23145 - WSDL2Java appears to ignore attributegroups in serialization
  from kbrichan@comcast.net (Brook Richan)
  
  Revision  Changes    Path
  1.1                  ws-axis/java/test/wsdl/attrGroup/AttrGroupService.wsdl
  
  Index: AttrGroupService.wsdl
  ===================================================================
  <?xml version="1.0" encoding="utf-8"?>
  <definitions
     xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
     xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
     xmlns:s="http://www.w3.org/2001/XMLSchema"
     xmlns:s0="http://tempuri.org/"
     xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/"
     xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding"
     targetNamespace="http://tempuri.org/"
     xmlns="http://schemas.xmlsoap.org/wsdl/">
    <types>
      <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
        <s:import namespace="http://www.w3.org/2001/XMLSchema" />
        <s:import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
        <s:attributeGroup name="MyCommonAttrs1">
          <s:attribute name="attr1" type="s:int"/>
        </s:attributeGroup>
        <s:attributeGroup name="MyCommonAttrs2">
          <s:attributeGroup ref="s0:MyCommonAttrs1"/>
          <s:attribute name="attr2" type="s:double"/>
        </s:attributeGroup>
        <s:element name="Record1">
          <s:complexType>
            <s:sequence>
              <s:element name="elem1" type="s:int"/>
            </s:sequence>
            <s:attributeGroup ref="s0:MyCommonAttrs1"/>
            <s:attributeGroup ref="soapenc11:commonAttributes"/>
            <s:attribute name="attr3" type="s:string"/>
          </s:complexType>
        </s:element>
        <s:element name="Record2">
          <s:complexType>
            <s:sequence>
              <s:element name="elem2" type="s:string"/>
            </s:sequence>
            <s:attributeGroup ref="s0:MyCommonAttrs2"/>
            <s:attributeGroup ref="soapenc12:commonAttributes"/>
          </s:complexType>
        </s:element>
      </s:schema>
    </types>
    <message name="Record1SoapIn">
      <part name="parameters" element="s0:Record1" />
    </message>
    <message name="Record2SoapOut">
      <part name="parameters" element="s0:Record2" />
    </message>
    <portType name="AttrGroupServiceSoap">
      <operation name="a1AndA2">
        <input message="s0:Record1SoapIn" />
        <output message="s0:Record2SoapOut" />
      </operation>
    </portType>
    <binding name="AttrGroupServiceSoap" type="s0:AttrGroupServiceSoap">
      <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
      <operation name="a1AndA2">
        <soap:operation soapAction="http://tempuri.org/a1AndA2" style="document" />
        <input>
          <soap:body use="literal" />
        </input>
        <output>
          <soap:body use="literal" />
        </output>
      </operation>
    </binding>
    <service name="AttrGroupService">
      <port name="AttrGroupServiceSoap" binding="s0:AttrGroupServiceSoap">
        <soap:address location="http://www.irrelevant.com/services/AttrGroupService/AttrGroupService.asmx" />
      </port>
    </service>
  </definitions>
  
  
  1.1                  ws-axis/java/test/wsdl/attrGroup/AttrGroupServiceTestCase.java
  
  Index: AttrGroupServiceTestCase.java
  ===================================================================
  /**
   * AttrGroupServiceTestCase.java
   */
  
  package test.wsdl.attrGroup;
  
  public class AttrGroupServiceTestCase extends junit.framework.TestCase {
      public AttrGroupServiceTestCase(java.lang.String name) {
          super(name);
      }
      public void test1AttrGroupService() throws Exception {
          // make sure WSDL2Java generated the right stuff
          
          // we don't really need to test sending a request
          //   and getting a response, since many other tests comprehend that
          // all we need to do is make sure WSDL2Java generated
          //   the attributes needed from the attributeGroup definitions
          // so, basically, if this compiles, we are good to go
          // but running it won't hurt anything
  
          test.wsdl.attrGroup._Record1 rec1 = new test.wsdl.attrGroup._Record1();
  
          // an element defined within Record1
          rec1.setElem1(1);
          assertTrue("elem1 should be 1, but is "+rec1.getElem1(), rec1.getElem1()==1);
  
          // an attribute defined in an attributeGroup
          rec1.setAttr1(2);
          assertTrue("attr1 should be 2, but is "+rec1.getAttr1(), rec1.getAttr1()==2);
  
          // an attribute defined in Record1 itself
          rec1.setAttr3("x");
          assertTrue("attr3 should be x, but is "+rec1.getAttr3(), rec1.getAttr3().equals("x"));
          
          // two attributes from a known 1.1 soap encoding schema
          rec1.setId(new org.apache.axis.types.Id("theId"));
          rec1.setHref(new org.apache.axis.types.URI("a", "b"));
  
          test.wsdl.attrGroup._Record2 rec2 = new test.wsdl.attrGroup._Record2();
          
          // an element defined within Record2
          rec2.setElem2("2");
  
          // an attribute defined in a referenced attributeGroup within an attributeGroup
          rec2.setAttr1(2);
          
          // an attribute defined in an attributeGroup that has another nested reference
          rec2.setAttr2(1.2);
          
          // an attribute from a known 1.2 soap encoding schema
          rec2.setId(new org.apache.axis.types.Id("theId"));
      }
  
      /*
      public static void main(String[] args)
      {
          AttrGroupServiceTestCase test = new AttrGroupServiceTestCase("x");
          try {
              test.test1AttrGroupService();
          }
          catch (Exception e)
          {
              e.printStackTrace();
          }
      }
      */
  }
  
  
  
  1.1                  ws-axis/java/test/wsdl/attrGroup/build.xml
  
  Index: build.xml
  ===================================================================
  <?xml version="1.0" ?>
  <!DOCTYPE project [
          <!ENTITY properties SYSTEM "file:../../../xmls/properties.xml">
          <!ENTITY paths  SYSTEM "file:../../../xmls/path_refs.xml">
          <!ENTITY taskdefs SYSTEM "file:../../../xmls/taskdefs.xml">
          <!ENTITY taskdefs_post_compile SYSTEM "file:../../../xmls/taskdefs_post_compile.xml">
          <!ENTITY targets SYSTEM "file:../../../xmls/targets.xml">
  ]>
  
  <!-- ===================================================================
  <description>
     Test/Sample Component file for Axis
  
  Notes:
     This is a build file for use with the Jakarta Ant build tool.
  
  Prerequisites:
  
     jakarta-ant from http://jakarta.apache.org
  
  Build Instructions:
     To compile
          ant compile
     To execute
          ant run
  
  Author:
    Brook Richan brichan@sandlot.com
  
  Copyright:
    Copyright (c) 2003 Apache Software Foundation.
  </description>
  ==================================================================== -->
  
  <project default="compile">
  
  <property name="axis.home" location="../../.." />
  <property name="componentName" value="test/wsdl/attrGroup" />
          &properties;
          &paths;
          &taskdefs;
          &taskdefs_post_compile;
          &targets;
  
  <target name="clean">
      <echo message="Removing ${build.dir}/classes/${componentName} and ${build.dir}/work/${componentName}" />
      <delete dir="${build.dir}/classes/${componentName}"/>
      <delete dir="${build.dir}/work/${componentName}"/>
  </target>
  
  <target name="copy" depends="setenv"/>
  
  <target name="compile" depends="copy">
    <echo message="Compiling test.wsdl.attrGroup"/>
      <wsdl2java url="${axis.home}/test/wsdl/attrGroup/AttrGroupService.wsdl"
                 output="${axis.home}/build/work"
                 serverSide="no"
                 testcase="no">
          <mapping namespace="http://tempuri.org/" package="test.wsdl.attrGroup"/>
      </wsdl2java>
  
     <copy todir="${build.dir}/work/test/wsdl/attrGroup" overwrite="yes">
        <fileset dir="${axis.home}/test/wsdl/attrGroup">
          <include name="*TestCase.java"/>
        </fileset>
      </copy>
  
      <javac srcdir="${build.dir}/work" destdir="${build.dest}" fork="${javac.fork}"
             debug="${debug}">
        <classpath refid="classpath" />
        <include name="test/wsdl/attrGroup/*.java" />
        <include name="test/wsdl/attrGroup/**/*.java" />
      </javac>
  
  </target>
  
  <target name="run" >
    <antcall target="execute-Component-noServer" />
  </target>
  
  </project>