In order to run Cactus tests from a browser you need to have a webapp
containing your classes to test and your test classes. In addition,
both Cactus client side and server side jar classes must be able to be
loaded from your webapp (i.e located in your
directory or in a location available through your container Context
class loader (refer to your container documentation).
Then, in addition to the Cactus redirectors that you have mapped in
web.xml (see the
Configuration howto), you also
need to map the Cactus Servlet Test Runner, as follows:
[...] <servlet> <servlet-name>ServletTestRunner</servlet-name> <servlet-class> org.apache.cactus.server.runner.ServletTestRunner </servlet-class> </servlet> [...] <servlet-mapping> <servlet-name>ServletTestRunner</servlet-name> <url-pattern>/ServletTestRunner</url-pattern> </servlet-mapping> [...]
Open a browser and type
server:portis the name of your server machine and port on which your container is running
mywebappis the name of your webapp (usually the name of your war file)
mytestcaseis the fully qualified name (i.e. with packages) of your
TestCaseclass containing a
suite()method listing all the tests, in standard JUnit fashion.
cactus-report.xsl(in the root directory for example). Then, open a browser and type
http://server:port/mywebapp/ServletTestRunner?suite=mytestcase&xsl=cactus-report.xsl. You should see the following:
In the previous section, the XSLT transformation was performed on the client. This requires a browser capable of doing XSLT transformations in a standards-compliant manner, and requires adding the location of the stylesheet as a request parameter.
Since Cactus 1.5, the ServletTestRunner can also perform the transformation on the server-side. To enable that feature, make sure that a JAXP compliant XSLT processor (such as Xalan) is available to the web-application.
In addition, the location of the XSLT stylesheet needs to specified as initialization parameter of the ServletTestRunner. For example:
[...] <servlet> <servlet-name>ServletTestRunner</servlet-name> <servlet-class> org.apache.cactus.server.runner.ServletTestRunner </servlet-class> <init-param> <param-name>xsl-stylesheet</param-name> <param-value>styles/cactus-report.xsl</param-value> </init-param> </servlet> [...]
The specified path is relative to the root of the web-application. Of
course, the stylesheet needs to exist at that location. In contrast to
client-side transformations, the stylesheet may be placed somewhere
WEB-INF directory, because clients do not need
to access it directly.
If all of the above is correctly set up, you can enable the actual
transformation by including a
transform parameter with
the request (the value of the parameter does not matter). For example