java.lang.Object
com.meterware.httpunit.WebClient
com.meterware.servletunit.ServletUnitClient
- public class ServletUnitClient
- extends com.meterware.httpunit.WebClient
A client for use with the servlet runner class, allowing the testing of servlets
without an actual servlet container. Testing can be done in one of two ways.
End-to-end testing works much like the HttpUnit package, except that only servlets
actually registered with the ServletRunner will be invoked. It is also possible
to test servlets 'from the inside' by creating a ServletInvocationContext and then
calling any servlet methods which may be desired. Even in this latter mode, end-to-end
testing is supported, but requires a call to this class's getResponse method to update
its cookies and frames.
| Nested classes inherited from class com.meterware.httpunit.WebClient |
com.meterware.httpunit.WebClient.HeaderDictionary |
| Fields inherited from class com.meterware.httpunit.WebClient |
|
| Methods inherited from class com.meterware.httpunit.WebClient |
addClientListener, addCookie, addWindowListener, clearContents, clearProxyServer, getClientProperties, getCookieNames, getCookieValue, getCurrentPage, getExceptionsThrownOnErrorStatus, getFrameContents, getFrameContents, getFrameNames, getHeaderField, getHeaderFields, getMainWindow, getNextAlert, getOpenWindow, getOpenWindows, getProxyHost, getProxyPort, getResource, getResponse, getResponse, getUserAgent, popNextAlert, putCookie, removeClientListener, removeWindowListener, sendRequest, setAuthorization, setDialogResponder, setExceptionsThrownOnErrorStatus, setHeaderField, setMainWindow, setProxyServer, setProxyServer, setUserAgent, updateMainWindow, writeMessageBody |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_invocationContextFactory
private InvocationContextFactory _invocationContextFactory
ServletUnitClient
private ServletUnitClient(InvocationContextFactory factory)
newClient
public static ServletUnitClient newClient(InvocationContextFactory factory)
- Creates and returns a new servlet unit client instance.
newInvocation
public InvocationContext newInvocation(java.lang.String requestString)
throws java.io.IOException,
java.net.MalformedURLException
- Creates and returns a new invocation context from a GET request.
newInvocation
public InvocationContext newInvocation(com.meterware.httpunit.WebRequest request)
throws java.io.IOException,
java.net.MalformedURLException
- Creates and returns a new invocation context to test calling of servlet methods.
newInvocation
InvocationContext newInvocation(com.meterware.httpunit.WebRequest request,
com.meterware.httpunit.FrameSelector frame)
throws java.io.IOException,
java.net.MalformedURLException
getResponse
public com.meterware.httpunit.WebResponse getResponse(InvocationContext invocation)
throws java.net.MalformedURLException,
java.io.IOException,
org.xml.sax.SAXException
- Updates this client and returns the response which would be displayed by the
user agent. Note that this will typically be the same as that returned by the
servlet invocation unless that invocation results in a redirect request.
getSession
public javax.servlet.http.HttpSession getSession(boolean create)
- Returns the session that would be used by the next request (if it asks for one).
- Since:
- 1.6
newResponse
protected com.meterware.httpunit.WebResponse newResponse(com.meterware.httpunit.WebRequest request,
com.meterware.httpunit.FrameSelector targetFrame)
throws java.net.MalformedURLException,
java.io.IOException
- Creates a web response object which represents the response to the specified web request.