This class provides a mock implementation of a Wicket HTTP based tester that can be used for testing. It emulates all of the functionality of an HttpServlet in a controlled, single-threaded environment. It is supported with mock objects for WebSession, HttpServletRequest, HttpServletResponse and ServletContext.
In its most basic usage you can just create a new MockWebApplication and provide your Wicket Application object. This should be sufficient to allow you to construct components and pages and so on for testing. To use certain features such as localization you must also call setupRequestAndResponse().
The tester takes an optional path attribute that defines a directory on the disk which will correspond to the root of the WAR bundle. This can then be used for locating non-tester resources.
To actually test the processing of a particular page or component you can also call processRequestCycle() to do all the normal work of a Wicket request.
Between calling setupRequestAndResponse() and processRequestCycle() you can get hold of any of the objects for initialization. The servlet request object has some handy convenience methods for Initializing the request to invoke certain types of pages and components.
After completion of processRequestCycle() you will probably just be testing component states. However, you also have full access to the response document (or binary data) and result codes via the servlet response object.
IMPORTANT NOTES
- This harness is SINGLE THREADED - there is only one global session. For multi-threaded testing you must do integration testing with a full tester server.
@author Chris Turner