use of io.undertow.servlet.api.ServletContainer in project undertow by undertow-io.
the class AsyncListenerOnCompleteTest method setup.
@BeforeClass
public static void setup() throws ServletException {
final PathHandler root = new PathHandler();
final ServletContainer container = ServletContainer.Factory.newInstance();
ServletInfo f = new ServletInfo("asyncServlet", OnCompleteServlet.class).addMapping("/async").setAsyncSupported(true);
ServletInfo a1 = new ServletInfo("message", MessageServlet.class).setAsyncSupported(true).addInitParam(MessageServlet.MESSAGE, "Hello").addMapping("/message");
DeploymentInfo builder = new DeploymentInfo().setClassLoader(AsyncListenerOnCompleteTest.class.getClassLoader()).setContextPath("/servletContext").setClassIntrospecter(TestClassIntrospector.INSTANCE).setDeploymentName("servletContext.war").addServlets(f, a1);
builder.setExceptionHandler(LoggingExceptionHandler.builder().add(IllegalStateException.class, "io.undertow", Logger.Level.DEBUG).build());
DeploymentManager manager = container.addDeployment(builder);
manager.deploy();
root.addPrefixPath(builder.getContextPath(), manager.start());
DefaultServer.setRootHandler(root);
}
use of io.undertow.servlet.api.ServletContainer in project undertow by undertow-io.
the class RealPathTestCase method setup.
@BeforeClass
public static void setup() throws ServletException {
final PathHandler root = new PathHandler();
final ServletContainer container = ServletContainer.Factory.newInstance();
ServletInfo realPathServlet = new ServletInfo("real path servlet", RealPathServlet.class).addMapping("/path/*");
DeploymentInfo builder = new DeploymentInfo().setClassIntrospecter(TestClassIntrospector.INSTANCE).setClassLoader(RealPathTestCase.class.getClassLoader()).setContextPath("/servletContext").setDeploymentName("servletContext.war").setResourceManager(new TestResourceLoader(RealPathTestCase.class)).addServlets(realPathServlet);
DeploymentManager manager = container.addDeployment(builder);
manager.deploy();
root.addPrefixPath(builder.getContextPath(), manager.start());
DefaultServer.setRootHandler(root);
}
use of io.undertow.servlet.api.ServletContainer 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.ServletContainer 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.ServletContainer in project undertow by undertow-io.
the class CrossContextServletSharedSessionTestCase method setup.
@BeforeClass
public static void setup() throws ServletException {
final ServletContainer container = ServletContainer.Factory.newInstance();
final PathHandler path = new PathHandler();
DefaultServer.setRootHandler(path);
InMemorySessionManager manager = new InMemorySessionManager("test");
createDeployment("1", container, path, manager);
createDeployment("2", container, path, manager);
}
Aggregations