Package io.microsphere.spring.test.util
Class ServletTestUtils
- java.lang.Object
-
- io.microsphere.spring.test.util.ServletTestUtils
-
public abstract class ServletTestUtils extends java.lang.ObjectThe utility class for Servlet Testing- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
ServletContext
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static javax.servlet.FilterRegistration.DynamicaddTestFilter(javax.servlet.ServletContext servletContext)Adds a test filter to the providedServletContext.static javax.servlet.ServletRegistration.DynamicaddTestServlet(javax.servlet.ServletContext servletContext)Adds a test servlet to the providedServletContext.
-
-
-
Method Detail
-
addTestServlet
public static javax.servlet.ServletRegistration.Dynamic addTestServlet(javax.servlet.ServletContext servletContext)
Adds a test servlet to the providedServletContext.This method registers a
TestServletwith the default servlet name "testServlet" and maps it to the default URL pattern "/testServlet".Example Usage
ServletContext servletContext = ...; // Obtain the ServletContext ServletTestUtils.addTestServlet(servletContext);- Parameters:
servletContext- theServletContextto which the test servlet will be added.- Returns:
- the
ServletRegistration.Dynamicfor the added servlet. - See Also:
TestServlet,ServletContext.addServlet(String, javax.servlet.Servlet)
-
addTestFilter
public static javax.servlet.FilterRegistration.Dynamic addTestFilter(javax.servlet.ServletContext servletContext)
Adds a test filter to the providedServletContext.This method registers a
TestFilterwith the default filter name "testFilter" and maps it to the default URL pattern "/testFilter". Additionally, it adds a test servlet to ensure the filter can be mapped to it.Example Usage
ServletContext servletContext = ...; // Obtain the ServletContext ServletTestUtils.addTestFilter(servletContext);- Parameters:
servletContext- theServletContextto which the test filter will be added.- Returns:
- the
FilterRegistration.Dynamicfor the added filter. - See Also:
TestFilter,ServletContext.addFilter(String, javax.servlet.Filter)
-
-