Installing HttpUnit

Getting HttpUnit


The latest release of HttpUnit is available from the HttpUnit project download page.
From time to time, pre-release versions are made available from the web site prerelease directory. Because HttpUnit is build test-first, these should usually be as stable as the releases; however, they are not tracked as closely and formally, and typically are only available for a relatively short time. Either form of distribution includes all source code and jars required to build the project.

Subversion access

If you prefer to see the very latest code, you can always obtain directly it from the Subversion/svn archive at svn co httpunit. Be sure to check out the httpunit module.

You can also access the svn repository online. See Building HttpUnit for instructions on building HttpUnit from the source code.

System Requirements

HttpUnit should run on any system that supports Java JDK 1.4 or higher.

Examining the Distribution

When you unpack the HttpUnit distribution, you should find the following directory layout:

   +--- jars // contains jars required to build, test, and run HttpUnit
   +--- lib  // contains the HttpUnit jar
   +--- doc  // contains documentation
   |      |
   |      +--- tutorial  // a brief tutorial in test-first development of a servlet-based web site
   |      |
   |      +--- api       // the javadoc
   |      |
   |      +--- manual    // this user manual
   +--- examples // some example programs written with HttpUnit
   +--- src      // the HttpUnit source code
   +--- test     // unit tests for HttpUnit - a good source for more examples
Only the lib and jars directories are required to run HttpUnit. You must have at least the HttpUnit jar in your classpath. Many of the other jars are optional. See the sext section, Understanding HttpUnit's dependencies for more information.

Understanding HttpUnit's dependencies

HttpUnit supports a number of optional capabilities. If you don't need them, you don't need the corresponding libraries in your classpath. At the minimum you must have an HTML parser (both JTidy and NekoHTML are supported) and a jaxp-compliant parser (xerces 2.2 is included in the distribution).

Jar Name Needed For Documented at
nekohtml.jar HTML parsing. Very tolerant of sloppy HTML. Requires xerces-j 2.2 or higher
tidy.jar HTML parsing. Very picky. Works with any jaxp-compliant parser.
xmlParserAPIs.jar the generic parser APIs supported by xerces-j
xercesImpl.jar the xerces-j 2.2 implementation
js.jar javascript support
servlet.jar required for ServletUnit - unit testing of servlets
junit.jar running the unit tests.
mail.jar Testing the file upload capabilities - not used to run HttpUnit itself
activation.jar Testing the file upload capabilities - not used to run HttpUnit itself

Building HttpUnit

By far the easiest way to build HttpUnit is by using ant. If you choose to build with less than the full set of jars, some classes will not compile. The included ant script handles this automatically for you, selecting only those that are appropriate. If you have ant installed, simply go to the main httpunit installation directory and type:

ant jar
to build the httpunit jar using any classes available in the jars directory. You can then verify your installation by running one of the examples. The command
ant run-example
will compile the examples and run the simplest of them, going to the Meterware web site and following a link to the main HttpUnit site. If all is working properly, it should print out a message telling you the number of links it found there.

Copyright © 2000-2007 Russell Gold. All rights Reserved.