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 pe...@apache.org on 2005/01/25 17:33:47 UTC

cvs commit: ws-axis/c/tests/auto_build/testcases/tests DynamicTest01.xml

perryan     2005/01/25 08:33:47

  Modified:    c/build  buildTest.xml
               c/docs   anttest-guide.html
  Added:       c/tests/auto_build/testcases/dynamic/Test01 Calculator.cpp
                        Calculator.hpp
               c/tests/auto_build/testcases/output DynamicTest01.expected
               c/tests/auto_build/testcases/tests DynamicTest01.xml
  Log:
  Updated the Ant test framework to allow dynamic clients to be compiled and tested.
  A very simple example dynamic client has been added too along with the standard framework files.
  The Ant test framework guide has been updated to reflect these changes.
  
  Revision  Changes    Path
  1.5       +18 -13    ws-axis/c/build/buildTest.xml
  
  Index: buildTest.xml
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/build/buildTest.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- buildTest.xml	10 Jan 2005 21:00:31 -0000	1.4
  +++ buildTest.xml	25 Jan 2005 16:33:45 -0000	1.5
  @@ -1,6 +1,10 @@
   
   <project name="buildTest" default="compileClient" basedir="..">
   
  +	<target name="buildClient" unless="runOnly">
  +		<antcall target="compileClient" inheritAll="true"/>
  +	</target>
  +
   	<!--
   	  Need to set a language property for wsdl2ws
   	  -->
  @@ -16,7 +20,7 @@
   	<!--
   	  Use WSDL2Ws to generate stubs from WSDL files
   	  -->
  -	<target name="generateStubs" if="test.wsdl" unless="runOnly" depends="setLanguage">
  +	<target name="generateStubs" if="test.wsdl" unless="test.dynamicCode" depends="setLanguage">
   		<!-- Make directory in which all generated code shall be placed -->
   		<mkdir dir="${dir.test.generated}/${client.lang}/${testName}"/>
   		<!-- Setup classpath for WSDL2Ws -->
  @@ -28,10 +32,6 @@
   		<java jar="${dir.wsdl2ws}/wsdl2ws.jar" fork="true">
   			<classpath refid="cp"/>
   			<arg value="${wsdl.test}"/>
  -			<!--
  -			<arg value="${dir.autotests}/wsdls/${testWsdl}"/>
  -			<arg value="-o${dir.test.generated}/${client.lang}/${testName}"/>
  -			-->
   			<arg value="-o${test.directory}"/>
   			<arg value="-l${generated.lang}"/>
   			<arg value="-sclient"/>
  @@ -41,17 +41,25 @@
   	<!--
   	  Copy across test client, ready for compiling
   	  -->
  -	<target name="copyClient" unless="runOnly">
  -		<!--
  -		<copy file="${dir.autotests}/client/${client.lang}/${testCode}" todir="${dir.test.generated}/${client.lang}/${testName}"/>
  -		-->
  +	<target name="getClient" depends="copyStubClient, copyDynamicClient"/>
  +
  +	<target name="copyStubClient" depends="generateStubs" unless="test.dynamicCode">
   		<copy file="${client.code}" todir="${test.directory}"/>
   	</target>
   
  +	<target name="copyDynamicClient" if="test.dynamicCode">
  +		<copy todir="${test.directory}">
  +			<fileset dir="${dir.autotests}/dynamic/${test.dynamicCodeDirectory}">
  +				<include name="*.cpp"/>
  +				<include name="*.hpp"/>
  +			</fileset>
  +		</copy>
  +	</target>
  +
   	<!--
   	  Compile test client
   	  -->
  -	<target name="compileClient" depends="generateStubs, copyClient" unless="runOnly">
  +	<target name="compileClient" depends="getClient">
   		<cc failonerror="false" incremental="false" outfile="${test.directory}/${testName}"
   		 objdir="${test.directory}" exceptions="true"
   		 outtype="executable" subsystem="console">
  @@ -67,9 +75,6 @@
   			<libset dir="${dir.lib}" libs="${clientLibraryName}"/>
   			<!-- Files to be compiled -->
   			<includepath path="${dir.include}"/>
  -			<!--
  -			<fileset dir="${dir.test.generated}/${client.lang}/${testName}">
  -			-->
   			<fileset dir="${test.directory}">
   				<include name="*.${client.lang}"/>
   			</fileset>
  
  
  
  1.2       +68 -9     ws-axis/c/docs/anttest-guide.html
  
  Index: anttest-guide.html
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/docs/anttest-guide.html,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- anttest-guide.html	11 Dec 2004 15:26:14 -0000	1.1
  +++ anttest-guide.html	25 Jan 2005 16:33:45 -0000	1.2
  @@ -61,6 +61,7 @@
   <a href="#properties">Test Properties Files</a><br/>
   <a href="#conversions">Conversions</a><br/>
   <a href="#handlers">Handlers</a><br/>
  +<a href="#dynamic">Dynamic Clients</a><br/>
   <a href="#monitor">TCP Monitor Utility</a><br/>
   <a href="#filelist">Files Specific to Ant Test Framework</a><br/>
   <a href="#required">Files Required by Ant Test Framework</a><br/>
  @@ -93,13 +94,13 @@
   In order for the tests to run, the location of the XML parser libraries, XMLPARSER_HOME needs to be specified, and the install location of the Axis C++ package needs to be specified. These can either be specified on the command line or added to the platform specific properties files.
   </p> 
   <p>To run all tests type:</p>
  -<blockquote><code>ant -f test.xml -Ddir.xmlParser=XMLPARSER_HOME -Ddir.package=PACKAGE</code></blockquote>
  +<blockquote><code>ant -f test.xml -Ddir.xmlParser=XMLPARSER_HOME -Ddir.release=PACKAGE</code></blockquote>
   
   <p>To run a sub-set of tests a file with the name of the test property files to be used for the test run. The location of the file needs to be passed to the Ant script. If a relative path is specified then it must be relevant to the BASEDIR directory. e.g. to run the subset of tests specified in a file called tests_to_run in the BASEDIR directory run:</p>
  -<blockquote><code>ant -f test.xml -Ddir.xmlParser=XMLPARSER_HOME -Ddir.package=PACKAGE -Dtest.list=tests_to_run</code></blockquote>
  +<blockquote><code>ant -f test.xml -Ddir.xmlParser=XMLPARSER_HOME -Ddir.release=PACKAGE -Dtest.list=tests_to_run</code></blockquote>
   
   <p>To run an individual test specify the name of the test property file. e.g. to run only the CalculatorDoc test run:</p>
  -<blockquote><code>ant -f test.xml -Ddir.xmlParser=XMLPARSER_HOME -Ddir.package=PACKAGE -Dtest.name=CalculatorDoc</code></blockquote>
  +<blockquote><code>ant -f test.xml -Ddir.xmlParser=XMLPARSER_HOME -Ddir.release=PACKAGE -Dtest.name=CalculatorDoc</code></blockquote>
   
   <h2 id="create">Creating new tests</h2>
   <p>When creating a new test at least 3 files must be added to the test framework.</p>
  @@ -234,15 +235,17 @@
       <DD>This is the endpoint for the service used in the test. The server or server:port portion of the endpoint is changed to point to the <a href="#monitor">TCP monitor utility</a>, which will forward the request to the testHost:testPort combination specified in the build.xx.properties file. The <a href="#monitor">monitor</a> will be started on localhost on the port specified by the monitorPort property in the properties file.  e.g. if the web service is running on a server called testserver which is listening on port 9080, and the <a href="#monitor">monitor</a> is configured to listen on port 12345 then the endpoint in example 1 will be changed to http://localhost:12345/Calculator/services/Calculator and the <a href="#monitor">monitor</a> will forward the request to testserver:9080</DD>
   
       </DL>
  +	 </p>
   
  -    The example 2 show all the optional tags that are available.
  +	 <p>
  +	 The example 2 shows all the optional tags that are available for handler tests.
       </p>
   
       <div class="example">
       <pre>
   
        &lt;test&gt;
  -        &lt;name&gt;HandlerTest2&lt;/name&gt;
  +        &lt;name&gt;HandlerTest02&lt;/name&gt;
           &lt;description&gt;CalculatorDoc with Handler Chain&lt;/description&gt;
           &lt;clientLang&gt;cpp&lt;/clientLang&gt;
           &lt;clientCode&gt;CalculatorDocClient.cpp&lt;/clientCode&gt;
  @@ -257,7 +260,7 @@
           &lt;/expected&gt;
           &lt;handler&gt;
               &lt;directory&gt;
  -                handler_chain
  +                handler_test2
               &lt;/directory&gt;
               &lt;service&gt;
                   Calculator
  @@ -292,6 +295,44 @@
               sent to the service.</DD>
       </DL>
   
  +	 <p>
  +	 The example 3 shows all the optional tags that are available for dynamic client tests <a href="#dynamic">(See Dynamic Clients)</a>.
  +    </p>
  +
  +    <div class="example">
  +    <pre>
  +
  +     &lt;test&gt;
  +        &lt;name&gt;DynamicTest01&lt;/name&gt;
  +        &lt;description&gt;CalculatorDoc implemented as a dynamic client&lt;/description&gt;
  +        &lt;dynamicCode&gt;true&lt;/dynamicCode&gt;
  +        &lt;dynamicCodeDirectory&gt;Test01&lt;/dynamicCodeDirectory&gt;
  +        &lt;clientLang&gt;cpp&lt;/clientLang&gt;
  +        &lt;wsdl&gt;CalculatorDoc.wsdl&lt;/wsdl&gt;
  +        &lt;expected&gt;
  +            &lt;output&gt;
  +                CalculatorDoc.cpp.out
  +            &lt;/output&gt;
  +        &lt;/expected&gt;
  +        &lt;endpoint&gt;http://localhost:80/Calculator/services/Calculator&lt;/endpoint&gt;
  +    &lt;/test&gt;
  +    </pre>
  +    </div>
  +    <p class="example">example 3</p>
  +
  +    <p>
  +    The optional tags shown in example 3 are detailed below.
  +    </p>
  +
  +    <DL>
  +        <DT>&lt;dynamicCode&gt;</DT>
  +		  <DD>This is a flag to indicate that the client is a dynamic client. The value has no relevance but must be set to something. WARNING setting it to false will have no effect. This property should only be used for dynamic client tests. Having this property will cause the framework to get the source from a different location and not to generate any stubs from the WSDL.</DD>
  +
  +        <DT>&lt;dynamicCodeDirectory&gt;</DT>
  +		  <DD>This is the name of the directory where all the dynamic code is copied from. All .cpp and .hpp files will be copied from this directory to the generated output directory.</DD>
  +
  +    </DL>
  +
   
   <h2 id="conversions">Conversions</h2>
   <p>
  @@ -308,9 +349,8 @@
   <br/>
   e.g.
   <br/>
  -In example 2 above a directory of handler_chain was specified. This directory is the parent of the library directories, but a sub directory of the ws-axis/c/tests/auto_build/testcases/handlers/ directory. The handler_chain directory structure is shown in example 3
  +In example 2 above a directory of handler_chain was specified. This directory is the parent of the library directories, but a sub directory of the ws-axis/c/tests/auto_build/testcases/handlers/ directory. The handler_chain directory structure is shown in example 4
   </p>
  -
   <div class="example">
   	<pre>
   	<code>
  @@ -325,7 +365,7 @@
   	</code>
   	</pre>
   </div>
  -    <p class="example">example 3</p>
  +    <p class="example">example 4</p>
   
   <p>
   When built this will produce 2 libraries in the test output directory called libtesthandler.so and libtesthandler2.so on Linux and testhandler.dll and testhandler2.dll on Windows.
  @@ -335,6 +375,25 @@
   At present only &lt;requestFlow ..&gt; handlers are supported.
   
   </p>
  +
  +<h2 id="dynamic">Dynamic Clients</h2>
  +<p>
  +A dynamic client is a client that uses the Call object directly and all initialization must be done manually. A dynamic client does NOT use stubs generated from the WSDL. Of course the dynamic client may have been based originally on a generated Stub. Using the dynamic client approach gives the developer greater control over when the APIs are called and may provide access to data protected via the Stub interface. The big disadvtage of a dynamic client is that a new release of AxisC++ may break the client more easily than if generated Stubs were used. All the code for dynamic client needs to be placed into a sub-directory of the dynamic directory <code>ws-axis/c/tests/auto_build/testcases/dynamic</code>.
  +<br/>
  +e.g.
  +<br/>
  +In example 3 above a dynamicCodeDirectory of Test01 was specified. This directory is a sub directory of the ws-axis/c/tests/auto_build/testcases/dynamic directory. This directory structure is shown in example 5.
  +</p>
  +<div class="example">
  +	<pre>
  +	<code>
  +        Test01/Calculator.cpp
  +        Test01/Calculator.hpp
  +	</code>
  +	</pre>
  +</div>
  +    <p class="example">example 5</p>
  +
   
   <h2 id="monitor">TCP Monitor Utility</h2>
   <p>
  
  
  
  1.1                  ws-axis/c/tests/auto_build/testcases/dynamic/Test01/Calculator.cpp
  
  Index: Calculator.cpp
  ===================================================================
  /*
  * This is a manually edited version of the Generated stub code for CaluclatorDoc.wsdl
  * to simplify the code to allow the cpp file to be edited to be used as a dynamic client
  * perryan@uk.ibm.com
  */
  
  #include "Calculator.hpp"
  #include <axis/AxisWrapperAPI.hpp>
  
  Calculator::Calculator (const char *pcEndpointUri,
                          AXIS_PROTOCOL_TYPE eProtocol)
  {
    m_pCall = new Call ();
    m_pCall->setProtocol (eProtocol);
    m_pCall->setEndpointURI (pcEndpointUri);
  }
  
  Calculator::Calculator ()
  {
    m_pCall = new Call ();
    m_pCall->setEndpointURI ("http://localhost/axis/Calculator");
  }
  
  Calculator::~Calculator ()
  {
  }
  
  /*
  * A new test method which is called from elsewhere in the code. New test 
  * methods can be used to keep things clean. perryan@uk.ibm.com 
  */
  void
  Calculator::printProtocolType ()
  {
    printf ("protocol type = %d\n", m_pCall->getProtocol ());
  }
  
  /*
  * This method wrap the service methoddiv
  */
  xsd__int Calculator::div (xsd__int Value0, xsd__int Value1)
  {
    xsd__int
      Ret = 0;
    const char *
      pcCmplxFaultName;
  
  #define DEFAULT_WSDL_ENDPOINT "http://localhost/axis/Calculator"
  
    try
    {
      if (AXIS_SUCCESS != m_pCall->initialize (CPP_DOC_PROVIDER))
        return Ret;
  
      m_pCall->setTransportProperty (SOAPACTION_HEADER, "Calculator#div");
      m_pCall->setSOAPVersion (SOAP_VER_1_1);
      m_pCall->setOperation ("div", DEFAULT_WSDL_ENDPOINT);
  
      printProtocolType ();
  
      includeSecure ();
      char
        cPrefixAndParamName0[17];
      sprintf (cPrefixAndParamName0, "%s:arg_0_3",
               m_pCall->getNamespacePrefix (DEFAULT_WSDL_ENDPOINT));
      m_pCall->addParameter ((void *) &Value0, cPrefixAndParamName0, XSD_INT);
      char
        cPrefixAndParamName1[17];
      sprintf (cPrefixAndParamName1, "%s:arg_1_3",
               m_pCall->getNamespacePrefix (DEFAULT_WSDL_ENDPOINT));
      m_pCall->addParameter ((void *) &Value1, cPrefixAndParamName1, XSD_INT);
  
      if (AXIS_SUCCESS == m_pCall->invoke ())
        {
          if (AXIS_SUCCESS ==
              m_pCall->checkMessage ("divResponse", DEFAULT_WSDL_ENDPOINT))
            {
              Ret = m_pCall->getElementAsInt ("divReturn", 0);
            }
  
        }
      m_pCall->unInitialize ();
      return Ret;
    }
    catch (AxisException & e)
    {
      throw;
    }
  }
  
  /*
  * Methods for supporting SecureChannel
  */
  
  void
  Calculator::SetSecure (char *pszArguments, ...)
  {
    char **ppszArgPtr = &pszArguments;
    int iArgIndex = 0;
  
    while (*ppszArgPtr != NULL)
      {
        sArguments[iArgIndex] = *ppszArgPtr;
  
        iArgIndex++;
        ppszArgPtr++;
      }
  }
  
  void
  Calculator::includeSecure ()
  {
    m_pCall->setTransportProperty (SECURE_PROPERTIES,
                                   (const char *) &sArguments);
  }
  
  
  // Main added to allow the modified generated stub to be used as a dynamic 
  // 
  // client
  // perryan@uk.ibm.com
  int
  main (int argc, char *argv[])
  {
    char endpoint[256];
    const char *url = "http://localhost:9080/Calculator/services/Calculator";
    const char *op = 0;
    int i1 = 100, i2 = 20;
    int iResult;
    url = argv[1];
    try
    {
      sprintf (endpoint, "%s", url);
      Calculator ws (endpoint);
      iResult = ws.div (i1, i2);
  
  // Call new test method
  // doesn't neccessarily need to be called from main()
  // perryan@uk.ibm.com
      ws.printProtocolType ();
  
      printf ("%d\n", iResult);
    }
    catch (AxisException & e)
    {
      printf ("Exception : %s\n", e.what ());
    }
    catch (exception & e)
    {
      printf ("Unknown exception has occured\n");
    }
    catch (...)
    {
      printf ("Unspecified exception has occured\n");
    }
    return 0;
  }
  
  
  
  1.1                  ws-axis/c/tests/auto_build/testcases/dynamic/Test01/Calculator.hpp
  
  Index: Calculator.hpp
  ===================================================================
  /*
   * This is a manually edited version of the Generated stub code for CaluclatorDoc.wsdl
   * to simplify the code to allow the cpp file to be edited to be used as a dynamic client
   */
  
  // perryan@uk.ibm.com
  // Changed defined name to remove STUB
  #if !defined(__CALCULATOR_CLIENT_H__INCLUDED_)
  #define __CALCULATOR_CLIENT_H__INCLUDED_
  
  #include <axis/AxisException.hpp>
  #include <axis/client/Call.hpp>
  
  // These are normally included from the generated <stub>_AxisClientException header file
  // so we need to specify them explicitly here
  // perryan@uk.ibm.com
  #include <string>
  #include <exception>
  
  // These are normally included from the generated <stub>_AxisClientException header file
  // so we need to specify them explicitly here
  // perryan@uk.ibm.com
  using namespace std;
  AXIS_CPP_NAMESPACE_USE class Calculator
  {
  public:
    STORAGE_CLASS_INFO Calculator (const char *pchEndpointUri,
                                   AXIS_PROTOCOL_TYPE eProtocol = APTHTTP1_1);
    STORAGE_CLASS_INFO Calculator ();
  public:
    STORAGE_CLASS_INFO virtual ~ Calculator ();
  public:
    STORAGE_CLASS_INFO void SetSecure (char *, ...);
    STORAGE_CLASS_INFO xsd__int div (xsd__int Value0, xsd__int Value1);
  
  // Add any new test methods here. These need to be class members to get access to the 
  // Call object.
  // perryan@uk.ibm.com
    STORAGE_CLASS_INFO void printProtocolType (void);
  
  private:
    void includeSecure ();
    Call *m_pCall;
  
  protected:
    std::string sArguments[8];
  };
  
  #endif /* !defined(__CALCULATOR_CLIENT_H__INCLUDED_) */
  
  
  
  1.1                  ws-axis/c/tests/auto_build/testcases/output/DynamicTest01.expected
  
  Index: DynamicTest01.expected
  ===================================================================
  protocol type = 1
  protocol type = 1
  5
  
  
  
  1.1                  ws-axis/c/tests/auto_build/testcases/tests/DynamicTest01.xml
  
  Index: DynamicTest01.xml
  ===================================================================
  <test>
      <name>DynamicTest1</name>
      <description>CalculatorDoc</description>
  	<dynamicCode>true</dynamicCode>
  	<dynamicCodeDirectory>Test01</dynamicCodeDirectory>
      <clientLang>cpp</clientLang>
      <wsdl>CalculatorDoc.wsdl</wsdl>
      <expected>
          <output>
              DynamicTest01.expected
          </output>
      </expected>
  	<endpoint>http://localhost:80/Calculator/services/Calculator</endpoint>
  </test>