|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.mock.web.MockServletContext
public class MockServletContext
Mock implementation of the ServletContext interface.
Used for testing the web framework; only rarely necessary for testing application controllers, as long as they don't explicitly access the ServletContext. In the latter case, ClassPathXmlApplicationContext can be used to load them; else, XmlWebApplicationContext needs to be used, possibly with this MockServletContext class.
Constructor Summary | |
---|---|
MockServletContext()
Create a new MockServletContext, using no base path and a DefaultResourceLoader (i.e. the classpath root as WAR root). |
|
MockServletContext(String resourceBasePath)
Create a new MockServletContext, using a DefaultResourceLoader. |
|
MockServletContext(String resourceBasePath,
ResourceLoader resourceLoader)
Create a new MockServletContext. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MockServletContext()
DefaultResourceLoader
public MockServletContext(String resourceBasePath)
resourceBasePath
- the WAR root directory (should not end with a /)DefaultResourceLoader
public MockServletContext(String resourceBasePath, ResourceLoader resourceLoader)
resourceBasePath
- the WAR root directory (should not end with a /)resourceLoader
- the ResourceLoader to useMethod Detail |
---|
protected String getResourceLocation(String path)
path
- the path as specified
public ServletContext getContext(String name)
getContext
in interface ServletContext
public int getMajorVersion()
getMajorVersion
in interface ServletContext
public int getMinorVersion()
getMinorVersion
in interface ServletContext
public String getMimeType(String filePath)
getMimeType
in interface ServletContext
public Set getResourcePaths(String path)
getResourcePaths
in interface ServletContext
public URL getResource(String path) throws MalformedURLException
getResource
in interface ServletContext
MalformedURLException
public InputStream getResourceAsStream(String path)
getResourceAsStream
in interface ServletContext
public RequestDispatcher getRequestDispatcher(String path)
getRequestDispatcher
in interface ServletContext
public RequestDispatcher getNamedDispatcher(String path)
getNamedDispatcher
in interface ServletContext
public Servlet getServlet(String name)
getServlet
in interface ServletContext
public Enumeration getServlets()
getServlets
in interface ServletContext
public Enumeration getServletNames()
getServletNames
in interface ServletContext
public void log(String message)
log
in interface ServletContext
public void log(Exception e, String message)
log
in interface ServletContext
public void log(String message, Throwable t)
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 void addInitParameter(String name, String value)
public Enumeration getInitParameterNames()
getInitParameterNames
in interface ServletContext
public Object getAttribute(String name)
getAttribute
in interface ServletContext
public Enumeration getAttributeNames()
getAttributeNames
in interface ServletContext
public void setAttribute(String name, Object value)
setAttribute
in interface ServletContext
public void removeAttribute(String name)
removeAttribute
in interface ServletContext
public String getServletContextName()
getServletContextName
in interface ServletContext
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |