Package com.meterware.servletunit
Interface InvocationContext
-
public interface InvocationContextAn interface which represents the invocation of a servlet.- Author:
- Russell Gold
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description javax.servlet.FiltergetFilter()Returns the current active filter object.javax.servlet.FilterChaingetFilterChain()Returns the current filter chain.FrameSelectorgetFrame()Returns the target frame for the original request.javax.servlet.http.HttpServletRequestgetRequest()Returns the request to be processed by the servlet or filter.javax.servlet.http.HttpServletResponsegetResponse()Returns the response which the servlet or filter should modify during its operation.javax.servlet.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(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)Pushes the current filter onto the execution stack and switches to the next filter or the selected servlet.voidpushForwardRequest(javax.servlet.RequestDispatcher rd, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Adds a request dispatcher to this context to simulate a forward request.voidpushIncludeRequest(javax.servlet.RequestDispatcher rd, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Adds a request dispatcher to this context to simulate an include request.voidservice()Invokes the current servlet or filter.
-
-
-
Method Detail
-
getRequest
javax.servlet.http.HttpServletRequest getRequest()
Returns the request to be processed by the servlet or filter.
-
getResponse
javax.servlet.http.HttpServletResponse getResponse()
Returns the response which the servlet or filter should modify during its operation.
-
service
void service() throws javax.servlet.ServletException, java.io.IOExceptionInvokes the current servlet or filter.- Throws:
javax.servlet.ServletExceptionjava.io.IOException- Since:
- 1.6
-
getServlet
javax.servlet.Servlet getServlet() throws javax.servlet.ServletExceptionReturns the selected servlet, initialized to provide access to sessions and servlet context information. Only valid to call ifisFilterActive()returns false.- Throws:
javax.servlet.ServletException
-
getServletResponse
WebResponse getServletResponse() throws java.io.IOException
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.- Throws:
java.io.IOException
-
getFrame
FrameSelector getFrame()
Returns the target frame for the original request.- Since:
- 1.6
-
pushIncludeRequest
void pushIncludeRequest(javax.servlet.RequestDispatcher rd, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletExceptionAdds a request dispatcher to this context to simulate an include request.- Throws:
javax.servlet.ServletException
-
pushForwardRequest
void pushForwardRequest(javax.servlet.RequestDispatcher rd, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletExceptionAdds a request dispatcher to this context to simulate a forward request.- Throws:
javax.servlet.ServletException
-
popRequest
void popRequest()
Removes the top request dispatcher or filter from this context.
-
isFilterActive
boolean isFilterActive()
Returns true if the current context is a filter, rather than a servlet.- Since:
- 1.6
-
getFilter
javax.servlet.Filter getFilter() throws javax.servlet.ServletExceptionReturns the current active filter object. Only valid to call ifisFilterActive()returns true.- Throws:
javax.servlet.ServletException- Since:
- 1.6
-
getFilterChain
javax.servlet.FilterChain getFilterChain()
Returns the current filter chain. Only valid to call ifisFilterActive()returns true.- Since:
- 1.6
-
pushFilter
void pushFilter(javax.servlet.ServletRequest request, javax.servlet.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 thedoFiltercall.
Note: this method specifiesServletRequestandServletResponsebecause those are the types passed toFilter.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain); however, HttpUnit requires the objects to implementHttpServletRequestandHttpServletResponsebecause they will eventually be passed to anHttpServlet.- 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
-
-