com.meterware.servletunit

Interface InvocationContext

public interface InvocationContext

An interface which represents the invocation of a servlet.

Author: Russell Gold

Method Summary
FiltergetFilter()
Returns the current active filter object.
FilterChaingetFilterChain()
Returns the current filter chain.
FrameSelectorgetFrame()
Returns the target frame for the original request.
HttpServletRequestgetRequest()
Returns the request to be processed by the servlet or filter.
HttpServletResponsegetResponse()
Returns the response which the servlet or filter should modify during its operation.
ServletgetServlet()
Returns the selected servlet, initialized to provide access to sessions and servlet context information.
WebResponsegetServletResponse()
Returns the final response from the servlet.
booleanisFilterActive()
Returns true if the current context is a filter, rather than a servlet.
voidpopRequest()
Removes the top request dispatcher or filter from this context.
voidpushFilter(ServletRequest request, ServletResponse response)
Pushes the current filter onto the execution stack and switches to the next filter or the selected servlet.
voidpushForwardRequest(RequestDispatcher rd, HttpServletRequest request, HttpServletResponse response)
Adds a request dispatcher to this context to simulate a forward request.
voidpushIncludeRequest(RequestDispatcher rd, HttpServletRequest request, HttpServletResponse response)
Adds a request dispatcher to this context to simulate an include request.
voidservice()
Invokes the current servlet or filter.

Method Detail

getFilter

public Filter getFilter()
Returns the current active filter object. Only valid to call if {@link #isFilterActive} returns true.

Since: 1.6

getFilterChain

public FilterChain getFilterChain()
Returns the current filter chain. Only valid to call if {@link #isFilterActive} returns true.

Since: 1.6

getFrame

public FrameSelector getFrame()
Returns the target frame for the original request.

Since: 1.6

getRequest

public HttpServletRequest getRequest()
Returns the request to be processed by the servlet or filter.

getResponse

public HttpServletResponse getResponse()
Returns the response which the servlet or filter should modify during its operation.

getServlet

public Servlet getServlet()
Returns the selected servlet, initialized to provide access to sessions and servlet context information. Only valid to call if {@link #isFilterActive} returns false.

getServletResponse

public WebResponse getServletResponse()
Returns the final response from the servlet. Note that this method should only be invoked after all processing has been done to the servlet response.

isFilterActive

public boolean isFilterActive()
Returns true if the current context is a filter, rather than a servlet.

Since: 1.6

popRequest

public void popRequest()
Removes the top request dispatcher or filter from this context.

pushFilter

public void pushFilter(ServletRequest request, ServletResponse response)
Pushes the current filter onto the execution stack and switches to the next filter or the selected servlet. This can be used to simulate the effect of the {@link javax.servlet.FilterChain#doFilter doFilter} call.
Note: this method specifies {@link ServletRequest} and {@link ServletResponse} because those are the types passed to {@link Filter#doFilter}; however, HttpUnit requires the objects to implement {@link HttpServletRequest} and {@link HttpServletResponse} because they will eventually be passed to an {@link javax.servlet.http.HttpServlet}.

Parameters: request the request to pass to the next filter. May be a wrapper. response the response object to pass to the next filter. May be a wrapper.

Since: 1.6

pushForwardRequest

public void pushForwardRequest(RequestDispatcher rd, HttpServletRequest request, HttpServletResponse response)
Adds a request dispatcher to this context to simulate a forward request.

pushIncludeRequest

public void pushIncludeRequest(RequestDispatcher rd, HttpServletRequest request, HttpServletResponse response)
Adds a request dispatcher to this context to simulate an include request.

service

public void service()
Invokes the current servlet or filter.

Since: 1.6