Cargo is hip project that automates container management in a generic fashion, such that the same API used to deploy a WAR file to Tomcat can also start and stop JBoss. Cargo can also download and install a container automatically (which happens to be one of my all time favorite features!). You can leverage Cargo’s API in a few different fashions, ranging from Java code to Ant tasks to Maven goals.

What’s more, leveraging Cargo takes care of one of the major challenges to writing logically repeatable tests. With Cargo in hand, you can construct a build that automatically:

  1. Downloads a desired container
  2. Installs that container
  3. Starts the container
  4. Deploys a selected WAR (or EAR) file to the container

At a later point, you can also have Cargo stop a selected container, baby! Note — this process makes no assumptions regarding where a container is installed or even if it is installed; thus, a hip testing process can proceed regardless of environment.

Yet, step 2 from above can be somewhat of an issue if your build sits on a network that happens to require a proxy (that is, Cargo won’t be able to download a particular container if the download file resides outside your network). After some poking around on Cargo’s website and Cargo’s source code, I was able to ascertain that the Ant task does support a proxy element as a part of the zipurlinstaller element like so:

<pre class="prettyprint"><code><zipurlinstaller installurl="<a href="https://.../apache-tomcat-5.5.27.zip">https://.../apache-tomcat-5.5.27.zip</a>">
 <proxy host="proxy.acme.com" port="80" user="5555" password="8AO" />
</zipurlinstaller>

When it comes to crafting repeatable tests (regardless of which testing framework you use, by the way), I find that Cargo is indispensable — give it a try and you’ll know why! Can you dig it, man?

You can now follow The Disco Blog on Twitter, baby!
andrew_glover

When Andrew Glover isn't listening to “Funkytown” or “Le Freak” he enjoys speaking on the No Fluff Just Stuff Tour. He also writes articles for multiple online publications including IBM's developerWorks and O'Reilly’s ONJava and ONLamp portals. Andrew is also the co-author of Java Testing Patterns, which was published by Wiley in September 2004; Addison-Wesley’s Continuous Integration; and Manning’s Groovy in Action.

More from this author