类 MockFilterChain
- java.lang.Object
- org.springframework.mock.web.MockFilterChain
- 所有已实现的接口:
FilterChain
public class MockFilterChain extends Object implements FilterChain
Mock implementation of theFilterChain
interface.A
MockFilterChain
can be configured with one or more filters and a Servlet to invoke. The first time the chain is called, it invokes all filters and the Servlet, and saves the request and response. Subsequent invocations raise anIllegalStateException
unlessreset()
is called.- 从以下版本开始:
- 2.0.3
- 作者:
- Juergen Hoeller, Rob Winch, Rossen Stoyanchev
- 另请参阅:
MockFilterConfig
,PassThroughFilterChain
构造器概要
构造器 构造器 说明 MockFilterChain()
Register a single do-nothingFilter
implementation.MockFilterChain(Servlet servlet)
Create a FilterChain with a Servlet.MockFilterChain(Servlet servlet, Filter... filters)
Create aFilterChain
with Filter's and a Servlet.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
doFilter(ServletRequest request, ServletResponse response)
ServletRequest
getRequest()
Return the request thatdoFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
has been called with.ServletResponse
getResponse()
Return the response thatdoFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
has been called with.void
reset()
Reset theMockFilterChain
allowing it to be invoked again.
构造器详细资料
MockFilterChain
public MockFilterChain()
Register a single do-nothingFilter
implementation. The first invocation saves the request and response. Subsequent invocations raise anIllegalStateException
unlessreset()
is called.
MockFilterChain
public MockFilterChain(Servlet servlet)
Create a FilterChain with a Servlet.- 参数:
servlet
- the Servlet to invoke- 从以下版本开始:
- 3.2
MockFilterChain
public MockFilterChain(Servlet servlet, Filter... filters)
Create aFilterChain
with Filter's and a Servlet.- 参数:
servlet
- theServlet
to invoke in thisFilterChain
filters
- theFilter
's to invoke in thisFilterChain
- 从以下版本开始:
- 3.2
方法详细资料
getRequest
public ServletRequest getRequest()
Return the request thatdoFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
has been called with.
getResponse
public ServletResponse getResponse()
Return the response thatdoFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
has been called with.
doFilter
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException
- 指定者:
doFilter
在接口中FilterChain
- 抛出:
IOException
ServletException
reset
public void reset()
Reset theMockFilterChain
allowing it to be invoked again.