public class MockServletContext extends Object implements ServletContext
ServletContext
where just
enough is present to allow for communication between Mondrian's
XMLA code and other code in the same JVM.
Currently it is used in both the CmdRunner and in XMLA JUnit tests. If you need to add to this implementation, please do so.
Modifier and Type | Field and Description |
---|---|
static String |
PARAM_CALLBACKS |
static String |
PARAM_CHAR_ENCODING |
static String |
PARAM_DATASOURCES_CONFIG |
ORDERED_LIBS, TEMPDIR
Constructor and Description |
---|
MockServletContext() |
Modifier and Type | Method and Description |
---|---|
FilterRegistration.Dynamic |
addFilter(String filterName,
Class<? extends Filter> filterClass) |
FilterRegistration.Dynamic |
addFilter(String filterName,
Filter filter) |
FilterRegistration.Dynamic |
addFilter(String filterName,
String className) |
void |
addInitParameter(String name,
String value) |
void |
addListener(Class<? extends EventListener> listenerClass) |
void |
addListener(String className) |
<T extends EventListener> |
addListener(T t) |
void |
addResource(String name,
URL url) |
ServletRegistration.Dynamic |
addServlet(String servletName,
Class<? extends Servlet> servletClass) |
ServletRegistration.Dynamic |
addServlet(String servletName,
Servlet servlet) |
ServletRegistration.Dynamic |
addServlet(String servletName,
String className) |
<T extends Filter> |
createFilter(Class<T> clazz) |
<T extends EventListener> |
createListener(Class<T> clazz) |
<T extends Servlet> |
createServlet(Class<T> clazz) |
void |
declareRoles(String... roleNames) |
Object |
getAttribute(String s) |
Enumeration |
getAttributeNames()
Returns an Enumeration containing the attribute names available within
this servlet context.
|
ClassLoader |
getClassLoader() |
ServletContext |
getContext(String s)
Returns a ServletContext object that corresponds to a specified URL on
the server.
|
String |
getContextPath() |
Set<SessionTrackingMode> |
getDefaultSessionTrackingModes() |
int |
getEffectiveMajorVersion() |
int |
getEffectiveMinorVersion() |
Set<SessionTrackingMode> |
getEffectiveSessionTrackingModes() |
FilterRegistration |
getFilterRegistration(String filterName) |
Map<String,? extends FilterRegistration> |
getFilterRegistrations() |
String |
getInitParameter(String name)
Returns a String containing the value of the named context-wide
initialization parameter, or null if the parameter does not exist.
|
Enumeration |
getInitParameterNames()
Returns the names of the context's initialization parameters as an
Enumeration of String objects, or an empty Enumeration if the context has
no initialization parameters.
|
JspConfigDescriptor |
getJspConfigDescriptor() |
int |
getMajorVersion()
Returns the major version of the Java Servlet API that this servlet
container supports.
|
String |
getMimeType(String s)
Returns the MIME type of the specified file, or null if the MIME type is
not known.
|
int |
getMinorVersion()
Returns the minor version of the Servlet API that this servlet container
supports.
|
RequestDispatcher |
getNamedDispatcher(String s)
Returns a RequestDispatcher object that acts as a wrapper for the named
servlet.
|
String |
getRealPath(String path)
Returns a String containing the real path for a given virtual path.
|
RequestDispatcher |
getRequestDispatcher(String s)
Returns a RequestDispatcher object that acts as a wrapper for the
resource located at the given path.
|
URL |
getResource(String name)
Returns a URL to the resource that is mapped to a specified path.
|
InputStream |
getResourceAsStream(String s)
Returns the resource located at the named path as an InputStream object.
|
Set |
getResourcePaths(String s) |
String |
getServerInfo()
Returns the name and version of the servlet container on which the
servlet is running.
|
Servlet |
getServlet(String s) |
String |
getServletContextName() |
Enumeration |
getServletNames() |
ServletRegistration |
getServletRegistration(String servletName) |
Map<String,? extends ServletRegistration> |
getServletRegistrations() |
Enumeration |
getServlets() |
SessionCookieConfig |
getSessionCookieConfig() |
String |
getVirtualServerName() |
void |
log(Exception exception,
String s)
Deprecated.
Method log is deprecated
|
void |
log(String s)
Writes the specified message to a servlet log file, usually an event log.
|
void |
log(String s,
Throwable throwable)
Writes an explanatory message and a stack trace for a given Throwable
exception to the servlet log file.
|
void |
removeAttribute(String s)
Removes the attribute with the given name from the servlet context.
|
void |
setAttribute(String s,
Object obj)
Binds an object to a given attribute name in this servlet context.
|
boolean |
setInitParameter(String name,
String value) |
void |
setMajorVersion(int majorVersion) |
void |
setMinorVersion(int minorVersion) |
void |
setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes) |
public static final String PARAM_DATASOURCES_CONFIG
public static final String PARAM_CHAR_ENCODING
public static final String PARAM_CALLBACKS
public ServletContext getContext(String s)
getContext
in interface ServletContext
public int getMajorVersion()
getMajorVersion
in interface ServletContext
public int getMinorVersion()
getMinorVersion
in interface ServletContext
public String getMimeType(String s)
getMimeType
in interface ServletContext
public Set getResourcePaths(String s)
getResourcePaths
in interface ServletContext
public URL getResource(String name) throws MalformedURLException
getResource
in interface ServletContext
MalformedURLException
public InputStream getResourceAsStream(String s)
getResourceAsStream
in interface ServletContext
public RequestDispatcher getRequestDispatcher(String s)
getRequestDispatcher
in interface ServletContext
public RequestDispatcher getNamedDispatcher(String s)
getNamedDispatcher
in interface ServletContext
public Servlet getServlet(String s) throws ServletException
getServlet
in interface ServletContext
ServletException
public Enumeration getServlets()
getServlets
in interface ServletContext
public Enumeration getServletNames()
getServletNames
in interface ServletContext
public void log(String s)
log
in interface ServletContext
public void log(Exception exception, String s)
log
in interface ServletContext
public void log(String s, Throwable throwable)
log
in interface ServletContext
public String getRealPath(String path)
getRealPath
in interface ServletContext
public String getServerInfo()
getServerInfo
in interface ServletContext
public String getInitParameter(String name)
getInitParameter
in interface ServletContext
public Enumeration getInitParameterNames()
getInitParameterNames
in interface ServletContext
public Object getAttribute(String s)
getAttribute
in interface ServletContext
public Enumeration getAttributeNames()
getAttributeNames
in interface ServletContext
public void setAttribute(String s, Object obj)
setAttribute
in interface ServletContext
public void removeAttribute(String s)
removeAttribute
in interface ServletContext
public String getServletContextName()
getServletContextName
in interface ServletContext
public void setMajorVersion(int majorVersion)
public void setMinorVersion(int minorVersion)
public String getContextPath()
getContextPath
in interface ServletContext
public int getEffectiveMajorVersion()
getEffectiveMajorVersion
in interface ServletContext
public int getEffectiveMinorVersion()
getEffectiveMinorVersion
in interface ServletContext
public boolean setInitParameter(String name, String value)
setInitParameter
in interface ServletContext
public ServletRegistration.Dynamic addServlet(String servletName, String className)
addServlet
in interface ServletContext
public ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet)
addServlet
in interface ServletContext
public ServletRegistration.Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass)
addServlet
in interface ServletContext
public <T extends Servlet> T createServlet(Class<T> clazz) throws ServletException
createServlet
in interface ServletContext
ServletException
public ServletRegistration getServletRegistration(String servletName)
getServletRegistration
in interface ServletContext
public Map<String,? extends ServletRegistration> getServletRegistrations()
getServletRegistrations
in interface ServletContext
public FilterRegistration.Dynamic addFilter(String filterName, String className)
addFilter
in interface ServletContext
public FilterRegistration.Dynamic addFilter(String filterName, Filter filter)
addFilter
in interface ServletContext
public FilterRegistration.Dynamic addFilter(String filterName, Class<? extends Filter> filterClass)
addFilter
in interface ServletContext
public <T extends Filter> T createFilter(Class<T> clazz) throws ServletException
createFilter
in interface ServletContext
ServletException
public FilterRegistration getFilterRegistration(String filterName)
getFilterRegistration
in interface ServletContext
public Map<String,? extends FilterRegistration> getFilterRegistrations()
getFilterRegistrations
in interface ServletContext
public SessionCookieConfig getSessionCookieConfig()
getSessionCookieConfig
in interface ServletContext
public void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes)
setSessionTrackingModes
in interface ServletContext
public Set<SessionTrackingMode> getDefaultSessionTrackingModes()
getDefaultSessionTrackingModes
in interface ServletContext
public Set<SessionTrackingMode> getEffectiveSessionTrackingModes()
getEffectiveSessionTrackingModes
in interface ServletContext
public void addListener(String className)
addListener
in interface ServletContext
public <T extends EventListener> void addListener(T t)
addListener
in interface ServletContext
public void addListener(Class<? extends EventListener> listenerClass)
addListener
in interface ServletContext
public <T extends EventListener> T createListener(Class<T> clazz) throws ServletException
createListener
in interface ServletContext
ServletException
public JspConfigDescriptor getJspConfigDescriptor()
getJspConfigDescriptor
in interface ServletContext
public ClassLoader getClassLoader()
getClassLoader
in interface ServletContext
public void declareRoles(String... roleNames)
declareRoles
in interface ServletContext
public String getVirtualServerName()
getVirtualServerName
in interface ServletContext