public class MockRequestDispatcher extends Object implements RequestDispatcher
RequestDispatcher
interface.
Used for testing the web framework; typically not necessary for testing application controllers.
ERROR_EXCEPTION, ERROR_EXCEPTION_TYPE, ERROR_MESSAGE, ERROR_REQUEST_URI, ERROR_SERVLET_NAME, ERROR_STATUS_CODE, FORWARD_CONTEXT_PATH, FORWARD_PATH_INFO, FORWARD_QUERY_STRING, FORWARD_REQUEST_URI, FORWARD_SERVLET_PATH, INCLUDE_CONTEXT_PATH, INCLUDE_PATH_INFO, INCLUDE_QUERY_STRING, INCLUDE_REQUEST_URI, INCLUDE_SERVLET_PATH
Constructor and Description |
---|
MockRequestDispatcher(String resource)
Create a new MockRequestDispatcher for the given resource.
|
Modifier and Type | Method and Description |
---|---|
void |
forward(ServletRequest request,
ServletResponse response) |
protected MockHttpServletResponse |
getMockHttpServletResponse(ServletResponse response)
Obtain the underlying
MockHttpServletResponse , unwrapping
HttpServletResponseWrapper decorators if necessary. |
void |
include(ServletRequest request,
ServletResponse response) |
public MockRequestDispatcher(String resource)
resource
- the server resource to dispatch to, located at a
particular path or given by a particular namepublic void forward(ServletRequest request, ServletResponse response)
forward
in interface RequestDispatcher
public void include(ServletRequest request, ServletResponse response)
include
in interface RequestDispatcher
protected MockHttpServletResponse getMockHttpServletResponse(ServletResponse response)
MockHttpServletResponse
, unwrapping
HttpServletResponseWrapper
decorators if necessary.