com.mockrunner.mock.web
Class MockFilterChain

java.lang.Object
  extended by com.mockrunner.mock.web.MockFilterChain
All Implemented Interfaces:
javax.servlet.FilterChain

public class MockFilterChain
extends java.lang.Object
implements javax.servlet.FilterChain

Mock implementation of FilterChain.


Constructor Summary
MockFilterChain()
           
 
Method Summary
 void addFilter(java.lang.Class filterClass)
          Adds a filter to the chain.
 void addFilter(javax.servlet.Filter filter)
          Adds a filter to the chain.
 void doFilter(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)
           
 javax.servlet.ServletRequest getLastRequest()
          Returns the last request, usually the request that was used to call the final servlet.
 javax.servlet.ServletResponse getLastResponse()
          Returns the last response, usually the response that was used to call the final servlet.
 java.util.List getRequestList()
          Returns the list of all request objects used to call doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse) when iterating through the chain.
 java.util.List getResponseList()
          Returns the list of all response objects used to call doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse) when iterating through the chain.
 void release()
          Clears all filters and sets the current servlet to null.
 void reset()
          Resets the internal iterator of this chain.
 void setServlet(javax.servlet.Servlet servlet)
          Sets the servlet that is called at the end of the chain.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockFilterChain

public MockFilterChain()
Method Detail

doFilter

public void doFilter(javax.servlet.ServletRequest request,
                     javax.servlet.ServletResponse response)
              throws java.io.IOException,
                     javax.servlet.ServletException
Specified by:
doFilter in interface javax.servlet.FilterChain
Throws:
java.io.IOException
javax.servlet.ServletException

reset

public void reset()
Resets the internal iterator of this chain.


addFilter

public void addFilter(javax.servlet.Filter filter)
Adds a filter to the chain.

Parameters:
filter - the filter

addFilter

public void addFilter(java.lang.Class filterClass)
Adds a filter to the chain. The filter must implement javax.servlet.Filter.

Parameters:
filterClass - the filter class
Throws:
java.lang.IllegalArgumentException - if the specified class does not implement javax.servlet.Filter

setServlet

public void setServlet(javax.servlet.Servlet servlet)
Sets the servlet that is called at the end of the chain.

Parameters:
servlet - the servlet

release

public void release()
Clears all filters and sets the current servlet to null.


getRequestList

public java.util.List getRequestList()
Returns the list of all request objects used to call doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse) when iterating through the chain.

Returns:
the request list

getResponseList

public java.util.List getResponseList()
Returns the list of all response objects used to call doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse) when iterating through the chain.

Returns:
the response list

getLastRequest

public javax.servlet.ServletRequest getLastRequest()
Returns the last request, usually the request that was used to call the final servlet. Returns null if no request is specified, e.g. if the chain wasn't called. Otherwise returns the last entry of the list returned by getRequestList().

Returns:
the last request

getLastResponse

public javax.servlet.ServletResponse getLastResponse()
Returns the last response, usually the response that was used to call the final servlet. Returns null if no response is specified, e.g. if the chain wasn't called. Otherwise returns the last entry of the list returned by getResponseList().

Returns:
the last response