13.8. Testing Application Functionality
Problem
You want to verify that your application, deployed and running on an application server, does what it's supposed to do for a specific use case or scenario.
Solution
Use the JWebUnit acceptance testing framework.
Discussion
JWebUnit, an extension of the JUnit testing framework, leverages JUnit and Http-Unit for web application acceptance testing. JUnit provides the test harness and basic assertion methods, and HttpUnit (http://httpunit.sourceforge.net) provides a mechanism for programmatically sending requests and reading responses from a web application. JWebUnit exercises a running web application by programmatically sending requests, clicking links, filling out and submitting forms, and inspecting the response.
To get started with JWebUnit, download it from the project site, http://jwebunit.sourceforge.net. The source distribution includes everything you need; the JWebUnit Jar file, dependent Jar files, documentation, and the JWebUnit source code. Create a test directory structure in your application's project directory like that shown in Figure 13-10. You will need to copy the Jar files included with JWebUnit to your test/lib directory.

Figure 13-10. Project structure with "test" directory
The easiest way to create a new JWebUnit test class is to subclass
net.sourceforge.jwebunit.WebTestCase.
Tip
If you have been using your own extension ...