2011/08/05 - Jakarta Cactus has been retired.

For more information, please explore the Attic.

CactifyWar MOJO

The mojo 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 specifying it as a <libDependencies> element.

Parameters

Here is a list of all the parameters that can be specified to the cactifywar plugin.

Name Description Required
destFile The location and name of the cactified web-application archive to create. Yes
srcFile The original web-application archive that is going to be cactified. Yes
mergeWebXml Allows the specification of a web deployment descriptor whose content will get merged into the resulting descriptor. This is only required for purposes like adding special security constraints for testing, as the Cactus test redirectors will be added to the cactified deployment descriptor anyway. The merging of the descriptors is based on the same principles as used by the webxmlmerge task. No
version The version of the web application archive to create if no source archive has been specified with the srcfile attribute. Can be either 2.2 or 2.3. No, unless the srcfile attribute is omitted

Nested Elements

Here is a list of all the nested elements that you can use with the cactifywar plugin.

Name Description Required
libDependencies The artifacts that you want to include in the WEB-INF/lib folder of the archive that you create. The dependencies that you specify here with <groupId> and <artifactId> must be specified as a project dependencies. No
redirectors This allows you to specify custom redirector definitions. Inside the this element you can specify any of the following: <servletRedirector>, <filterRedirector>, <jspRedirector>. Each one of these can get any of the following attributes: name, mapping, roles. No

Examples

The following example demonstrates the simplest-possible use of the plugin. You have to add the following plugin definition inside your <build> definition of your pom.xml. 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.

<plugin>
   <groupId>org.apache.cactus</groupId>
   <artifactId>cactus.integration.maven2</artifactId>
   <version>1.8.1-SNAPSHOT</version>
   <configuration>
      <srcFile>target/cactus-maven2-test-1.0-SNAPSHOT.war</srcFile>
      <destFile>cactifiedByMaven2.war</destFile>
   </configuration>
</plugin>

The next example demonstrates how to modify the mappings of the redirectors.

<plugin>
   <groupId>org.apache.cactus</groupId>
   <artifactId>cactus.integration.maven2</artifactId>
   <version>1.8.1-SNAPSHOT</version>
   <configuration>
      <srcFile>target/cactus-maven2-test-1.0-SNAPSHOT.war</srcFile>
      <destFile>cactifiedByMaven2.war</destFile>
      <redirectors>
         <servletRedirector>
            <name>ServletRedirectorSecure</name>
            <mapping>/ServletRedirectorSecure</mapping>
            <roles>test</roles>
        </servletRedirector>
        <filterRedirector>
           <name>FilterRedirector</name>
           <mapping>/test/filterRedirector</mapping>
        </filterRedirector>
     </redirectors>  
   </configuration>
</plugin>        

In the following example, we add the HttpUnit library to the cactified WAR. (Note that you have to add it explicitly in the project dependecies also)

<plugin>
   <groupId>org.apache.cactus</groupId>
   <artifactId>cactus.integration.maven2</artifactId>
   <version>1.8.1-SNAPSHOT</version>
   <configuration>
      <srcFile>target/cactus-maven2-test-1.0-SNAPSHOT.war</srcFile>
      <destFile>cactifiedByMaven2.war</destFile>
      <libDependencies>
         <dependency>
            <groupId>httpunit</groupId>
            <artifactId>httpunit</artifactId>
         </dependency>
     </libDependencies> 
   </configuration>
</plugin>           

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).

<plugin>
   <groupId>org.apache.cactus</groupId>
   <artifactId>cactus.integration.maven2</artifactId>
   <version>1.8.1-SNAPSHOT</version>
   <configuration>
      <srcFile>target/cactus-maven2-test-1.0-SNAPSHOT.war</srcFile>
      <destFile>cactifiedByMaven2.war</destFile>
      <redirectors>
         <servletRedirector>
            <name>ServletRedirectorSecure</name>
            <mapping>/ServletRedirectorSecure</mapping>
            <roles>test</roles>
        </servletRedirector>
        <servletRedirector/>
     </redirectors>  
   </configuration>
</plugin>