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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations