Search in sources :

Example 36 with DeploymentManager

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

the class TransferTestCase method setup.

@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").addServlet(new ServletInfo("servlet", TXServlet.class).addMapping("/"));
    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) SimpleServletTestCase(io.undertow.servlet.test.SimpleServletTestCase) BeforeClass(org.junit.BeforeClass)

Example 37 with DeploymentManager

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

the class RedirectTestCase method setup.

@BeforeClass
public static void setup() throws ServletException {
    final PathHandler pathHandler = new PathHandler();
    final ServletContainer container = ServletContainer.Factory.newInstance();
    DeploymentInfo builder = new DeploymentInfo().setClassLoader(SimpleServletTestCase.class.getClassLoader()).setContextPath("/servletContext").setClassIntrospecter(TestClassIntrospector.INSTANCE).setDeploymentName("servletContext.war").addServlets(servlet("request", RequestPathServlet.class).addMapping("/"), servlet("redirect", RedirectServlet.class).addMapping("/redirect/*"));
    DeploymentManager manager = container.addDeployment(builder);
    manager.deploy();
    try {
        pathHandler.addPrefixPath(builder.getContextPath(), manager.start());
    } catch (ServletException e) {
        throw new RuntimeException(e);
    }
    DefaultServer.setRootHandler(pathHandler);
}
Also used : ServletException(javax.servlet.ServletException) DeploymentManager(io.undertow.servlet.api.DeploymentManager) ServletContainer(io.undertow.servlet.api.ServletContainer) PathHandler(io.undertow.server.handlers.PathHandler) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) SimpleServletTestCase(io.undertow.servlet.test.SimpleServletTestCase) BeforeClass(org.junit.BeforeClass)

Example 38 with DeploymentManager

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

the class RequestPathTestCase method setup.

@BeforeClass
public static void setup() throws ServletException {
    final PathHandler pathHandler = new PathHandler();
    final ServletContainer container = ServletContainer.Factory.newInstance();
    DeploymentInfo builder = new DeploymentInfo().setClassLoader(SimpleServletTestCase.class.getClassLoader()).setContextPath("/servletContext").setClassIntrospecter(TestClassIntrospector.INSTANCE).setDeploymentName("servletContext.war").addServlets(new ServletInfo("request", RequestPathServlet.class).addMapping("/req/*"), new ServletInfo("DefaultServlet", RequestPathServlet.class).addMapping("/"), new ServletInfo("ExactServlet", RequestPathServlet.class).addMapping("/exact"), new ServletInfo("ExactTxtServlet", RequestPathServlet.class).addMapping("/exact.txt"), new ServletInfo("HtmlServlet", RequestPathServlet.class).addMapping("*.html")).addFilters(new FilterInfo("header", SetHeaderFilter.class).addInitParam("header", "Filter").addInitParam("value", "true"), new FilterInfo("all", SetHeaderFilter.class).addInitParam("header", "all").addInitParam("value", "true")).addFilterUrlMapping("header", "*.txt", DispatcherType.REQUEST).addFilterUrlMapping("all", "/*", DispatcherType.REQUEST);
    DeploymentManager manager = container.addDeployment(builder);
    manager.deploy();
    try {
        pathHandler.addPrefixPath(builder.getContextPath(), manager.start());
    } catch (ServletException e) {
        throw new RuntimeException(e);
    }
    DefaultServer.setRootHandler(pathHandler);
}
Also used : ServletInfo(io.undertow.servlet.api.ServletInfo) ServletException(javax.servlet.ServletException) DeploymentManager(io.undertow.servlet.api.DeploymentManager) ServletContainer(io.undertow.servlet.api.ServletContainer) PathHandler(io.undertow.server.handlers.PathHandler) SetHeaderFilter(io.undertow.servlet.test.util.SetHeaderFilter) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) FilterInfo(io.undertow.servlet.api.FilterInfo) BeforeClass(org.junit.BeforeClass)

Example 39 with DeploymentManager

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

the class RequestListenerAsyncRequestTestCase method setup.

@BeforeClass
public static void setup() throws ServletException {
    final PathHandler root = new PathHandler();
    final ServletContainer container = ServletContainer.Factory.newInstance();
    ServletInfo m = new ServletInfo("messageServlet", MessageServlet.class).addInitParam(MessageServlet.MESSAGE, HELLO_WORLD).setAsyncSupported(true).addMapping("/message");
    ServletInfo a = new ServletInfo("asyncServlet", AsyncServlet.class).addInitParam(MessageServlet.MESSAGE, HELLO_WORLD).setAsyncSupported(true).addMapping("/async");
    ServletInfo a2 = new ServletInfo("asyncServlet2", AnotherAsyncServlet.class).setAsyncSupported(true).addMapping("/async2");
    DeploymentInfo builder = new DeploymentInfo().setClassLoader(SimpleServletTestCase.class.getClassLoader()).setContextPath("/servletContext").setClassIntrospecter(TestClassIntrospector.INSTANCE).setDeploymentName("servletContext.war").addServlets(m, a, a2).addListener(new ListenerInfo(TestListener.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) TestListener(io.undertow.servlet.test.util.TestListener) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) MessageServlet(io.undertow.servlet.test.util.MessageServlet) BeforeClass(org.junit.BeforeClass)

Example 40 with DeploymentManager

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

the class FilterPathMappingTestCase method test_WFLY_1935.

@Test
public void test_WFLY_1935() throws IOException, ServletException {
    DeploymentInfo builder = new DeploymentInfo();
    final PathHandler root = new PathHandler();
    final ServletContainer container = ServletContainer.Factory.newInstance();
    builder.addServlet(new ServletInfo("*.a", PathMappingServlet.class).addMapping("*.a"));
    builder.addFilter(new FilterInfo("/*", PathFilter.class));
    builder.addFilterUrlMapping("/*", "/*", DispatcherType.REQUEST);
    //non standard, but we still support it
    builder.addFilter(new FilterInfo("/SimpleServlet.a", PathFilter.class));
    builder.addFilterUrlMapping("/SimpleServlet.a", "/SimpleServlet.a", DispatcherType.REQUEST);
    builder.setClassIntrospecter(TestClassIntrospector.INSTANCE).setClassLoader(FilterPathMappingTestCase.class.getClassLoader()).setContextPath("/servletContext").setDeploymentName("servletContext.war");
    final DeploymentManager manager = container.addDeployment(builder);
    manager.deploy();
    root.addPrefixPath(builder.getContextPath(), manager.start());
    DefaultServer.setRootHandler(root);
    TestHttpClient client = new TestHttpClient();
    try {
        runTest(client, "SimpleServlet.a", "*.a - /SimpleServlet.a - null", "/*", "/SimpleServlet.a");
    } finally {
        client.getConnectionManager().shutdown();
    }
}
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) FilterInfo(io.undertow.servlet.api.FilterInfo) TestHttpClient(io.undertow.testutils.TestHttpClient) Test(org.junit.Test)

Aggregations

DeploymentManager (io.undertow.servlet.api.DeploymentManager)84 DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)75 ServletContainer (io.undertow.servlet.api.ServletContainer)69 PathHandler (io.undertow.server.handlers.PathHandler)58 BeforeClass (org.junit.BeforeClass)53 ServletInfo (io.undertow.servlet.api.ServletInfo)51 TestResourceLoader (io.undertow.servlet.test.util.TestResourceLoader)17 FilterInfo (io.undertow.servlet.api.FilterInfo)16 SimpleServletTestCase (io.undertow.servlet.test.SimpleServletTestCase)16 ServletException (javax.servlet.ServletException)14 WebSocketDeploymentInfo (io.undertow.websockets.jsr.WebSocketDeploymentInfo)13 LoginConfig (io.undertow.servlet.api.LoginConfig)12 ServletIdentityManager (io.undertow.servlet.test.security.constraint.ServletIdentityManager)10 ListenerInfo (io.undertow.servlet.api.ListenerInfo)8 SecurityConstraint (io.undertow.servlet.api.SecurityConstraint)8 WebResourceCollection (io.undertow.servlet.api.WebResourceCollection)8 ServerWebSocketContainer (io.undertow.websockets.jsr.ServerWebSocketContainer)8 Test (org.junit.Test)8 TestHttpClient (io.undertow.testutils.TestHttpClient)7 ServletSecurityInfo (io.undertow.servlet.api.ServletSecurityInfo)5