Search in sources :

Example 86 with ServletContainer

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

the class ProxyXForwardedTestCase method setup.

@BeforeClass
public static void setup() throws ServletException {
    PORT = DefaultServer.getHostPort("default");
    final PathHandler root = new PathHandler();
    final ServletContainer container = ServletContainer.Factory.newInstance();
    ServletInfo s = new ServletInfo("servlet", ProxyPeerXForwardedHandlerServlet.class).addMapping("/proxyPeerHandler");
    DeploymentInfo builder = new DeploymentInfo().setClassLoader(SimpleServletTestCase.class.getClassLoader()).setContextPath("/servletContext").setClassIntrospecter(TestClassIntrospector.INSTANCE).setDeploymentName("servletContext.war").addServlet(s);
    DeploymentManager manager = container.addDeployment(builder);
    manager.deploy();
    HttpHandler startHandler = manager.start();
    startHandler = new ProxyPeerAddressHandler(startHandler, false);
    root.addPrefixPath(builder.getContextPath(), startHandler);
    DefaultServer.setRootHandler(root);
}
Also used : ServletInfo(io.undertow.servlet.api.ServletInfo) HttpHandler(io.undertow.server.HttpHandler) ProxyPeerXForwardedHandlerServlet(io.undertow.servlet.test.util.ProxyPeerXForwardedHandlerServlet) DeploymentManager(io.undertow.servlet.api.DeploymentManager) ServletContainer(io.undertow.servlet.api.ServletContainer) ProxyPeerAddressHandler(io.undertow.server.handlers.ProxyPeerAddressHandler) PathHandler(io.undertow.server.handlers.PathHandler) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) BeforeClass(org.junit.BeforeClass)

Example 87 with ServletContainer

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

the class DefaultServletCachingListenerTestCase method setup.

@BeforeClass
public static void setup() throws ServletException, IOException {
    tmpDir = Files.createTempDirectory(DIR_NAME);
    // assume tmp is in the default file system and watch-service is not the slow polling impl
    Assume.assumeTrue("WatchService is going to work OK", FileSystems.getDefault().equals(tmpDir.getFileSystem()) && !FileSystems.getDefault().newWatchService().getClass().getName().equals("sun.nio.fs.PollingWatchService"));
    final PathHandler root = new PathHandler();
    final ServletContainer container = ServletContainer.Factory.newInstance();
    DeploymentInfo builder = new DeploymentInfo().setClassIntrospecter(TestClassIntrospector.INSTANCE).setClassLoader(ServletPathMappingTestCase.class.getClassLoader()).setContextPath("/servletContext").addWelcomePage("index.html").setDeploymentName("servletContext.war").setResourceManager(new CachingResourceManager(100, MAX_FILE_SIZE, dataCache, new PathResourceManager(tmpDir, 10485760, false, false, true), -1));
    builder.addServlet(new ServletInfo("DefaultTestServlet", PathTestServlet.class).addMapping("/path/default")).addFilter(Servlets.filter("message", MessageFilter.class).addInitParam(MessageFilter.MESSAGE, "FILTER_TEXT ")).addFilterUrlMapping("message", "*.txt", DispatcherType.REQUEST);
    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) CachingResourceManager(io.undertow.server.handlers.resource.CachingResourceManager) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) MessageFilter(io.undertow.servlet.test.util.MessageFilter) ServletPathMappingTestCase(io.undertow.servlet.test.path.ServletPathMappingTestCase) PathResourceManager(io.undertow.server.handlers.resource.PathResourceManager) BeforeClass(org.junit.BeforeClass)

Example 88 with ServletContainer

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

the class SimpleServletTestCase method setup.

@BeforeClass
public static void setup() throws ServletException {
    final PathHandler root = new PathHandler();
    final ServletContainer container = ServletContainer.Factory.newInstance();
    ServletInfo s = new ServletInfo("servlet", MessageServlet.class).addInitParam(MessageServlet.MESSAGE, HELLO_WORLD).addMapping("/aa");
    DeploymentInfo builder = new DeploymentInfo().setClassLoader(SimpleServletTestCase.class.getClassLoader()).setContextPath("/servletContext").setClassIntrospecter(TestClassIntrospector.INSTANCE).setDeploymentName("servletContext.war").addServlet(s);
    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 89 with ServletContainer

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

the class CrossContextClassLoaderTestCase method setup.

@BeforeClass
public static void setup() throws ServletException {
    final PathHandler root = new PathHandler();
    final ServletContainer container = ServletContainer.Factory.newInstance();
    ServletInfo s = new ServletInfo("includer", IncludeServlet.class).addMapping("/a");
    DeploymentInfo builder = new DeploymentInfo().setClassLoader(new TempClassLoader("IncluderClassLoader")).setContextPath("/includer").setClassIntrospecter(TestClassIntrospector.INSTANCE).setDeploymentName("includer.war").addServlet(s);
    DeploymentManager manager = container.addDeployment(builder);
    manager.deploy();
    root.addPrefixPath(builder.getContextPath(), manager.start());
    s = new ServletInfo("included", IncludedServlet.class).addMapping("/a");
    builder = new DeploymentInfo().setClassLoader(new TempClassLoader("IncludedClassLoader")).setContextPath("/included").setClassIntrospecter(TestClassIntrospector.INSTANCE).setDeploymentName("included.war").addServlet(s);
    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 90 with ServletContainer

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

the class SecurityRedirectTestCase method setup.

@BeforeClass
public static void setup() throws ServletException {
    final PathHandler root = new PathHandler();
    final ServletContainer container = ServletContainer.Factory.newInstance();
    ServletIdentityManager identityManager = new ServletIdentityManager();
    identityManager.addUser("user1", "password1", "role1");
    DeploymentInfo builder = new DeploymentInfo().setClassIntrospecter(TestClassIntrospector.INSTANCE).setClassLoader(ServletPathMappingTestCase.class.getClassLoader()).setContextPath("/servletContext").setDeploymentName("servletContext.war").setResourceManager(new TestResourceLoader(SecurityRedirectTestCase.class)).addWelcomePages("index.html").setIdentityManager(identityManager).setLoginConfig(new LoginConfig("BASIC", "Test Realm")).addSecurityConstraint(new SecurityConstraint().addRoleAllowed("role1").addWebResourceCollection(new WebResourceCollection().addUrlPatterns("/index.html", "/filterpath/*")));
    DeploymentManager manager = container.addDeployment(builder);
    manager.deploy();
    root.addPrefixPath(builder.getContextPath(), manager.start());
    DefaultServer.setRootHandler(root);
}
Also used : WebResourceCollection(io.undertow.servlet.api.WebResourceCollection) TestResourceLoader(io.undertow.servlet.test.util.TestResourceLoader) DeploymentManager(io.undertow.servlet.api.DeploymentManager) ServletContainer(io.undertow.servlet.api.ServletContainer) LoginConfig(io.undertow.servlet.api.LoginConfig) PathHandler(io.undertow.server.handlers.PathHandler) DeploymentInfo(io.undertow.servlet.api.DeploymentInfo) ServletIdentityManager(io.undertow.servlet.test.security.constraint.ServletIdentityManager) SecurityConstraint(io.undertow.servlet.api.SecurityConstraint) BeforeClass(org.junit.BeforeClass)

Aggregations

ServletContainer (io.undertow.servlet.api.ServletContainer)92 DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)88 DeploymentManager (io.undertow.servlet.api.DeploymentManager)78 PathHandler (io.undertow.server.handlers.PathHandler)76 BeforeClass (org.junit.BeforeClass)69 ServletInfo (io.undertow.servlet.api.ServletInfo)65 TestResourceLoader (io.undertow.servlet.test.util.TestResourceLoader)20 SimpleServletTestCase (io.undertow.servlet.test.SimpleServletTestCase)19 ServletException (javax.servlet.ServletException)19 FilterInfo (io.undertow.servlet.api.FilterInfo)18 LoginConfig (io.undertow.servlet.api.LoginConfig)18 ServletIdentityManager (io.undertow.servlet.test.security.constraint.ServletIdentityManager)16 Test (org.junit.Test)15 WebSocketDeploymentInfo (io.undertow.websockets.jsr.WebSocketDeploymentInfo)14 SecurityConstraint (io.undertow.servlet.api.SecurityConstraint)12 WebResourceCollection (io.undertow.servlet.api.WebResourceCollection)12 ListenerInfo (io.undertow.servlet.api.ListenerInfo)10 TestHttpClient (io.undertow.testutils.TestHttpClient)9 ServletSecurityInfo (io.undertow.servlet.api.ServletSecurityInfo)8 AuthMethodConfig (io.undertow.servlet.api.AuthMethodConfig)7