Search in sources :

Example 51 with ServletInfo

use of io.undertow.servlet.api.ServletInfo 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);
}
Also used : ServletInfo(io.undertow.servlet.api.ServletInfo) DeploymentManager(io.undertow.servlet.api.DeploymentManager) ServletContainer(io.undertow.servlet.api.ServletContainer) PathHandler(io.undertow.server.handlers.PathHandler) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) MessageServlet(io.undertow.servlet.test.util.MessageServlet) BeforeClass(org.junit.BeforeClass)

Example 52 with ServletInfo

use of io.undertow.servlet.api.ServletInfo in project undertow by undertow-io.

the class AsyncListenerOnErrorTest method setup.

@BeforeClass
public static void setup() throws ServletException {
    final PathHandler root = new PathHandler();
    final ServletContainer container = ServletContainer.Factory.newInstance();
    ServletInfo f = new ServletInfo("faultyServlet", FaultyServlet.class).addMapping("/faulty");
    ServletInfo a1 = new ServletInfo("asyncServlet1", AsyncServlet1.class).setAsyncSupported(true).addMapping("/async1");
    ServletInfo a2 = new ServletInfo("asyncServlet2", AsyncServlet2.class).setAsyncSupported(true).addMapping("/async2");
    ServletInfo a3 = new ServletInfo("asyncServlet3", AsyncServlet3.class).setAsyncSupported(true).addMapping("/async3");
    DeploymentInfo builder = new DeploymentInfo().setClassLoader(AsyncListenerOnErrorTest.class.getClassLoader()).setContextPath("/servletContext").setClassIntrospecter(TestClassIntrospector.INSTANCE).setDeploymentName("servletContext.war").addServlets(f, a1, a2, a3);
    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);
}
Also used : ServletInfo(io.undertow.servlet.api.ServletInfo) DeploymentManager(io.undertow.servlet.api.DeploymentManager) ServletContainer(io.undertow.servlet.api.ServletContainer) PathHandler(io.undertow.server.handlers.PathHandler) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) BeforeClass(org.junit.BeforeClass)

Example 53 with ServletInfo

use of io.undertow.servlet.api.ServletInfo in project undertow by undertow-io.

the class NestedListenerInvocationTestCase method setup.

@BeforeClass
public static void setup() throws ServletException {
    final PathHandler root = new PathHandler();
    final ServletContainer container = ServletContainer.Factory.newInstance();
    ServletInfo a = new ServletInfo("asyncServlet", AsyncServlet.class).setAsyncSupported(true).addMapping("/async");
    DeploymentInfo builder = new DeploymentInfo().setClassLoader(NestedListenerInvocationTestCase.class.getClassLoader()).setContextPath("/servletContext").setClassIntrospecter(TestClassIntrospector.INSTANCE).setDeploymentName("servletContext.war").addServlets(a).addListener(new ListenerInfo(SimpleRequestListener.class));
    DeploymentManager manager = container.addDeployment(builder);
    manager.deploy();
    root.addPrefixPath(builder.getContextPath(), manager.start());
    DefaultServer.setRootHandler(root);
}
Also used : ServletInfo(io.undertow.servlet.api.ServletInfo) ListenerInfo(io.undertow.servlet.api.ListenerInfo) DeploymentManager(io.undertow.servlet.api.DeploymentManager) ServletContainer(io.undertow.servlet.api.ServletContainer) PathHandler(io.undertow.server.handlers.PathHandler) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) BeforeClass(org.junit.BeforeClass)

Example 54 with ServletInfo

use of io.undertow.servlet.api.ServletInfo 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);
}
Also used : ServletInfo(io.undertow.servlet.api.ServletInfo) TestResourceLoader(io.undertow.servlet.test.util.TestResourceLoader) PathTestServlet(io.undertow.servlet.test.util.PathTestServlet) DeploymentManager(io.undertow.servlet.api.DeploymentManager) ServletContainer(io.undertow.servlet.api.ServletContainer) PathHandler(io.undertow.server.handlers.PathHandler) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) FilterInfo(io.undertow.servlet.api.FilterInfo) ServletPathMappingTestCase(io.undertow.servlet.test.path.ServletPathMappingTestCase) BeforeClass(org.junit.BeforeClass)

Example 55 with ServletInfo

use of io.undertow.servlet.api.ServletInfo 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);
}
Also used : ServletInfo(io.undertow.servlet.api.ServletInfo) TestResourceLoader(io.undertow.servlet.test.util.TestResourceLoader) DeploymentManager(io.undertow.servlet.api.DeploymentManager) ServletContainer(io.undertow.servlet.api.ServletContainer) PathHandler(io.undertow.server.handlers.PathHandler) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) BeforeClass(org.junit.BeforeClass)

Aggregations

ServletInfo (io.undertow.servlet.api.ServletInfo)67 DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)58 ServletContainer (io.undertow.servlet.api.ServletContainer)51 DeploymentManager (io.undertow.servlet.api.DeploymentManager)50 PathHandler (io.undertow.server.handlers.PathHandler)49 BeforeClass (org.junit.BeforeClass)43 FilterInfo (io.undertow.servlet.api.FilterInfo)15 SimpleServletTestCase (io.undertow.servlet.test.SimpleServletTestCase)14 LoginConfig (io.undertow.servlet.api.LoginConfig)13 ListenerInfo (io.undertow.servlet.api.ListenerInfo)11 TestResourceLoader (io.undertow.servlet.test.util.TestResourceLoader)11 SecurityConstraint (io.undertow.servlet.api.SecurityConstraint)10 WebResourceCollection (io.undertow.servlet.api.WebResourceCollection)9 ServletIdentityManager (io.undertow.servlet.test.security.constraint.ServletIdentityManager)9 Test (org.junit.Test)9 TestHttpClient (io.undertow.testutils.TestHttpClient)8 ServletSecurityInfo (io.undertow.servlet.api.ServletSecurityInfo)7 MessageServlet (io.undertow.servlet.test.util.MessageServlet)6 Servlet (javax.servlet.Servlet)6 ServletException (javax.servlet.ServletException)6