|
Broken Links Retrieval: 2- Installing and testing HttpUnit
par Lionel
|
Part 2- Installing and testing HttpUnit
We assume that you have a Java Development Kit installed. We use J2SE
1.4 (Standard Edition) from Sun. Domino uses a different version but
in that case it does not make a difference. The programs we developped
work in both versions.
1. Installing HttpUnit
Go to the project's
home page or to the download
zone. The latest relase is 1.5.1 and the file you should download
is httpunit-1.5.1.zip.
After the download completes, extract the file in any directory you want.
Let's say, c:\httpunit.
2. Creating a working directory
If you don't want to loose time on deploying the required files, the
most simple thing to do is to create a working directory (let's say c:\myhttp)
and copy in this working directory all .jar files that you find
in c:\HttpUnit 's subdirectories (\jars and \lib).
js.jar
junit.jar
nekohtml.jar
servlet.jar
Tidy.jar
xercesImpl.jar
xmlParserAPIs.jar
httpunit.jar (from c:\HttpUnit\lib)
You should also copy the Notes.jar file. We will use it later to access
Notes databases.
You will create your programs in this directory. Many free and commercial
IDEs are available: Ellipse, NetBeans, ... I prefer to use a simple text
editor. I warmly recommend the Crimson
Editor.
3. Compiling and executing
I always control compilation and execution from a Command session. If
you use a sophisticated IDE such as Eclipse, you should be able to use
a "Run" command somewhere in a menu. If you prefer the Command
line, simply go to your working directory (cd c:\httputils) and do the
following:
- To compile your programs, type the following command line:
javac -classpath .;Notes.jar;httpunit.jar;junit.jar;js.jar;Tidy.jar;xercesImpl.jar;xmlParserAPIs.jar
MonProgram.java
where MonProgram.java is the file name that contains the Java code. I
have automated this command line by creating a .BAT file.
The compilation creates a .class file.
- To execute your programs, type the following:
java -cp .;Notes.jar;httpunit.jar;junit.jar;Tidy.jar;xercesImpl.jar;xmlParserAPIs.jar
MonProgram
where MonProgram is the name of the Java program (do not add the extensions
.class or .java)
Note: I have removed js.jar from the Java execution. For a reason that
I ignore, this class generates run time errors.
4. Testing
HttpUnit comes with some examples that you can use for testing purposes.
Simply copy the file examples\example.java in your working directory.
Then compile and execute it using the command line detailed in the previous
chapter.
If you have a proxy server, you should get the following error message:
Exception: java.net.UnknownHostException:
www.meterware.com
otherwise the program should display the following output:
Rhino classes (js.jar) not found
- Javascript disabled
line 57 column 22 - Error: is not recognized! This document
has errors that must be fixed before using HTML Tidy to generate a tidied
up version.
The HttpUnit main page contains 17 links
In both cases, the output means you have a correct working environment.
Now we have a full functional environment. It's time to start coding
our Java application.
|