@BeforeClass
public static void setup() throws ServletException {
final PathHandler root = new PathHandler();
final ServletContainer container = ServletContainer.Factory.newInstance();
DeploymentInfo builder = new DeploymentInfo()
.setClassLoader(SimpleServletTestCase.class.getClassLoader())
.setContextPath("/servletContext")
.setClassIntrospecter(TestClassIntrospector.INSTANCE)
.setDeploymentName("servletContext.war")
.setResourceManager(new TestResourceLoader(DispatcherIncludeTestCase.class))
.addServlet(
new ServletInfo("include", MessageServlet.class)
.addInitParam(MessageServlet.MESSAGE, "included")
.addMapping("/include"))
.addServlet(
new ServletInfo("dispatcher", IncludeServlet.class)
.addMapping("/dispatch"))
.addServlet(
new ServletInfo("pathTest", PathTestServlet.class)
.addMapping("/path"))
.addFilter(
new FilterInfo("notIncluded", MessageFilter.class)
.addInitParam(MessageFilter.MESSAGE, "Not Included"))
.addFilter(
new FilterInfo("inc", MessageFilter.class)
.addInitParam(MessageFilter.MESSAGE, "Path!"))
.addFilter(
new FilterInfo("nameFilter", MessageFilter.class)
.addInitParam(MessageFilter.MESSAGE, "Name!"))
.addFilterUrlMapping("notIncluded", "/include", DispatcherType.REQUEST)
.addFilterUrlMapping("inc", "/include", DispatcherType.INCLUDE)
.addFilterServletNameMapping("nameFilter", "include", DispatcherType.INCLUDE);
DeploymentManager manager = container.addDeployment(builder);
manager.deploy();
root.addPrefixPath(builder.getContextPath(), manager.start());
DefaultServer.setRootHandler(root);
}