com.meterware.servletunit
Interface InvocationContext


public interface InvocationContext

An interface which represents the invocation of a servlet.

Author:
Russell Gold

Method Summary
 javax.servlet.Filter getFilter()
          Returns the current active filter object.
 javax.servlet.FilterChain getFilterChain()
          Returns the current filter chain.
 FrameSelector getFrame()
          Returns the target frame for the original request.
 javax.servlet.http.HttpServletRequest getRequest()
          Returns the request to be processed by the servlet or filter.
 javax.servlet.http.HttpServletResponse getResponse()
          Returns the response which the servlet or filter should modify during its operation.
 javax.servlet.Servlet getServlet()
          Returns the selected servlet, initialized to provide access to sessions and servlet context information.
 WebResponse getServletResponse()
          Returns the final response from the servlet.
 boolean isFilterActive()
          Returns true if the current context is a filter, rather than a servlet.
 void popRequest()
          Removes the top request dispatcher or filter from this context.
 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.
 void pushForwardRequest(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.
 void pushIncludeRequest(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.
 void service()
          Invokes the current servlet or filter.
 

Method Detail

getRequest

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


getResponse

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


service

public void service()
             throws javax.servlet.ServletException,
                    java.io.IOException
Invokes the current servlet or filter.

Throws:
javax.servlet.ServletException
java.io.IOException
Since:
1.6

getServlet

public javax.servlet.Servlet getServlet()
                                 throws javax.servlet.ServletException
Returns the selected servlet, initialized to provide access to sessions and servlet context information. Only valid to call if isFilterActive() returns false.

Throws:
javax.servlet.ServletException

getServletResponse

public 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

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

Since:
1.6

pushIncludeRequest

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

Throws:
javax.servlet.ServletException

pushForwardRequest

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

Throws:
javax.servlet.ServletException

popRequest

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


isFilterActive

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

Since:
1.6

getFilter

public javax.servlet.Filter getFilter()
                               throws javax.servlet.ServletException
Returns the current active filter object. Only valid to call if isFilterActive() returns true.

Throws:
javax.servlet.ServletException
Since:
1.6

getFilterChain

public javax.servlet.FilterChain getFilterChain()
Returns the current filter chain. Only valid to call if isFilterActive() returns true.

Since:
1.6

pushFilter

public 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 the doFilter call.
Note: this method specifies ServletRequest and ServletResponse because those are the types passed to Filter.doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain); however, HttpUnit requires the objects to implement HttpServletRequest and HttpServletResponse because they will eventually be passed to an 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

Copyright © 2000-2008 Russell Gold. See license agreement for rights granted.