Package com.jalios.jcms.test
Class MockServletContext
- java.lang.Object
-
- com.jalios.jcms.test.MockServletContext
-
- All Implemented Interfaces:
javax.servlet.ServletContext
public class MockServletContext extends java.lang.Object implements javax.servlet.ServletContext
Mock ServletContext to be used for testing purpose only.- Since:
- jcms-5.7.4
-
-
Constructor Summary
Constructors Constructor Description MockServletContext(java.lang.String realPath)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description javax.servlet.FilterRegistration.Dynamic
addFilter(java.lang.String arg0, java.lang.Class<? extends javax.servlet.Filter> arg1)
javax.servlet.FilterRegistration.Dynamic
addFilter(java.lang.String arg0, java.lang.String arg1)
javax.servlet.FilterRegistration.Dynamic
addFilter(java.lang.String arg0, javax.servlet.Filter arg1)
javax.servlet.ServletRegistration.Dynamic
addJspFile(java.lang.String arg0, java.lang.String arg1)
void
addListener(java.lang.Class<? extends java.util.EventListener> arg0)
void
addListener(java.lang.String arg0)
<T extends java.util.EventListener>
voidaddListener(T arg0)
javax.servlet.ServletRegistration.Dynamic
addServlet(java.lang.String arg0, java.lang.Class<? extends javax.servlet.Servlet> arg1)
javax.servlet.ServletRegistration.Dynamic
addServlet(java.lang.String arg0, java.lang.String arg1)
javax.servlet.ServletRegistration.Dynamic
addServlet(java.lang.String arg0, javax.servlet.Servlet arg1)
<T extends javax.servlet.Filter>
TcreateFilter(java.lang.Class<T> arg0)
<T extends java.util.EventListener>
TcreateListener(java.lang.Class<T> arg0)
<T extends javax.servlet.Servlet>
TcreateServlet(java.lang.Class<T> arg0)
void
declareRoles(java.lang.String... arg0)
java.lang.Object
getAttribute(java.lang.String arg0)
java.util.Enumeration
getAttributeNames()
java.lang.ClassLoader
getClassLoader()
javax.servlet.ServletContext
getContext(java.lang.String arg0)
java.lang.String
getContextPath()
java.util.Set<javax.servlet.SessionTrackingMode>
getDefaultSessionTrackingModes()
int
getEffectiveMajorVersion()
int
getEffectiveMinorVersion()
java.util.Set<javax.servlet.SessionTrackingMode>
getEffectiveSessionTrackingModes()
javax.servlet.FilterRegistration
getFilterRegistration(java.lang.String arg0)
java.util.Map<java.lang.String,? extends javax.servlet.FilterRegistration>
getFilterRegistrations()
java.lang.String
getInitParameter(java.lang.String arg0)
java.util.Enumeration
getInitParameterNames()
javax.servlet.descriptor.JspConfigDescriptor
getJspConfigDescriptor()
int
getMajorVersion()
java.lang.String
getMimeType(java.lang.String arg0)
int
getMinorVersion()
javax.servlet.RequestDispatcher
getNamedDispatcher(java.lang.String arg0)
java.lang.String
getRealPath(java.lang.String arg0)
java.lang.String
getRequestCharacterEncoding()
javax.servlet.RequestDispatcher
getRequestDispatcher(java.lang.String arg0)
java.net.URL
getResource(java.lang.String arg0)
java.io.InputStream
getResourceAsStream(java.lang.String arg0)
java.util.Set
getResourcePaths(java.lang.String arg0)
java.lang.String
getResponseCharacterEncoding()
java.lang.String
getServerInfo()
javax.servlet.Servlet
getServlet(java.lang.String arg0)
Deprecated.java.lang.String
getServletContextName()
java.util.Enumeration
getServletNames()
Deprecated.javax.servlet.ServletRegistration
getServletRegistration(java.lang.String arg0)
java.util.Map<java.lang.String,? extends javax.servlet.ServletRegistration>
getServletRegistrations()
java.util.Enumeration
getServlets()
Deprecated.javax.servlet.SessionCookieConfig
getSessionCookieConfig()
int
getSessionTimeout()
java.lang.String
getVirtualServerName()
void
log(java.lang.Exception arg0, java.lang.String arg1)
Deprecated.void
log(java.lang.String arg0)
void
log(java.lang.String arg0, java.lang.Throwable arg1)
void
removeAttribute(java.lang.String arg0)
void
setAttribute(java.lang.String arg0, java.lang.Object arg1)
boolean
setInitParameter(java.lang.String arg0, java.lang.String arg1)
void
setRequestCharacterEncoding(java.lang.String arg0)
void
setResponseCharacterEncoding(java.lang.String arg0)
void
setSessionTimeout(int arg0)
void
setSessionTrackingModes(java.util.Set<javax.servlet.SessionTrackingMode> arg0)
-
-
-
Method Detail
-
getServletContextName
public java.lang.String getServletContextName()
- Specified by:
getServletContextName
in interfacejavax.servlet.ServletContext
-
getServerInfo
public java.lang.String getServerInfo()
- Specified by:
getServerInfo
in interfacejavax.servlet.ServletContext
-
getRealPath
public java.lang.String getRealPath(java.lang.String arg0)
- Specified by:
getRealPath
in interfacejavax.servlet.ServletContext
-
getResource
public java.net.URL getResource(java.lang.String arg0) throws java.net.MalformedURLException
- Specified by:
getResource
in interfacejavax.servlet.ServletContext
- Throws:
java.net.MalformedURLException
-
getAttribute
public java.lang.Object getAttribute(java.lang.String arg0)
- Specified by:
getAttribute
in interfacejavax.servlet.ServletContext
-
getAttributeNames
public java.util.Enumeration getAttributeNames()
- Specified by:
getAttributeNames
in interfacejavax.servlet.ServletContext
-
setAttribute
public void setAttribute(java.lang.String arg0, java.lang.Object arg1)
- Specified by:
setAttribute
in interfacejavax.servlet.ServletContext
-
removeAttribute
public void removeAttribute(java.lang.String arg0)
- Specified by:
removeAttribute
in interfacejavax.servlet.ServletContext
-
getInitParameter
public java.lang.String getInitParameter(java.lang.String arg0)
- Specified by:
getInitParameter
in interfacejavax.servlet.ServletContext
-
getInitParameterNames
public java.util.Enumeration getInitParameterNames()
- Specified by:
getInitParameterNames
in interfacejavax.servlet.ServletContext
-
log
public void log(java.lang.String arg0)
- Specified by:
log
in interfacejavax.servlet.ServletContext
-
log
public void log(java.lang.String arg0, java.lang.Throwable arg1)
- Specified by:
log
in interfacejavax.servlet.ServletContext
-
log
@Deprecated public void log(java.lang.Exception arg0, java.lang.String arg1)
Deprecated.- Specified by:
log
in interfacejavax.servlet.ServletContext
-
getMajorVersion
public int getMajorVersion()
- Specified by:
getMajorVersion
in interfacejavax.servlet.ServletContext
-
getMinorVersion
public int getMinorVersion()
- Specified by:
getMinorVersion
in interfacejavax.servlet.ServletContext
-
getContext
public javax.servlet.ServletContext getContext(java.lang.String arg0)
- Specified by:
getContext
in interfacejavax.servlet.ServletContext
-
getRequestDispatcher
public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String arg0)
- Specified by:
getRequestDispatcher
in interfacejavax.servlet.ServletContext
-
getNamedDispatcher
public javax.servlet.RequestDispatcher getNamedDispatcher(java.lang.String arg0)
- Specified by:
getNamedDispatcher
in interfacejavax.servlet.ServletContext
-
getMimeType
public java.lang.String getMimeType(java.lang.String arg0)
- Specified by:
getMimeType
in interfacejavax.servlet.ServletContext
-
getResourcePaths
public java.util.Set getResourcePaths(java.lang.String arg0)
- Specified by:
getResourcePaths
in interfacejavax.servlet.ServletContext
-
getResourceAsStream
public java.io.InputStream getResourceAsStream(java.lang.String arg0)
- Specified by:
getResourceAsStream
in interfacejavax.servlet.ServletContext
-
getServlet
@Deprecated public javax.servlet.Servlet getServlet(java.lang.String arg0) throws javax.servlet.ServletException
Deprecated.- Specified by:
getServlet
in interfacejavax.servlet.ServletContext
- Throws:
javax.servlet.ServletException
-
getServlets
@Deprecated public java.util.Enumeration getServlets()
Deprecated.- Specified by:
getServlets
in interfacejavax.servlet.ServletContext
-
getServletNames
@Deprecated public java.util.Enumeration getServletNames()
Deprecated.- Specified by:
getServletNames
in interfacejavax.servlet.ServletContext
-
getContextPath
public java.lang.String getContextPath()
- Specified by:
getContextPath
in interfacejavax.servlet.ServletContext
-
addListener
public void addListener(java.lang.String arg0)
- Specified by:
addListener
in interfacejavax.servlet.ServletContext
-
addListener
public <T extends java.util.EventListener> void addListener(T arg0)
- Specified by:
addListener
in interfacejavax.servlet.ServletContext
-
addListener
public void addListener(java.lang.Class<? extends java.util.EventListener> arg0)
- Specified by:
addListener
in interfacejavax.servlet.ServletContext
-
createFilter
public <T extends javax.servlet.Filter> T createFilter(java.lang.Class<T> arg0) throws javax.servlet.ServletException
- Specified by:
createFilter
in interfacejavax.servlet.ServletContext
- Throws:
javax.servlet.ServletException
-
createListener
public <T extends java.util.EventListener> T createListener(java.lang.Class<T> arg0) throws javax.servlet.ServletException
- Specified by:
createListener
in interfacejavax.servlet.ServletContext
- Throws:
javax.servlet.ServletException
-
createServlet
public <T extends javax.servlet.Servlet> T createServlet(java.lang.Class<T> arg0) throws javax.servlet.ServletException
- Specified by:
createServlet
in interfacejavax.servlet.ServletContext
- Throws:
javax.servlet.ServletException
-
declareRoles
public void declareRoles(java.lang.String... arg0)
- Specified by:
declareRoles
in interfacejavax.servlet.ServletContext
-
getClassLoader
public java.lang.ClassLoader getClassLoader()
- Specified by:
getClassLoader
in interfacejavax.servlet.ServletContext
-
getEffectiveMajorVersion
public int getEffectiveMajorVersion()
- Specified by:
getEffectiveMajorVersion
in interfacejavax.servlet.ServletContext
-
getEffectiveMinorVersion
public int getEffectiveMinorVersion()
- Specified by:
getEffectiveMinorVersion
in interfacejavax.servlet.ServletContext
-
setInitParameter
public boolean setInitParameter(java.lang.String arg0, java.lang.String arg1)
- Specified by:
setInitParameter
in interfacejavax.servlet.ServletContext
-
addFilter
public javax.servlet.FilterRegistration.Dynamic addFilter(java.lang.String arg0, java.lang.String arg1)
- Specified by:
addFilter
in interfacejavax.servlet.ServletContext
-
addFilter
public javax.servlet.FilterRegistration.Dynamic addFilter(java.lang.String arg0, javax.servlet.Filter arg1)
- Specified by:
addFilter
in interfacejavax.servlet.ServletContext
-
addFilter
public javax.servlet.FilterRegistration.Dynamic addFilter(java.lang.String arg0, java.lang.Class<? extends javax.servlet.Filter> arg1)
- Specified by:
addFilter
in interfacejavax.servlet.ServletContext
-
addServlet
public javax.servlet.ServletRegistration.Dynamic addServlet(java.lang.String arg0, java.lang.String arg1)
- Specified by:
addServlet
in interfacejavax.servlet.ServletContext
-
addServlet
public javax.servlet.ServletRegistration.Dynamic addServlet(java.lang.String arg0, javax.servlet.Servlet arg1)
- Specified by:
addServlet
in interfacejavax.servlet.ServletContext
-
addServlet
public javax.servlet.ServletRegistration.Dynamic addServlet(java.lang.String arg0, java.lang.Class<? extends javax.servlet.Servlet> arg1)
- Specified by:
addServlet
in interfacejavax.servlet.ServletContext
-
getDefaultSessionTrackingModes
public java.util.Set<javax.servlet.SessionTrackingMode> getDefaultSessionTrackingModes()
- Specified by:
getDefaultSessionTrackingModes
in interfacejavax.servlet.ServletContext
-
getEffectiveSessionTrackingModes
public java.util.Set<javax.servlet.SessionTrackingMode> getEffectiveSessionTrackingModes()
- Specified by:
getEffectiveSessionTrackingModes
in interfacejavax.servlet.ServletContext
-
getFilterRegistration
public javax.servlet.FilterRegistration getFilterRegistration(java.lang.String arg0)
- Specified by:
getFilterRegistration
in interfacejavax.servlet.ServletContext
-
getFilterRegistrations
public java.util.Map<java.lang.String,? extends javax.servlet.FilterRegistration> getFilterRegistrations()
- Specified by:
getFilterRegistrations
in interfacejavax.servlet.ServletContext
-
getJspConfigDescriptor
public javax.servlet.descriptor.JspConfigDescriptor getJspConfigDescriptor()
- Specified by:
getJspConfigDescriptor
in interfacejavax.servlet.ServletContext
-
getServletRegistration
public javax.servlet.ServletRegistration getServletRegistration(java.lang.String arg0)
- Specified by:
getServletRegistration
in interfacejavax.servlet.ServletContext
-
getServletRegistrations
public java.util.Map<java.lang.String,? extends javax.servlet.ServletRegistration> getServletRegistrations()
- Specified by:
getServletRegistrations
in interfacejavax.servlet.ServletContext
-
getSessionCookieConfig
public javax.servlet.SessionCookieConfig getSessionCookieConfig()
- Specified by:
getSessionCookieConfig
in interfacejavax.servlet.ServletContext
-
setSessionTrackingModes
public void setSessionTrackingModes(java.util.Set<javax.servlet.SessionTrackingMode> arg0) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException
- Specified by:
setSessionTrackingModes
in interfacejavax.servlet.ServletContext
- Throws:
java.lang.IllegalStateException
java.lang.IllegalArgumentException
-
getVirtualServerName
public java.lang.String getVirtualServerName()
- Specified by:
getVirtualServerName
in interfacejavax.servlet.ServletContext
-
addJspFile
public javax.servlet.ServletRegistration.Dynamic addJspFile(java.lang.String arg0, java.lang.String arg1)
- Specified by:
addJspFile
in interfacejavax.servlet.ServletContext
-
getRequestCharacterEncoding
public java.lang.String getRequestCharacterEncoding()
- Specified by:
getRequestCharacterEncoding
in interfacejavax.servlet.ServletContext
-
getResponseCharacterEncoding
public java.lang.String getResponseCharacterEncoding()
- Specified by:
getResponseCharacterEncoding
in interfacejavax.servlet.ServletContext
-
getSessionTimeout
public int getSessionTimeout()
- Specified by:
getSessionTimeout
in interfacejavax.servlet.ServletContext
-
setRequestCharacterEncoding
public void setRequestCharacterEncoding(java.lang.String arg0)
- Specified by:
setRequestCharacterEncoding
in interfacejavax.servlet.ServletContext
-
setResponseCharacterEncoding
public void setResponseCharacterEncoding(java.lang.String arg0)
- Specified by:
setResponseCharacterEncoding
in interfacejavax.servlet.ServletContext
-
setSessionTimeout
public void setSessionTimeout(int arg0)
- Specified by:
setSessionTimeout
in interfacejavax.servlet.ServletContext
-
-