Package org.springframework.mock.web
Class MockFilterConfig
- java.lang.Object
- org.springframework.mock.web.MockFilterConfig
- All Implemented Interfaces:
FilterConfig
public class MockFilterConfig extends Object implements FilterConfig
Mock implementation of theFilterConfig
interface.Used for testing the web framework; also useful for testing custom
Filter
implementations.- Since:
- 1.0.2
- Author:
- Juergen Hoeller
- See Also:
MockFilterChain
,PassThroughFilterChain
Constructor Summary
Constructors Constructor Description MockFilterConfig()
Create a new MockFilterConfig with a defaultMockServletContext
.MockFilterConfig(String filterName)
Create a new MockFilterConfig with a defaultMockServletContext
.MockFilterConfig(ServletContext servletContext)
Create a new MockFilterConfig.MockFilterConfig(ServletContext servletContext, String filterName)
Create a new MockFilterConfig.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addInitParameter(String name, String value)
String
getFilterName()
Returns the filter-name of this filter as defined in the deployment descriptor.String
getInitParameter(String name)
Returns aString
containing the value of the named initialization parameter, ornull
if the initialization parameter does not exist.Enumeration<String>
getInitParameterNames()
Returns the names of the filter's initialization parameters as anEnumeration
ofString
objects, or an emptyEnumeration
if the filter has no initialization parameters.ServletContext
getServletContext()
Returns a reference to theServletContext
in which the caller is executing.
Constructor Detail
MockFilterConfig
public MockFilterConfig()
Create a new MockFilterConfig with a defaultMockServletContext
.
MockFilterConfig
public MockFilterConfig(String filterName)
Create a new MockFilterConfig with a defaultMockServletContext
.- Parameters:
filterName
- the name of the filter
MockFilterConfig
public MockFilterConfig(@Nullable ServletContext servletContext)
Create a new MockFilterConfig.- Parameters:
servletContext
- the ServletContext that the servlet runs in
MockFilterConfig
public MockFilterConfig(@Nullable ServletContext servletContext, String filterName)
Create a new MockFilterConfig.- Parameters:
servletContext
- the ServletContext that the servlet runs infilterName
- the name of the filter
Method Detail
getFilterName
public String getFilterName()
Description copied from interface:javax.servlet.FilterConfig
Returns the filter-name of this filter as defined in the deployment descriptor.- Specified by:
getFilterName
in interfaceFilterConfig
- Returns:
- the filter name of this filter
getServletContext
public ServletContext getServletContext()
Description copied from interface:javax.servlet.FilterConfig
Returns a reference to theServletContext
in which the caller is executing.- Specified by:
getServletContext
in interfaceFilterConfig
- Returns:
- a
ServletContext
object, used by the caller to interact with its servlet container - See Also:
ServletContext
addInitParameter
public void addInitParameter(String name, String value)
getInitParameter
public String getInitParameter(String name)
Description copied from interface:javax.servlet.FilterConfig
Returns aString
containing the value of the named initialization parameter, ornull
if the initialization parameter does not exist.- Specified by:
getInitParameter
in interfaceFilterConfig
- Parameters:
name
- aString
specifying the name of the initialization parameter- Returns:
- a
String
containing the value of the initialization parameter, ornull
if the initialization parameter does not exist
getInitParameterNames
public Enumeration<String> getInitParameterNames()
Description copied from interface:javax.servlet.FilterConfig
Returns the names of the filter's initialization parameters as anEnumeration
ofString
objects, or an emptyEnumeration
if the filter has no initialization parameters.- Specified by:
getInitParameterNames
in interfaceFilterConfig
- Returns:
- an
Enumeration
ofString
objects containing the names of the filter's initialization parameters