Definition

Cargo provides Ant tasks to perform all the operations available from the Java API

Functional tests

Icon

The usage of Cargo for executing functional tests on a container does not mandate these ANT tasks. You could directly use the Cargo Java API from your Java unit test classes (JUnit, TestNG, etc), as described on the Functional testing page.

Explanation

Before using the Ant API you need to register the Cargo Ant tasks into Ant. This is done in the following manner:

Some additional dependencies might also be required for the ANT task. Please see the Installation page for details.

If the task configuration contains one or more deployables, it will deploy these to the container automatically.

And, of course, start the container.

Note: A container that's started with the start task will automatically shut down as soon as the parent ANT instance quits (i.e., you see a BUILD SUCCESSFUL or BUILD FAILED message). If you want to start a container and perform manual testing, see our next task run.

run

Start a container and wait for the user to press CTRL + C to stop. That task will:

If the task configuration contains one or more deployables, it will deploy these to the container automatically.

And, of course, start the container and wait for the user to press CTRL + C to stop.

stop

Stop a container.

restart

Stop and start again a container. If the container was not running before calling restart, it will simply be started.

configure

Create the configuration for a local container, without starting it. Note that the start and run actions will also install the container automatically.

deploy

Deploy a deployable to a running container.

undeploy

Undeploy a deployable from a running container.

redeploy

Undeploy and deploy again a deployable. If the deployable was not deployed before calling redeploy, it will simply be deployed.

Wait after the container has started

Icon

Many wonder the difference between the start and run actions:

If you want to just start the container and then do other tasks (for example, execute tests), use the start action. That action should therefore ONLY be used for integration testing.

If you want start the container and have ANT "blocked" afterwards (i.e., until you press CTRL + C to stop), use the run action. run is therefore the action to use for manual testing.

Examples

Orion 2.x

Here's a full example showing how to deploy a WAR, and expanded WAR and an EAR in an Orion 2.x container. Please note that the output and log attribute are optional. The property elements allow you to tune how the container is configured. Here we're telling it to start on port 8180 and to generate the maximum amount of logs in the container output file.

Tomcat 5.x

This example gives a walk through of how to get a Cargo Ant build to work with Tomcat 5.x .