Using Ant to test Concurrency

October 01, 2003

Apache Ant is an awesome tool for creating batch builds, and doing all sorts of automated tasks. It was designed to replace make files, but you can use it for lots of things, as my example will show. Ant uses an XML language, with tasks (tags) to compile java classes, run java classes, manipulate the file system, create zip or tar.gz files, run SQL statements, XSL, FTP, etc. It also has an extensible API so there are tasks to do pretty much anything you would like to automate. We use ant at CFDEV to package our products into zip files, encrypt CFM templates, create multiple versions, and even upload the distribution files to our server - all in one step!

To get started check out the Ant Manual

One Ant task that I have found useful recently for testing concurrency is that parallel task. It allows you to run several ant tasks within their own thread. I was using this to test some java code but you could also use it to test a web site.

Here's a code sample testing concurrent requests.

<?xml version='1.0'?>
<project name="Concurrent" default="test" basedir=".">
	<target name="test">
			<get src="" dest="1.html" />
			<get src="" dest="2.html" />
			<get src="" dest="3.html" />
			<get src="" dest="4.html" />
			<get src="" dest="5.html" />

Save the above contents in a file called build.xml and run the file by browsing the directory you saved it in with your shell, and typing ant (after installing ant ofcourse). You can add more concurrent threads just by adding more get tags.

5 people found this page useful, what do you think?


Any chance you could post some hints about your build.xml file? We are looking to move in this direction and any help would be greatly appreciated.

Post a Comment


Spell Checker by Foundeo

Recent Entries


did you hack my cf?