use of io.undertow.servlet.api.FilterInfo in project undertow by undertow-io.
the class WelcomeFileTestCase method setup.
@BeforeClass
public static void setup() throws ServletException {
final PathHandler root = new PathHandler();
final ServletContainer container = ServletContainer.Factory.newInstance();
DeploymentInfo builder = new DeploymentInfo().setClassIntrospecter(TestClassIntrospector.INSTANCE).setClassLoader(ServletPathMappingTestCase.class.getClassLoader()).setContextPath("/servletContext").setDeploymentName("servletContext.war").setResourceManager(new TestResourceLoader(WelcomeFileTestCase.class)).addWelcomePages("doesnotexist.html", "index.html", "default", "servletPath/servletFile.xhtml").addServlet(new ServletInfo("DefaultTestServlet", PathTestServlet.class).addMapping("/path/default")).addServlet(new ServletInfo("ServletPath", PathTestServlet.class).addMapping("/foo/servletPath/*")).addFilter(new FilterInfo("Filter", NoOpFilter.class)).addFilterUrlMapping("Filter", "/*", DispatcherType.REQUEST).addFilterUrlMapping("Filter", "/", DispatcherType.REQUEST);
DeploymentManager manager = container.addDeployment(builder);
manager.deploy();
root.addPrefixPath(builder.getContextPath(), manager.start());
builder = new DeploymentInfo().setClassIntrospecter(TestClassIntrospector.INSTANCE).setClassLoader(ServletPathMappingTestCase.class.getClassLoader()).setContextPath("/servletContext2").setDeploymentName("servletContext2.war").setResourceManager(new TestResourceLoader(WelcomeFileTestCase.class)).addWelcomePages("doesnotexist.html", "index.do").addServlet(new ServletInfo("*.do", PathTestServlet.class).addMapping("*.do"));
manager = container.addDeployment(builder);
manager.deploy();
root.addPrefixPath(builder.getContextPath(), manager.start());
DefaultServer.setRootHandler(root);
}
use of io.undertow.servlet.api.FilterInfo in project undertow by undertow-io.
the class EagerServletLifecycleTestCase method testServletLifecycle.
@Test
public void testServletLifecycle() throws Exception {
final PathHandler root = new PathHandler();
final ServletContainer container = ServletContainer.Factory.newInstance();
FilterInfo f = new FilterInfo("filter", LifecycleFilter.class);
DeploymentInfo builder = new DeploymentInfo().setClassLoader(EagerServletLifecycleTestCase.class.getClassLoader()).setContextPath("/servletContext").setClassIntrospecter(TestClassIntrospector.INSTANCE).setDeploymentName("servletContext.war").setEagerFilterInit(true).addFilter(f).addFilterUrlMapping("filter", "/aa", DispatcherType.REQUEST);
DeploymentManager manager = container.addDeployment(builder);
manager.deploy();
root.addPrefixPath(builder.getContextPath(), manager.start());
DefaultServer.setRootHandler(root);
Assert.assertTrue(LifecycleFilter.initCalled);
}
use of io.undertow.servlet.api.FilterInfo in project undertow by undertow-io.
the class ServletLifecycleTestCase method testServletLifecycle.
@Test
public void testServletLifecycle() throws Exception {
final PathHandler root = new PathHandler();
final ServletContainer container = ServletContainer.Factory.newInstance();
ServletInfo s = new ServletInfo("servlet", LifeCycleServlet.class).addMapping("/aa");
FilterInfo f = new FilterInfo("filter", LifecycleFilter.class);
DeploymentInfo builder = new DeploymentInfo().setClassLoader(ServletLifecycleTestCase.class.getClassLoader()).setContextPath("/servletContext").setClassIntrospecter(TestClassIntrospector.INSTANCE).setDeploymentName("servletContext.war").addServlet(s).addFilter(f).addFilterUrlMapping("filter", "/aa", DispatcherType.REQUEST);
DeploymentManager manager = container.addDeployment(builder);
manager.deploy();
root.addPrefixPath(builder.getContextPath(), manager.start());
DefaultServer.setRootHandler(root);
TestHttpClient client = new TestHttpClient();
try {
HttpGet get = new HttpGet(DefaultServer.getDefaultServerURL() + "/servletContext/aa");
HttpResponse result = client.execute(get);
Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode());
final String response = HttpClientUtils.readResponse(result);
manager.stop();
manager.undeploy();
Assert.assertTrue(LifeCycleServlet.initCalled);
Assert.assertTrue(LifeCycleServlet.destroyCalled);
Assert.assertTrue(LifecycleFilter.initCalled);
Assert.assertTrue(LifecycleFilter.destroyCalled);
} finally {
client.getConnectionManager().shutdown();
}
}
use of io.undertow.servlet.api.FilterInfo in project undertow by undertow-io.
the class AbstractResponseWrapperTestCase method setup.
@Before
public void setup() throws ServletException {
DeploymentInfo builder = new DeploymentInfo();
builder.setExceptionHandler(LoggingExceptionHandler.builder().add(IllegalArgumentException.class, "io.undertow", Logger.Level.DEBUG).build());
final PathHandler root = new PathHandler();
final ServletContainer container = ServletContainer.Factory.newInstance();
builder.addServlet(new ServletInfo("wrapperServlet", WrapperServlet.class).addMapping("/*"));
builder.addFilter(new FilterInfo("standard", StandardRequestWrappingFilter.class));
builder.addFilterUrlMapping("standard", "/standard", DispatcherType.REQUEST);
builder.addFilter(new FilterInfo("nonstandard", NonStandardRequestWrappingFilter.class));
builder.addFilterUrlMapping("nonstandard", "/nonstandard", DispatcherType.REQUEST);
builder.setClassIntrospecter(TestClassIntrospector.INSTANCE).setClassLoader(AbstractResponseWrapperTestCase.class.getClassLoader()).setContextPath("/servletContext").setDeploymentName("servletContext.war").setAllowNonStandardWrappers(isNonStandardAllowed());
final DeploymentManager manager = container.addDeployment(builder);
manager.deploy();
root.addPrefixPath(builder.getContextPath(), manager.start());
DefaultServer.setRootHandler(root);
}
Aggregations