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 theServletConfiginterface.- 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 voidaddInitParameter(String name, String value)StringgetInitParameter(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 anEnumerationofStringobjects, or an emptyEnumerationif the servlet has no initialization parameters.ServletContextgetServletContext()Returns a reference to theServletContextin which the caller is executing.StringgetServletName()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.ServletConfigReturns 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:
getServletNamein interfaceServletConfig- Returns:
- the name of the servlet instance
getServletContext
public ServletContext getServletContext()
Description copied from interface:javax.servlet.ServletConfigReturns a reference to theServletContextin which the caller is executing.- Specified by:
getServletContextin interfaceServletConfig- Returns:
- a
ServletContextobject, 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.ServletConfigGets the value of the initialization parameter with the given name.- Specified by:
getInitParameterin interfaceServletConfig- Parameters:
name- the name of the initialization parameter whose value to get- Returns:
- a
Stringcontaining the value of the initialization parameter, ornullif the initialization parameter does not exist
getInitParameterNames
public Enumeration<String> getInitParameterNames()
Description copied from interface:javax.servlet.ServletConfigReturns the names of the servlet's initialization parameters as anEnumerationofStringobjects, or an emptyEnumerationif the servlet has no initialization parameters.- Specified by:
getInitParameterNamesin interfaceServletConfig- Returns:
- an
EnumerationofStringobjects containing the names of the servlet's initialization parameters