public class FakeServletContext extends Object implements javax.servlet.ServletContext
Constructor and Description |
---|
FakeServletContext() |
FakeServletContext(String rootpath) |
FakeServletContext(String rootpath,
Map<String,Object> attrs) |
FakeServletContext(String rootpath,
Map<String,Object> attrs,
Map<String,String> initParams) |
Modifier and Type | Method and Description |
---|---|
javax.servlet.FilterRegistration.Dynamic |
addFilter(String filterName,
Class<? extends javax.servlet.Filter> filterClass) |
javax.servlet.FilterRegistration.Dynamic |
addFilter(String filterName,
javax.servlet.Filter filter) |
javax.servlet.FilterRegistration.Dynamic |
addFilter(String filterName,
String className) |
void |
addListener(Class<? extends EventListener> listenerClass) |
void |
addListener(String className) |
<T extends EventListener> |
addListener(T t) |
javax.servlet.ServletRegistration.Dynamic |
addServlet(String servletName,
Class<? extends javax.servlet.Servlet> servletClass) |
javax.servlet.ServletRegistration.Dynamic |
addServlet(String servletName,
javax.servlet.Servlet servlet) |
javax.servlet.ServletRegistration.Dynamic |
addServlet(String servletName,
String className) |
<T extends javax.servlet.Filter> |
createFilter(Class<T> clazz) |
<T extends EventListener> |
createListener(Class<T> clazz) |
<T extends javax.servlet.Servlet> |
createServlet(Class<T> clazz) |
void |
declareRoles(String... roleNames) |
Object |
getAttribute(String name) |
Enumeration<String> |
getAttributeNames() |
ClassLoader |
getClassLoader() |
javax.servlet.ServletContext |
getContext(String path) |
String |
getContextPath() |
Set<javax.servlet.SessionTrackingMode> |
getDefaultSessionTrackingModes() |
int |
getEffectiveMajorVersion() |
int |
getEffectiveMinorVersion() |
Set<javax.servlet.SessionTrackingMode> |
getEffectiveSessionTrackingModes() |
javax.servlet.FilterRegistration |
getFilterRegistration(String filterName) |
Map<String,? extends javax.servlet.FilterRegistration> |
getFilterRegistrations() |
String |
getInitParameter(String name) |
Enumeration<String> |
getInitParameterNames() |
javax.servlet.descriptor.JspConfigDescriptor |
getJspConfigDescriptor() |
int |
getMajorVersion() |
String |
getMimeType(String filename) |
int |
getMinorVersion() |
javax.servlet.RequestDispatcher |
getNamedDispatcher(String name) |
String |
getRealFilePath(String path) |
String |
getRealPath(String path) |
javax.servlet.RequestDispatcher |
getRequestDispatcher(String path) |
URL |
getResource(String path) |
InputStream |
getResourceAsStream(String path) |
Set<String> |
getResourcePaths(String path) |
String |
getServerInfo() |
javax.servlet.Servlet |
getServlet(String name) |
String |
getServletContextName() |
Enumeration<String> |
getServletNames() |
javax.servlet.ServletRegistration |
getServletRegistration(String servletName) |
Map<String,? extends javax.servlet.ServletRegistration> |
getServletRegistrations() |
Enumeration<javax.servlet.Servlet> |
getServlets() |
javax.servlet.SessionCookieConfig |
getSessionCookieConfig() |
void |
log(Exception e,
String msg) |
void |
log(String msg) |
void |
log(String msg,
Throwable t) |
void |
removeAttribute(String name) |
void |
setAttribute(String name,
Object value) |
boolean |
setInitParameter(String name,
String value) |
void |
setSessionTrackingModes(Set<javax.servlet.SessionTrackingMode> sessionTrackingModes) |
void |
setVersion(int major,
int minor) |
public FakeServletContext()
public FakeServletContext(String rootpath)
public void setVersion(int major, int minor)
public javax.servlet.ServletContext getContext(String path)
getContext
in interface javax.servlet.ServletContext
public Object getAttribute(String name)
getAttribute
in interface javax.servlet.ServletContext
public Enumeration<String> getAttributeNames()
getAttributeNames
in interface javax.servlet.ServletContext
public void removeAttribute(String name)
removeAttribute
in interface javax.servlet.ServletContext
public void setAttribute(String name, Object value)
setAttribute
in interface javax.servlet.ServletContext
public int getMajorVersion()
getMajorVersion
in interface javax.servlet.ServletContext
public int getMinorVersion()
getMinorVersion
in interface javax.servlet.ServletContext
public String getMimeType(String filename)
getMimeType
in interface javax.servlet.ServletContext
public String getRealPath(String path)
getRealPath
in interface javax.servlet.ServletContext
public InputStream getResourceAsStream(String path)
getResourceAsStream
in interface javax.servlet.ServletContext
public URL getResource(String path) throws MalformedURLException
getResource
in interface javax.servlet.ServletContext
MalformedURLException
public Set<String> getResourcePaths(String path)
getResourcePaths
in interface javax.servlet.ServletContext
public javax.servlet.RequestDispatcher getRequestDispatcher(String path)
getRequestDispatcher
in interface javax.servlet.ServletContext
public javax.servlet.RequestDispatcher getNamedDispatcher(String name)
getNamedDispatcher
in interface javax.servlet.ServletContext
public String getServerInfo()
getServerInfo
in interface javax.servlet.ServletContext
public String getInitParameter(String name)
getInitParameter
in interface javax.servlet.ServletContext
public Enumeration<String> getInitParameterNames()
getInitParameterNames
in interface javax.servlet.ServletContext
public void log(String msg)
log
in interface javax.servlet.ServletContext
public void log(String msg, Throwable t)
log
in interface javax.servlet.ServletContext
public void log(Exception e, String msg)
log
in interface javax.servlet.ServletContext
public javax.servlet.Servlet getServlet(String name) throws javax.servlet.ServletException
getServlet
in interface javax.servlet.ServletContext
javax.servlet.ServletException
public Enumeration<javax.servlet.Servlet> getServlets()
getServlets
in interface javax.servlet.ServletContext
public Enumeration<String> getServletNames()
getServletNames
in interface javax.servlet.ServletContext
public String getServletContextName()
getServletContextName
in interface javax.servlet.ServletContext
public String getContextPath()
getContextPath
in interface javax.servlet.ServletContext
public int getEffectiveMajorVersion()
public int getEffectiveMinorVersion()
public javax.servlet.ServletRegistration.Dynamic addServlet(String servletName, String className)
public javax.servlet.ServletRegistration.Dynamic addServlet(String servletName, javax.servlet.Servlet servlet)
public javax.servlet.ServletRegistration.Dynamic addServlet(String servletName, Class<? extends javax.servlet.Servlet> servletClass)
public <T extends javax.servlet.Servlet> T createServlet(Class<T> clazz) throws javax.servlet.ServletException
javax.servlet.ServletException
public javax.servlet.ServletRegistration getServletRegistration(String servletName)
public Map<String,? extends javax.servlet.ServletRegistration> getServletRegistrations()
public javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, String className)
public javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, javax.servlet.Filter filter)
public javax.servlet.FilterRegistration.Dynamic addFilter(String filterName, Class<? extends javax.servlet.Filter> filterClass)
public <T extends javax.servlet.Filter> T createFilter(Class<T> clazz) throws javax.servlet.ServletException
javax.servlet.ServletException
public javax.servlet.FilterRegistration getFilterRegistration(String filterName)
public Map<String,? extends javax.servlet.FilterRegistration> getFilterRegistrations()
public javax.servlet.SessionCookieConfig getSessionCookieConfig()
public void setSessionTrackingModes(Set<javax.servlet.SessionTrackingMode> sessionTrackingModes)
public Set<javax.servlet.SessionTrackingMode> getDefaultSessionTrackingModes()
public Set<javax.servlet.SessionTrackingMode> getEffectiveSessionTrackingModes()
public void addListener(String className)
public <T extends EventListener> void addListener(T t)
public void addListener(Class<? extends EventListener> listenerClass)
public <T extends EventListener> T createListener(Class<T> clazz) throws javax.servlet.ServletException
javax.servlet.ServletException
public javax.servlet.descriptor.JspConfigDescriptor getJspConfigDescriptor()
public ClassLoader getClassLoader()
public void declareRoles(String... roleNames)