org.apache.click.servlet
Class MockServletConfig

java.lang.Object
  extended by org.apache.click.servlet.MockServletConfig
All Implemented Interfaces:
ServletConfig

public class MockServletConfig
extends Object
implements ServletConfig

Mock implementation of ServletConfig.

Implements all of the methods from the standard ServletConfig class plus helper methods to aid setting up a config.


Constructor Summary
MockServletConfig()
          Create a new MockServletConfig instance.
MockServletConfig(ServletContext servletContext)
          Create a new MockServletConfig instance with the specified servletContext.
MockServletConfig(String servletName)
          Create a new MockServletConfig instance with the specified servletName.
MockServletConfig(String servletName, ServletContext servletContext)
          Create a new MockServletConfig instance with the specified servletName and servletContext.
MockServletConfig(String servletName, ServletContext servletContext, Map<String,String> initParameters)
          Create a new MockServletConfig instance with the specified servletName, servletContext and initialization parameters.
 
Method Summary
 void addInitParameter(String name, String value)
          Add an init parameter.
 void addInitParameters(Map<String,String> initParameters)
          Add the map of init parameters.
 String getInitParameter(String name)
          Returns a String containing the value of the named initialization parameter, or null if the parameter does not exist.
 Enumeration<String> getInitParameterNames()
          Returns the names of the servlet's initialization parameters as an Enumeration of String objects, or an empty Enumeration if the servlet has no initialization parameters.
 ServletContext getServletContext()
          Return the servlet context.
 String getServletName()
          Return the servlet name.
 void setServletContext(ServletContext servletContext)
          Set the servlet context instance.
 void setServletName(String servletName)
          Set the servlet name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockServletConfig

public MockServletConfig()
Create a new MockServletConfig instance.


MockServletConfig

public MockServletConfig(String servletName)
Create a new MockServletConfig instance with the specified servletName.

Parameters:
servletName - the servlet name

MockServletConfig

public MockServletConfig(ServletContext servletContext)
Create a new MockServletConfig instance with the specified servletContext.

Parameters:
servletContext - the servletContext

MockServletConfig

public MockServletConfig(String servletName,
                         ServletContext servletContext)
Create a new MockServletConfig instance with the specified servletName and servletContext.

Parameters:
servletName - the servlet name
servletContext - the servlet context

MockServletConfig

public MockServletConfig(String servletName,
                         ServletContext servletContext,
                         Map<String,String> initParameters)
Create a new MockServletConfig instance with the specified servletName, servletContext and initialization parameters.

Parameters:
servletName - the servlet name
servletContext - the servlet context
initParameters - the initialization parameters
Method Detail

addInitParameter

public void addInitParameter(String name,
                             String value)
Add an init parameter.

Parameters:
name - The parameter name
value - The parameter value

addInitParameters

public void addInitParameters(Map<String,String> initParameters)
Add the map of init parameters.

Parameters:
initParameters - A map of init parameters

setServletName

public void setServletName(String servletName)
Set the servlet name.

Parameters:
servletName - the new servletName

setServletContext

public void setServletContext(ServletContext servletContext)
Set the servlet context instance.

Parameters:
servletContext - a servletContext instance

getServletName

public String getServletName()
Return the servlet name.

Specified by:
getServletName in interface ServletConfig
Returns:
the servlet name

getServletContext

public ServletContext getServletContext()
Return the servlet context.

Specified by:
getServletContext in interface ServletConfig
Returns:
the servletContext

getInitParameterNames

public Enumeration<String> getInitParameterNames()
Returns the names of the servlet's initialization parameters as an Enumeration of String objects, or an empty Enumeration if the servlet has no initialization parameters.

Specified by:
getInitParameterNames in interface ServletConfig
Returns:
enumeration of initialization parameters

getInitParameter

public String getInitParameter(String name)
Returns a String containing the value of the named initialization parameter, or null if the parameter does not exist.

Specified by:
getInitParameter in interface ServletConfig
Parameters:
name - a String specifying the name of the initialization parameter
Returns:
a String containing the value of the initialization parameter