Introduction
Conventions
Running the Tests
Creating new tests
How the Framework Works
Test Properties Files
Conversions
Handlers
Dynamic Clients
TCP Monitor Utility
Files Specific to Ant Test Framework
Files Required by Ant Test Framework
This document describes the Apache Ant based test framework used for testing the Apache Axis C++ Web Services project. Please refer to the antbuild-guide.html for information about Ant versions and pre-requisites.
The entire Axis C++ source tree is not required to run the test suite, but all the files in ws-axis/c/build and ws-axis/c/tests/auto_build/testcases directories are required. The product must be installed on the test machine. Please refer to the lininstall-guide.html for Linux install instructions or the wininstall-guide.html for Windows install instructions.
Each test has a property file and all the property files are located in the BASEDIR/tests/auto_build/testcases/tests directory. By default all the tests which have a property file in this directory will be run, but it is possible to define a subset of tests to run or to run an individual test.
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.
To run all tests type:
ant -f test.xml -Ddir.xmlParser=XMLPARSER_HOME -Ddir.release=PACKAGE
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:
ant -f test.xml -Ddir.xmlParser=XMLPARSER_HOME -Ddir.release=PACKAGE -Dtest.list=tests_to_run
To run an individual test specify the name of the test property file. e.g. to run only the CalculatorDoc test run:
ant -f test.xml -Ddir.xmlParser=XMLPARSER_HOME -Ddir.release=PACKAGE -Dtest.name=CalculatorDoc
When creating a new test at least 3 files must be added to the test framework.
main() function. This must be located in the BASEDIR/tests/auto_build/testcases/client/<lang> directory.BASEDIR/tests/auto_build/testcases/output directory.BASEDIR/tests/auto_build/testcases/tests directory.Additionally the following files may also be added
BASEDIR/tests/auto_build/testcases/wsdls directory.BASEDIR/tests/auto_build/testcases/output directory.BASEDIR/tests/auto_build/testcases/handlers directory. (See Handlers).When the tests are run the each test is compiled into the test output directory. This directory is created in the directory structure pointed to by the dir.obj property in the build.xx.properties files. Under the dir.obj directory the following directory structure is created.
test/generated*
test/generated/etc*
test/generated/<lang>
test/generated/<lang>/<test name>
*The axiscpp.conf file is created in a different location dependent upon platform
After initializing and compiling the TCP monitor utility, for each test property file in the list of tests to run (See Running Tests the framework will:
The test property files are pseudo XML documents that define all the required elements to run a test (See Creating new tests). A basic example of the properties file can be seen in example 1 which has all the mandatory elements.
<test>
<name>CalculatorDoc</name>
<description>CalculatorDoc</description>
<clientLang>cpp</clientLang>
<clientCode>CalculatorDocClient.cpp</clientCode>
<wsdl>CalculatorDoc.wsdl</wsdl>
<expected>
<output>
CalculatorDoc.cpp.out
</output>
</expected>
<endpoint>http://localhost:80/Calculator/services/Calculator</endpoint>
</test>
example 1
Each of the XML tags in example 1 are detailed below.
BASEDIR/tests/auto_build/testcases/tests directory. The name is used as the name of the test client that is built, the name of the test output directory, and the name of the output files created as part of the test run.The example 2 shows all the optional tags that are available for handler tests.
<test>
<name>HandlerTest02</name>
<description>CalculatorDoc with Handler Chain</description>
<clientLang>cpp</clientLang>
<clientCode>CalculatorDocClient.cpp</clientCode>
<wsdl>CalculatorDoc.wsdl</wsdl>
<expected>
<output>
CalculatorDoc.cpp.out
</output>
<request>
HandlerTest2Request.out
</request>
</expected>
<handler>
<directory>
handler_test2
</directory>
<service>
Calculator
</service>
</handler>
<endpoint>http://localhost:80/Calculator/services/Calculator</endpoint>
</test>
example 2
The optional tags shown in example 2 are detailed below.
The example 3 shows all the additional tags that are available for tests.
<test>
<name>CalculatorDocSSL</name>
<description>CalculatorDoc using SSL</description>
<clientLang>cpp</clientLang>
<clientCode>CalculatorDocSSLClient.cpp</clientCode>
<wsdl>CalculatorDoc.wsdl</wsdl>
<expected>
<output>
CalculatorDoc.cpp.out
</output>
</expected>
<endpoint>https://localhost:80/Calculator/services/Calculator</endpoint>
<nomonitor>true</nomonitor>
<port>9443</port>
</test>
example 3
The optional tags shown in example 3 are detailed below.
The example 4 shows all the optional tags that are available for dynamic client tests (See Dynamic Clients).
<test>
<name>DynamicTest01</name>
<description>CalculatorDoc implemented as a dynamic client</description>
<dynamicCode>true</dynamicCode>
<dynamicCodeDirectory>Test01</dynamicCodeDirectory>
<clientLang>cpp</clientLang>
<wsdl>CalculatorDoc.wsdl</wsdl>
<expected>
<output>
CalculatorDoc.cpp.out
</output>
</expected>
<endpoint>http://localhost:80/Calculator/services/Calculator</endpoint>
</test>
example 4
The optional tags shown in example 4 are detailed below.
The expected output files, the request/response messages written by the TCP monitor utility and the output files (redirected stdout/stderr) written by the test client may be in different formats, e.g. DOS format or UNIX format or a combination of both. All the files used for comparison are first converted to the platform specific format of the machine the tests are being run on.
Additionally the expected request files will have host:port combination of the original request in the HTTP header information from when it was created. This information is altered to match the location of the TCP monitor utility.
If handlers have been specified in the test properties file for a test (See Test Properties Files), then the directory specified will have sub-directories matching the names of the libraries to be created. This will be the name of the library without any prefix or suffix. A prefix of lib is usual for UNIX systems, and a suffix could be .DLL, .so, or .sl depending on platform. If the sub-directory is called testhandler then this will create a library called testhandler.DLL on windows and libtesthandler.so on Linux. All the source code for the library will be in this sub-directory.
e.g.
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 5
handler_chain/testhandler
handler_chain/testhandler/TestHandler.cpp
handler_chain/testhandler/THandler.cpp
handler_chain/testhandler/THandler.h
handler_chain/testhandler2
handler_chain/testhandler2/TestHandler2.cpp
handler_chain/testhandler2/THandler2.h
handler_chain/testhandler2/THandler2.cpp
example 5
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.
The framework also creates the client.wsdd file required to invoke the handlers when the test is run and also updated the axiscpp.conf used by the test.
At present only <requestFlow ..> handlers are supported.
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 ws-axis/c/tests/auto_build/testcases/dynamic.
e.g.
In example 5 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 6.
Test01/Calculator.cpp
Test01/Calculator.hpp
example 6
usage: TCPMonitor <-l listen port> <-p forward port> <-h forward host> <-o request output file> [-r response output file]
The program will listen for all requests on the listen port and write them to a file. The program stays alive until a stop message is received so many requests for many services will be written to the same file if they are all sent to the same port.
usage: StopTCPMonitor <-p listen port> <-h host>
e.g. to run CalculatorDoc through the monitor
This will create 2 files in /tmp called request.out and response.out.
Created: 11/12/2004 13:23