Package mondrian.tui
Class MockServletContext
- java.lang.Object
-
- mondrian.tui.MockServletContext
-
- All Implemented Interfaces:
ServletContext
public class MockServletContext extends Object implements ServletContext
Partial implementation of theServletContextwhere 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.
- Author:
- Richard M. Emberson
-
-
Field Summary
Fields Modifier and Type Field Description static StringPARAM_CALLBACKSstatic StringPARAM_CHAR_ENCODINGstatic StringPARAM_DATASOURCES_CONFIG-
Fields inherited from interface javax.servlet.ServletContext
ORDERED_LIBS, TEMPDIR
-
-
Constructor Summary
Constructors Constructor Description MockServletContext()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description FilterRegistration.DynamicaddFilter(String filterName, Class<? extends Filter> filterClass)FilterRegistration.DynamicaddFilter(String filterName, String className)FilterRegistration.DynamicaddFilter(String filterName, Filter filter)voidaddInitParameter(String name, String value)voidaddListener(Class<? extends EventListener> listenerClass)voidaddListener(String className)<T extends EventListener>
voidaddListener(T t)voidaddResource(String name, URL url)ServletRegistration.DynamicaddServlet(String servletName, Class<? extends Servlet> servletClass)ServletRegistration.DynamicaddServlet(String servletName, String className)ServletRegistration.DynamicaddServlet(String servletName, Servlet servlet)<T extends Filter>
TcreateFilter(Class<T> clazz)<T extends EventListener>
TcreateListener(Class<T> clazz)<T extends Servlet>
TcreateServlet(Class<T> clazz)voiddeclareRoles(String... roleNames)ObjectgetAttribute(String s)EnumerationgetAttributeNames()Returns an Enumeration containing the attribute names available within this servlet context.ClassLoadergetClassLoader()ServletContextgetContext(String s)Returns a ServletContext object that corresponds to a specified URL on the server.StringgetContextPath()Set<SessionTrackingMode>getDefaultSessionTrackingModes()intgetEffectiveMajorVersion()intgetEffectiveMinorVersion()Set<SessionTrackingMode>getEffectiveSessionTrackingModes()FilterRegistrationgetFilterRegistration(String filterName)Map<String,? extends FilterRegistration>getFilterRegistrations()StringgetInitParameter(String name)Returns a String containing the value of the named context-wide initialization parameter, or null if the parameter does not exist.EnumerationgetInitParameterNames()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.JspConfigDescriptorgetJspConfigDescriptor()intgetMajorVersion()Returns the major version of the Java Servlet API that this servlet container supports.StringgetMimeType(String s)Returns the MIME type of the specified file, or null if the MIME type is not known.intgetMinorVersion()Returns the minor version of the Servlet API that this servlet container supports.RequestDispatchergetNamedDispatcher(String s)Returns a RequestDispatcher object that acts as a wrapper for the named servlet.StringgetRealPath(String path)Returns a String containing the real path for a given virtual path.RequestDispatchergetRequestDispatcher(String s)Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path.URLgetResource(String name)Returns a URL to the resource that is mapped to a specified path.InputStreamgetResourceAsStream(String s)Returns the resource located at the named path as an InputStream object.SetgetResourcePaths(String s)StringgetServerInfo()Returns the name and version of the servlet container on which the servlet is running.ServletgetServlet(String s)StringgetServletContextName()EnumerationgetServletNames()ServletRegistrationgetServletRegistration(String servletName)Map<String,? extends ServletRegistration>getServletRegistrations()EnumerationgetServlets()SessionCookieConfiggetSessionCookieConfig()StringgetVirtualServerName()voidlog(Exception exception, String s)Deprecated.Method log is deprecatedvoidlog(String s)Writes the specified message to a servlet log file, usually an event log.voidlog(String s, Throwable throwable)Writes an explanatory message and a stack trace for a given Throwable exception to the servlet log file.voidremoveAttribute(String s)Removes the attribute with the given name from the servlet context.voidsetAttribute(String s, Object obj)Binds an object to a given attribute name in this servlet context.booleansetInitParameter(String name, String value)voidsetMajorVersion(int majorVersion)voidsetMinorVersion(int minorVersion)voidsetSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.servlet.ServletContext
addJspFile, getRequestCharacterEncoding, getResponseCharacterEncoding, getSessionTimeout, setRequestCharacterEncoding, setResponseCharacterEncoding, setSessionTimeout
-
-
-
-
Field Detail
-
PARAM_DATASOURCES_CONFIG
public static final String PARAM_DATASOURCES_CONFIG
- See Also:
- Constant Field Values
-
PARAM_CHAR_ENCODING
public static final String PARAM_CHAR_ENCODING
- See Also:
- Constant Field Values
-
PARAM_CALLBACKS
public static final String PARAM_CALLBACKS
- See Also:
- Constant Field Values
-
-
Method Detail
-
getContext
public ServletContext getContext(String s)
Returns a ServletContext object that corresponds to a specified URL on the server.- Specified by:
getContextin interfaceServletContext
-
getMajorVersion
public int getMajorVersion()
Returns the major version of the Java Servlet API that this servlet container supports.- Specified by:
getMajorVersionin interfaceServletContext
-
getMinorVersion
public int getMinorVersion()
Returns the minor version of the Servlet API that this servlet container supports.- Specified by:
getMinorVersionin interfaceServletContext
-
getMimeType
public String getMimeType(String s)
Returns the MIME type of the specified file, or null if the MIME type is not known.- Specified by:
getMimeTypein interfaceServletContext
-
getResourcePaths
public Set getResourcePaths(String s)
- Specified by:
getResourcePathsin interfaceServletContext
-
getResource
public URL getResource(String name) throws MalformedURLException
Returns a URL to the resource that is mapped to a specified path.- Specified by:
getResourcein interfaceServletContext- Throws:
MalformedURLException
-
getResourceAsStream
public InputStream getResourceAsStream(String s)
Returns the resource located at the named path as an InputStream object.- Specified by:
getResourceAsStreamin interfaceServletContext
-
getRequestDispatcher
public RequestDispatcher getRequestDispatcher(String s)
Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path.- Specified by:
getRequestDispatcherin interfaceServletContext
-
getNamedDispatcher
public RequestDispatcher getNamedDispatcher(String s)
Returns a RequestDispatcher object that acts as a wrapper for the named servlet.- Specified by:
getNamedDispatcherin interfaceServletContext
-
getServlet
public Servlet getServlet(String s) throws ServletException
- Specified by:
getServletin interfaceServletContext- Throws:
ServletException
-
getServlets
public Enumeration getServlets()
- Specified by:
getServletsin interfaceServletContext
-
getServletNames
public Enumeration getServletNames()
- Specified by:
getServletNamesin interfaceServletContext
-
log
public void log(String s)
Writes the specified message to a servlet log file, usually an event log.- Specified by:
login interfaceServletContext
-
log
public void log(Exception exception, String s)
Deprecated.Method log is deprecatedDeprecated. As of Java Servlet API 2.1, use log(String message, Throwable throwable) instead. This method was originally defined to write an exception's stack trace and an explanatory error message to the servlet log file.- Specified by:
login interfaceServletContext
-
log
public void log(String s, Throwable throwable)
Writes an explanatory message and a stack trace for a given Throwable exception to the servlet log file.- Specified by:
login interfaceServletContext
-
getRealPath
public String getRealPath(String path)
Returns a String containing the real path for a given virtual path.- Specified by:
getRealPathin interfaceServletContext
-
getServerInfo
public String getServerInfo()
Returns the name and version of the servlet container on which the servlet is running.- Specified by:
getServerInfoin interfaceServletContext
-
getInitParameter
public 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.- Specified by:
getInitParameterin interfaceServletContext
-
getInitParameterNames
public 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.- Specified by:
getInitParameterNamesin interfaceServletContext
-
getAttribute
public Object getAttribute(String s)
- Specified by:
getAttributein interfaceServletContext
-
getAttributeNames
public Enumeration getAttributeNames()
Returns an Enumeration containing the attribute names available within this servlet context.- Specified by:
getAttributeNamesin interfaceServletContext
-
setAttribute
public void setAttribute(String s, Object obj)
Binds an object to a given attribute name in this servlet context.- Specified by:
setAttributein interfaceServletContext
-
removeAttribute
public void removeAttribute(String s)
Removes the attribute with the given name from the servlet context.- Specified by:
removeAttributein interfaceServletContext
-
getServletContextName
public String getServletContextName()
- Specified by:
getServletContextNamein interfaceServletContext
-
setMajorVersion
public void setMajorVersion(int majorVersion)
-
setMinorVersion
public void setMinorVersion(int minorVersion)
-
getContextPath
public String getContextPath()
- Specified by:
getContextPathin interfaceServletContext
-
getEffectiveMajorVersion
public int getEffectiveMajorVersion()
- Specified by:
getEffectiveMajorVersionin interfaceServletContext
-
getEffectiveMinorVersion
public int getEffectiveMinorVersion()
- Specified by:
getEffectiveMinorVersionin interfaceServletContext
-
setInitParameter
public boolean setInitParameter(String name, String value)
- Specified by:
setInitParameterin interfaceServletContext
-
addServlet
public ServletRegistration.Dynamic addServlet(String servletName, String className)
- Specified by:
addServletin interfaceServletContext
-
addServlet
public ServletRegistration.Dynamic addServlet(String servletName, Servlet servlet)
- Specified by:
addServletin interfaceServletContext
-
addServlet
public ServletRegistration.Dynamic addServlet(String servletName, Class<? extends Servlet> servletClass)
- Specified by:
addServletin interfaceServletContext
-
createServlet
public <T extends Servlet> T createServlet(Class<T> clazz) throws ServletException
- Specified by:
createServletin interfaceServletContext- Throws:
ServletException
-
getServletRegistration
public ServletRegistration getServletRegistration(String servletName)
- Specified by:
getServletRegistrationin interfaceServletContext
-
getServletRegistrations
public Map<String,? extends ServletRegistration> getServletRegistrations()
- Specified by:
getServletRegistrationsin interfaceServletContext
-
addFilter
public FilterRegistration.Dynamic addFilter(String filterName, String className)
- Specified by:
addFilterin interfaceServletContext
-
addFilter
public FilterRegistration.Dynamic addFilter(String filterName, Filter filter)
- Specified by:
addFilterin interfaceServletContext
-
addFilter
public FilterRegistration.Dynamic addFilter(String filterName, Class<? extends Filter> filterClass)
- Specified by:
addFilterin interfaceServletContext
-
createFilter
public <T extends Filter> T createFilter(Class<T> clazz) throws ServletException
- Specified by:
createFilterin interfaceServletContext- Throws:
ServletException
-
getFilterRegistration
public FilterRegistration getFilterRegistration(String filterName)
- Specified by:
getFilterRegistrationin interfaceServletContext
-
getFilterRegistrations
public Map<String,? extends FilterRegistration> getFilterRegistrations()
- Specified by:
getFilterRegistrationsin interfaceServletContext
-
getSessionCookieConfig
public SessionCookieConfig getSessionCookieConfig()
- Specified by:
getSessionCookieConfigin interfaceServletContext
-
setSessionTrackingModes
public void setSessionTrackingModes(Set<SessionTrackingMode> sessionTrackingModes)
- Specified by:
setSessionTrackingModesin interfaceServletContext
-
getDefaultSessionTrackingModes
public Set<SessionTrackingMode> getDefaultSessionTrackingModes()
- Specified by:
getDefaultSessionTrackingModesin interfaceServletContext
-
getEffectiveSessionTrackingModes
public Set<SessionTrackingMode> getEffectiveSessionTrackingModes()
- Specified by:
getEffectiveSessionTrackingModesin interfaceServletContext
-
addListener
public void addListener(String className)
- Specified by:
addListenerin interfaceServletContext
-
addListener
public <T extends EventListener> void addListener(T t)
- Specified by:
addListenerin interfaceServletContext
-
addListener
public void addListener(Class<? extends EventListener> listenerClass)
- Specified by:
addListenerin interfaceServletContext
-
createListener
public <T extends EventListener> T createListener(Class<T> clazz) throws ServletException
- Specified by:
createListenerin interfaceServletContext- Throws:
ServletException
-
getJspConfigDescriptor
public JspConfigDescriptor getJspConfigDescriptor()
- Specified by:
getJspConfigDescriptorin interfaceServletContext
-
getClassLoader
public ClassLoader getClassLoader()
- Specified by:
getClassLoaderin interfaceServletContext
-
declareRoles
public void declareRoles(String... roleNames)
- Specified by:
declareRolesin interfaceServletContext
-
getVirtualServerName
public String getVirtualServerName()
- Specified by:
getVirtualServerNamein interfaceServletContext
-
-