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

For more information, please explore the Attic.

Introduction

This tutorial explains where to get Cactus samples and how to use them.

There are some samples available as part of the documentation. The samples depend on the kind of test case you are writing (Servlet, Taglibs, Filters, ...). For this reason you'll find some samples in the TestCase Howto tutorial.

However, the majority of Cactus samples are in the form of source samples. These samples are part of the Cactus distribution that you have downloaded (in the samples directory).

The following section explains how to execute the Cactus Samples using Ant or Maven2(the Maven2 execution only calls the Ant execution). If you wish to integrate them in your own build system or in your favorite IDE, you'll have to understand the principles first and manually install them (read the Getting Started and the Configuration Howto tutorials). Some detailed explanations for IDE integration are also available in the IDE Howto tutorial.

Running the Cactus Samples using Ant

Prerequisites

You need to install the following items prior to building the Cactus Sample application:

  • A JVM (1.2 or above),
  • You don't need a servlet engine any more, since Cactus in integrated with Cargo and now Cargo tries to download a servlet container for you.
  • Ant (see the "Installing Ant" tutorial).
  • Ivy for copying the dependencies from the m2 repository. The installation of Ivy is pretty straight-forward: simply place the two Ivy jars(ivy-[version].jar and ivy-core[version].jar) in the ANT_HOME/lib directory.
  • Maven2 for getting the dependencies.

Installing the Cactus Sample

Follow these steps:
  • Download the Cactus Sample and unzip it in a directory. Let's call the [downloaded_directory]/samples directory sampleroot.

Running the samples

Open a shell, cd to the sampleroot directory and select which samples you want to run. To run all of the dependencies type in sampleroot the following: mvn install. If you want to run just one type of samples, cd to the corresponding directory and type agsain mvn install. What will happen is that Maven will get all of the dependencies(approximately 10-15 min.) and then will invoke Ant to execute the tests. Ant will call Cargo to get the container that is needed to execute the tests in (approximately 5-10 min.) and will execute the tests (approximately 2-3 mins.) As you can see the majority of time is spent on getting the dependencies and the containers. Hopefully this is done only one time(dependencies) or until you call mvn clean(containers).