Package org.springframework.mock.web
Class MockServletConfig
- java.lang.Object
- org.springframework.mock.web.MockServletConfig
- All Implemented Interfaces:
ServletConfig
public class MockServletConfig extends Object implements ServletConfig
Mock implementation of theServletConfig
interface.- Since:
- 1.0.2
- Author:
- Rod Johnson, Juergen Hoeller
Constructor Summary
Constructors Constructor Description MockServletConfig()
Create a new MockServletConfig with a defaultMockServletContext
.MockServletConfig(String servletName)
Create a new MockServletConfig with a defaultMockServletContext
.MockServletConfig(ServletContext servletContext)
Create a new MockServletConfig.MockServletConfig(ServletContext servletContext, String servletName)
Create a new MockServletConfig.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addInitParameter(String name, String value)
String
getInitParameter(String name)
Gets the value of the initialization parameter with the given name.Enumeration<String>
getInitParameterNames()
Returns the names of the servlet's initialization parameters as anEnumeration
ofString
objects, or an emptyEnumeration
if the servlet has no initialization parameters.ServletContext
getServletContext()
Returns a reference to theServletContext
in which the caller is executing.String
getServletName()
Returns the name of this servlet instance.
Constructor Detail
MockServletConfig
public MockServletConfig()
Create a new MockServletConfig with a defaultMockServletContext
.
MockServletConfig
public MockServletConfig(String servletName)
Create a new MockServletConfig with a defaultMockServletContext
.- Parameters:
servletName
- the name of the servlet
MockServletConfig
public MockServletConfig(@Nullable ServletContext servletContext)
Create a new MockServletConfig.- Parameters:
servletContext
- the ServletContext that the servlet runs in
MockServletConfig
public MockServletConfig(@Nullable ServletContext servletContext, String servletName)
Create a new MockServletConfig.- Parameters:
servletContext
- the ServletContext that the servlet runs inservletName
- the name of the servlet
Method Detail
getServletName
public String getServletName()
Description copied from interface:javax.servlet.ServletConfig
Returns the name of this servlet instance. The name may be provided via server administration, assigned in the web application deployment descriptor, or for an unregistered (and thus unnamed) servlet instance it will be the servlet's class name.- Specified by:
getServletName
in interfaceServletConfig
- Returns:
- the name of the servlet instance
getServletContext
public ServletContext getServletContext()
Description copied from interface:javax.servlet.ServletConfig
Returns a reference to theServletContext
in which the caller is executing.- Specified by:
getServletContext
in interfaceServletConfig
- 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.ServletConfig
Gets the value of the initialization parameter with the given name.- Specified by:
getInitParameter
in interfaceServletConfig
- Parameters:
name
- the name of the initialization parameter whose value to get- 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.ServletConfig
Returns the names of the servlet's initialization parameters as anEnumeration
ofString
objects, or an emptyEnumeration
if the servlet has no initialization parameters.- Specified by:
getInitParameterNames
in interfaceServletConfig
- Returns:
- an
Enumeration
ofString
objects containing the names of the servlet's initialization parameters