# Installing HttpUnit

## Getting HttpUnit

### Releases

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 https://httpunit.svn.sourceforge.net/svnroot/httpunit 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:

    httpunit
       +--- 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 | www.apache.org/~andyc/neko/doc/html/index.html.
tidy.jar | HTML parsing. Very picky. Works with any jaxp-compliant parser. | lempinen.net/sami/jtidy/
xmlParserAPIs.jar | the generic parser APIs supported by xerces-j | xml.apache.org
xercesImpl.jar | the xerces-j 2.2 implementation | xml.apache.org
js.jar | javascript support | www.mozilla.org/rhino
servlet.jar | required for ServletUnit - unit testing of servlets | java.sun.com
junit.jar | running the unit tests. | www.junit.org
mail.jar | Testing the file upload capabilities - not used to run HttpUnit itself | java.sun.com/products/javamail/
activation.jar | Testing the file upload capabilities - not used to run HttpUnit itself | java.sun.com/products/javabeans/glasgow/jaf.html

## 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.