![]() | ![]() |
Apache > Jakarta > Cactus > Running Tests > Ant | Docs for: v1.7.1 | v1.7 Last update: September 2 2005 |
CactifyWar TaskThe task cactifywar allows the enhancement of an existing web-application archive (WAR) with the elements needed to run Cactus in-container tests. This includes adding the definitions of the test redirectors to the deployment descriptor, as well as adding the libraries that Cactus requires on the server side (see the Classpath Guide for details).
If you want to use the
HttpUnit integration in your
tests, you'll need to explicitly add the
httpunit.jar to
the cactified WAR. You can easily do this by using a nested
<lib> element.
The cactifywar task extends the built-in Ant task war, so it also supports all attributes and nested elements that war supports. ParametersAs this task is an extension of the war task, it also supports all the attributes supported by the war task. The only exception is the warfile attribute, which has been renamed to destfile for the cactifywar task.
Nested ElementsAs this task is an extension of the war task, it also supports all attributes that the war task supports. In addition, you can specify the URL-patterns to map the Cactus test redirectors to which the nested elements filterredirector, jspredirector and servletredirector. If you don't specify those elements, the test redirectors will be mapped to the default URL-pattern. filterredirectorThe filterredirector element lets you specify the URL pattern to which the Cactus filter test redirector is mapped in the web application. Parameters
This element will be ignored for Servlet 2.2 web applications.
jspredirectorThe jspredirector element lets you specify the URL pattern to which the Cactus JSP test redirector is mapped in the web application. Parameters
servletredirectorThe servletredirector element lets you specify the URL pattern to which the Cactus servlet test redirector is mapped in the web application. Parameters
xmlcatalog
The
The cactifywar task resolves the DTDs of web-app
descriptors (version 2.2 as well as 2.3) automatically to copies
stored in the JAR. So normally, you shouldn't need to specify a
nested
xmlcatalog element. Further, actually
specifying it will disable the default behaviour, and you'll need
to provide the web-app DTDs yourself.
ExamplesThe following example demonstrates the simplest-possible use of the task. It will add the redirectors with the default mappings to the cactified WARs, as well as the Cactus libraries and the JSP page needed for the JSP redirector. <cactifywar srcfile="${build.dir}/my.war" destfile="${build.dir}/test.war"/> The next example demonstrates how to modify the mappings of the redirectors. <cactifywar srcfile="${build.dir}/my.war" destfile="${build.dir}/test.war"> <filterredirector mapping="/test/filterRedirector"/> <jspredirector mapping="/test/jspRedirector"/> <servletredirector mapping="/test/servletRedirector"/> </cactifywar> In the following example, we add the test classes as well as the HttpUnit library to the cactified WAR. <cactifywar srcfile="${build.dir}/my.war" destfile="${build.dir}/test.war"> <classes dir="${build.dir}/classes/test" includes="**/*.class"/> <lib file="${httpunit.jar}"/> </cactifywar> In the next example, we add a security-constrained instance of the servlet redirector to be able to run tests using authentication (see Using Authentication for details). Note that you need to provide an empty servlet redirector element, so that the default redirector is included along side the secured redirector (it would just be overridden otherwise). <cactifywar srcfile="${build.dir}/my.war" destfile="${build.dir}/test.war"> <servletredirector/> <servletredirector name="ServletRedirectorSecure" mapping="/ServletRedirectorSecure" roles="test"/> </cactifywar> |