spring-framework / org.springframework.mock.web / MockFilterChain

MockFilterChain

open class MockFilterChain : FilterChain

Mock implementation of the javax.servlet.FilterChain 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 an IllegalStateException unless #reset() is called.

Author
Juergen Hoeller

Author
Rob Winch

Author
Rossen Stoyanchev

Since
2.0.3

See Also
MockFilterConfigPassThroughFilterChain

Constructors

<init>

MockFilterChain()

Register a single do-nothing Filter implementation. The first invocation saves the request and response. Subsequent invocations raise an IllegalStateException unless #reset() is called.

MockFilterChain(servlet: Servlet)

Create a FilterChain with a Servlet.

MockFilterChain(servlet: Servlet, vararg filters: Filter)

Create a FilterChain with Filter's and a Servlet.

Functions

doFilter

open fun doFilter(request: ServletRequest, response: ServletResponse): Unit

Invoke registered Filters and/or Servlet also saving the request and response.

getRequest

open fun getRequest(): ServletRequest

Return the request that #doFilter has been called with.

getResponse

open fun getResponse(): ServletResponse

Return the response that #doFilter has been called with.

reset

open fun reset(): Unit

Reset the MockFilterChain allowing it to be invoked again.