Class SpringBootMockServletContext
- java.lang.Object
- org.springframework.mock.web.MockServletContext
- org.springframework.boot.test.mock.web.SpringBootMockServletContext
- All Implemented Interfaces:
javax.servlet.ServletContext
public class SpringBootMockServletContext extends org.springframework.mock.web.MockServletContext
MockServletContextimplementation for Spring Boot. Respects well-known Spring Boot resource locations and uses an empty directory for "/" if no locations can be found.- Since:
- 1.4.0
Constructor Summary
Constructors Constructor Description SpringBootMockServletContext(String resourceBasePath)SpringBootMockServletContext(String resourceBasePath, org.springframework.core.io.ResourceLoader resourceLoader)
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description URLgetResource(String path)protected StringgetResourceBasePathLocation(String path)protected StringgetResourceLocation(String path)Methods inherited from class org.springframework.mock.web.MockServletContext
addFilter, addFilter, addFilter, addInitParameter, addJspFile, addListener, addListener, addListener, addMimeType, addServlet, addServlet, addServlet, createFilter, createListener, createServlet, declareRoles, getAttribute, getAttributeNames, getClassLoader, getContext, getContextPath, getDeclaredRoles, getDefaultServletName, getDefaultSessionTrackingModes, getEffectiveMajorVersion, getEffectiveMinorVersion, getEffectiveSessionTrackingModes, getFilterRegistration, getFilterRegistrations, getInitParameter, getInitParameterNames, getJspConfigDescriptor, getMajorVersion, getMimeType, getMinorVersion, getNamedDispatcher, getRealPath, getRequestCharacterEncoding, getRequestDispatcher, getResourceAsStream, getResourcePaths, getResponseCharacterEncoding, getServerInfo, getServlet, getServletContextName, getServletNames, getServletRegistration, getServletRegistrations, getServlets, getSessionCookieConfig, getSessionTimeout, getVirtualServerName, log, log, log, registerContext, registerNamedDispatcher, removeAttribute, setAttribute, setContextPath, setDefaultServletName, setEffectiveMajorVersion, setEffectiveMinorVersion, setInitParameter, setMajorVersion, setMinorVersion, setRequestCharacterEncoding, setResponseCharacterEncoding, setServletContextName, setSessionTimeout, setSessionTrackingModes, unregisterNamedDispatcher
Constructor Detail
SpringBootMockServletContext
public SpringBootMockServletContext(String resourceBasePath)
SpringBootMockServletContext
public SpringBootMockServletContext(String resourceBasePath, org.springframework.core.io.ResourceLoader resourceLoader)
Method Detail
getResourceLocation
protected String getResourceLocation(String path)
- Overrides:
getResourceLocationin classorg.springframework.mock.web.MockServletContext
getResourceBasePathLocation
protected final String getResourceBasePathLocation(String path)
getResource
public URL getResource(String path) throws MalformedURLException
- Specified by:
getResourcein interfacejavax.servlet.ServletContext- Overrides:
getResourcein classorg.springframework.mock.web.MockServletContext- Throws:
MalformedURLException