Forewords

If you want to quickly get a feeling of Cactus, there is a 20 minutes tutorial that take you through running your first Cactus test using Tomcat. It doesn't explain how Cactus works or any other details but let's you have something running quickly.

We suggest you take this quicky tutorial and then come back here and continue reading below. You would have had a first glimpse of Cactus in action and will be ready to understand the concepts behind it and its full power.

Installing Cactus

There is not really an installation of Cactus per see, as Cactus is not an application but a framework. However you do need to understand how it integrates in your working environment. Thus, installing Cactus simply means to understand what jars need to be put where and what are the configuration files you need to have and edit. This is discussed below.

There are 2 kinds of productivity environments in which you may want to use Cactus, mainly:

  • within your IDE,
  • from the command line, using Ant
Usually, these 2 environments are complementary. A good strategy is to use an IDE to increase day to day productivity, run quickly the Cactus tests in the IDE and use Ant to perform the (continuous) builds (including running the Cactus tests).

System Requirements

In order to run Cactus tests you need to have the following software already installed on your system:

  • Java Virtual Machine A Java 1.2 or greater compatible virtual machine must be present. Note that all servlet engines require a JVM to run so if you are already using servlets you already have one installed.
  • Servlet Engine A Servlet 2.x compliant servlet engine (where x >= 2.2) for running your Cactus tests must be present.
  • Ant (optional) Ant is only needed if you are working from the command line or if you wish to automate the execution of tests. If you wish to use Ant, make sure that you read the Ant Howto after you finish reading this introductory guide.

The Cactus files

At this point, you should have downloaded a Cactus distribution (for the J2EE API you intend to use) and unzipped it in a [cactus root] directory.

The jars making up Cactus can be found in [cactus root]/lib. Namely, they are:

  • cactus.jar: the main jar, contains the framework classes. You can find this jar in [cactus root]/lib.
  • cactus-ant.jar: a jar which contains some custom Ant tasks to help integrate easily with Ant. This is only needed if you wish to use Ant for automating the execution of Cactus tests. For more information on how to integrate Cactus with Ant, see the Ant Howto tutorial. You also find this jar in [cactus root]/lib.
  • httpclient.jar: Cactus is relying on the Jakarta Commons HttpClient framework for Cookie handling.
  • junit.jar: Cactus extends JUnit and thus needs the JUnit jar.
  • aspectjrt.jar: Cactus uses AspectJ for performing several tasks (logging entries and exit of methods, checking configuration, etc).
  • commons-logging.jar: Cactus uses the Jakarta Commons Logging facade framework to provide seamless Cactus logging using any existing Logging framework (Log4j, LogKit, JDK 1.4 Logging, etc). It is also needed for Commons HttpClient.
  • logging framework(optional): The logging framework to use (Log4j jar, LogKit jar, etc). It is optional as it is only needed for internal Cactus logging and in addition, the Commons Logging framework provides a simple logger that logs on the console.

The Cactus configuration files are described in the Configuration Howto tutorial.

What's next?

At this point you should understand what Cactus is and how it works.

The next step is to understand how to set up Cactus in your environment. For this you'll need to understand How to setup Cactus classpaths and start Cactus tests and How to configure Cactus.

Then, you should read the TestCase Howto to understand how to write Cactus Test Cases.

The last step is probably to put in practice what you've learned so far by running the Cactus Samples.

Enjoy !