use of io.undertow.servlet.api.ServletContainer in project undertow by undertow-io.
the class WebsocketStressTestCase method setup.
@BeforeClass
public static void setup() throws Exception {
defaultContainer = ContainerProvider.getWebSocketContainer();
executor = Executors.newFixedThreadPool(NUM_THREADS);
final ServletContainer container = ServletContainer.Factory.newInstance();
DeploymentInfo builder = new DeploymentInfo().setClassLoader(WebsocketStressTestCase.class.getClassLoader()).setContextPath("/ws").setResourceManager(new TestResourceLoader(WebsocketStressTestCase.class)).setClassIntrospecter(TestClassIntrospector.INSTANCE).addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, new WebSocketDeploymentInfo().setBuffers(DefaultServer.getBufferPool()).setWorker(DefaultServer.getWorker()).addEndpoint(StressEndpoint.class).setDispatchToWorkerThread(true).addListener(containerReady -> deployment = containerReady)).setDeploymentName("servletContext.war");
deploymentManager = container.addDeployment(builder);
deploymentManager.deploy();
DefaultServer.setRootHandler(Handlers.path().addPrefixPath("/ws", deploymentManager.start()));
}
use of io.undertow.servlet.api.ServletContainer in project undertow by undertow-io.
the class ProgramaticLazyEndpointTest method setup.
@BeforeClass
public static void setup() throws Exception {
final ServletContainer container = ServletContainer.Factory.newInstance();
DeploymentInfo builder = new DeploymentInfo().setClassLoader(ProgramaticLazyEndpointTest.class.getClassLoader()).setContextPath("/").setClassIntrospecter(TestClassIntrospector.INSTANCE).addServlet(Servlets.servlet("add", AddEndpointServlet.class).setLoadOnStartup(100)).addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, new WebSocketDeploymentInfo().setBuffers(DefaultServer.getBufferPool()).setWorker(DefaultServer.getWorker()).addListener(container1 -> deployment = container1)).setDeploymentName("servletContext.war");
deploymentManager = container.addDeployment(builder);
deploymentManager.deploy();
DefaultServer.setRootHandler(deploymentManager.start());
DefaultServer.startSSLServer();
}
use of io.undertow.servlet.api.ServletContainer in project cxf by apache.
the class UndertowHTTPServerEngine method buildServletContext.
private ServletContext buildServletContext(String contextName) throws ServletException {
ServletContainer servletContainer = new ServletContainerImpl();
DeploymentInfo deploymentInfo = new DeploymentInfo();
deploymentInfo.setClassLoader(Thread.currentThread().getContextClassLoader());
deploymentInfo.setDeploymentName("cxf-undertow");
deploymentInfo.setContextPath(contextName);
ServletInfo asyncServlet = new ServletInfo(ServletPathMatches.DEFAULT_SERVLET_NAME, CxfUndertowServlet.class);
deploymentInfo.addServlet(asyncServlet);
servletContainer.addDeployment(deploymentInfo);
DeploymentManager deploymentManager = servletContainer.getDeployment(deploymentInfo.getDeploymentName());
deploymentManager.deploy();
deploymentManager.start();
return deploymentManager.getDeployment().getServletContext();
}
use of io.undertow.servlet.api.ServletContainer in project undertow by undertow-io.
the class SuspendResumeTestCase method setup.
@BeforeClass
public static void setup() throws ServletException {
final ServletContainer container = ServletContainer.Factory.newInstance();
DeploymentInfo builder = new DeploymentInfo().setClassLoader(TestMessagesReceivedInOrder.class.getClassLoader()).setContextPath("/").setResourceManager(new TestResourceLoader(TestMessagesReceivedInOrder.class)).setClassIntrospecter(TestClassIntrospector.INSTANCE).addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, new WebSocketDeploymentInfo().setBuffers(DefaultServer.getBufferPool()).setWorker(DefaultServer.getWorker()).addListener(new WebSocketDeploymentInfo.ContainerReadyListener() {
@Override
public void ready(ServerWebSocketContainer c) {
serverContainer = c;
}
}).addEndpoint(SuspendResumeEndpoint.class)).setDeploymentName("servletContext.war");
DeploymentManager manager = container.addDeployment(builder);
manager.deploy();
DefaultServer.setRootHandler(Handlers.path().addPrefixPath("/", manager.start()));
}
use of io.undertow.servlet.api.ServletContainer in project undertow by undertow-io.
the class ServletFormAuthDefaultPageTestCase method setup.
@BeforeClass
public static void setup() throws ServletException {
final PathHandler path = new PathHandler();
final ServletContainer container = ServletContainer.Factory.newInstance();
ServletInfo s = new ServletInfo("servlet", SendUsernameServlet.class).setServletSecurityInfo(new ServletSecurityInfo().addRoleAllowed("role1")).addMapping("/secured/*");
ServletInfo echo = new ServletInfo("echo", EchoServlet.class).setServletSecurityInfo(new ServletSecurityInfo().addRoleAllowed("role1")).addMapping("/secured/echo");
ServletInfo echoParam = new ServletInfo("echoParam", RequestParamEchoServlet.class).setServletSecurityInfo(new ServletSecurityInfo().addRoleAllowed("role1")).addMapping("/secured/echoParam");
ServletInfo s1 = new ServletInfo("loginPage", FormLoginServlet.class).setServletSecurityInfo(new ServletSecurityInfo().addRoleAllowed("group1")).addMapping("/FormLoginServlet");
ServletIdentityManager identityManager = new ServletIdentityManager();
identityManager.addUser("user1", "password1", "role1");
Map<String, String> props = new HashMap<>();
props.put("default_page", "/main.html");
props.put("override_initial", "true");
AuthMethodConfig authMethodConfig = new AuthMethodConfig("FORM", props);
LoginConfig loginConfig = new LoginConfig("Test Realm", "/FormLoginServlet", "/error.html").addFirstAuthMethod(authMethodConfig);
DeploymentInfo builder = new DeploymentInfo().setClassLoader(SimpleServletTestCase.class.getClassLoader()).setContextPath("/servletContext").setClassIntrospecter(TestClassIntrospector.INSTANCE).setDeploymentName("servletContext.war").setAuthenticationMode(AuthenticationMode.CONSTRAINT_DRIVEN).setIdentityManager(identityManager).setLoginConfig(loginConfig).addServlets(s, s1, echo, echoParam);
DeploymentManager manager = container.addDeployment(builder);
manager.deploy();
path.addPrefixPath(builder.getContextPath(), manager.start());
DefaultServer.setRootHandler(path);
}
Aggregations