use of io.undertow.servlet.test.util.TestResourceLoader in project undertow by undertow-io.
the class ClientEndpointReconnectTestCase method setup.
@BeforeClass
public static void setup() throws Exception {
final ServletContainer container = ServletContainer.Factory.newInstance();
DeploymentInfo builder = new DeploymentInfo().setClassLoader(ClientEndpointReconnectTestCase.class.getClassLoader()).setContextPath("/ws").setResourceManager(new TestResourceLoader(ClientEndpointReconnectTestCase.class)).setClassIntrospecter(TestClassIntrospector.INSTANCE).addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, new WebSocketDeploymentInfo().setBuffers(new DefaultByteBufferPool(true, 8192)).setWorker(DefaultServer.getWorker()).addEndpoint(DisconnectServerEndpoint.class).addEndpoint(AnnotatedClientReconnectEndpoint.class).addListener(new WebSocketDeploymentInfo.ContainerReadyListener() {
@Override
public void ready(ServerWebSocketContainer container) {
deployment = container;
}
}).setReconnectHandler(new WebSocketReconnectHandler() {
@Override
public long disconnected(CloseReason closeReason, URI connectionUri, Session session, int disconnectCount) {
if (disconnectCount < 3) {
return 1;
} else {
return -1;
}
}
@Override
public long reconnectFailed(IOException exception, URI connectionUri, Session session, int failedCount) {
failed = true;
return -1;
}
})).setDeploymentName("servletContext.war");
DeploymentManager manager = container.addDeployment(builder);
manager.deploy();
DefaultServer.setRootHandler(Handlers.path().addPrefixPath("/ws", manager.start()));
}
use of io.undertow.servlet.test.util.TestResourceLoader in project undertow by undertow-io.
the class TestMessagesReceivedInOrder 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()).addEndpoint(EchoSocket.class)).setDeploymentName("servletContext.war");
DeploymentManager manager = container.addDeployment(builder);
manager.deploy();
DefaultServer.setRootHandler(Handlers.path().addPrefixPath("/", manager.start()));
}
use of io.undertow.servlet.test.util.TestResourceLoader in project undertow by undertow-io.
the class AnnotatedEndpointTest method setup.
@BeforeClass
public static void setup() throws Exception {
final ServletContainer container = ServletContainer.Factory.newInstance();
DeploymentInfo builder = new DeploymentInfo().setClassLoader(AnnotatedEndpointTest.class.getClassLoader()).setContextPath("/ws").setResourceManager(new TestResourceLoader(AnnotatedEndpointTest.class)).setClassIntrospecter(TestClassIntrospector.INSTANCE).addServletContextAttribute(WebSocketDeploymentInfo.ATTRIBUTE_NAME, new WebSocketDeploymentInfo().setBuffers(DefaultServer.getBufferPool()).setWorker(DefaultServer.getWorker()).addEndpoint(MessageEndpoint.class).addEndpoint(AnnotatedClientEndpoint.class).addEndpoint(AnnotatedClientEndpointWithConfigurator.class).addEndpoint(IncrementEndpoint.class).addEndpoint(EncodingEndpoint.class).addEndpoint(EncodingGenericsEndpoint.class).addEndpoint(TimeoutEndpoint.class).addEndpoint(ErrorEndpoint.class).addEndpoint(RootContextEndpoint.class).addEndpoint(ThreadSafetyEndpoint.class).addEndpoint(RequestUriEndpoint.class).addListener(new WebSocketDeploymentInfo.ContainerReadyListener() {
@Override
public void ready(ServerWebSocketContainer container) {
deployment = container;
}
})).addServlet(new ServletInfo("redirect", RedirectServlet.class).addMapping("/redirect")).setDeploymentName("servletContext.war");
DeploymentManager manager = container.addDeployment(builder);
manager.deploy();
DefaultServer.setRootHandler(Handlers.path().addPrefixPath("/ws", manager.start()));
}
use of io.undertow.servlet.test.util.TestResourceLoader in project undertow by undertow-io.
the class WebsocketStressTestCase method setup.
@BeforeClass
public static void setup() throws Exception {
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).addListener(new WebSocketDeploymentInfo.ContainerReadyListener() {
@Override
public void ready(ServerWebSocketContainer container) {
deployment = container;
}
})).setDeploymentName("servletContext.war");
DeploymentManager manager = container.addDeployment(builder);
manager.deploy();
DefaultServer.setRootHandler(Handlers.path().addPrefixPath("/ws", manager.start()));
}
use of io.undertow.servlet.test.util.TestResourceLoader in project undertow by undertow-io.
the class SaveOriginalPostRequestTestCase method setup.
@BeforeClass
public static void setup() throws ServletException {
final PathHandler path = new PathHandler();
final ServletContainer container = ServletContainer.Factory.newInstance();
ServletInfo securedRequestDumper = new ServletInfo("SecuredRequestDumperServlet", RequestDumper.class).setServletSecurityInfo(new ServletSecurityInfo().addRoleAllowed("role1")).addMapping("/secured/dumpRequest");
ServletInfo securedIndexRequestDumper = new ServletInfo("SecuredIndexRequestDumperServlet", RequestDumper.class).setServletSecurityInfo(new ServletSecurityInfo().addRoleAllowed("role1")).addMapping("/index.html");
ServletInfo unsecuredRequestDumper = new ServletInfo("UnsecuredRequestDumperServlet", RequestDumper.class).addMapping("/dumpRequest");
ServletInfo loginFormServlet = new ServletInfo("loginPage", FormLoginServlet.class).setServletSecurityInfo(new ServletSecurityInfo().addRoleAllowed("group1")).addMapping("/FormLoginServlet");
ServletIdentityManager identityManager = new ServletIdentityManager();
identityManager.addUser("user1", "password1", "role1");
DeploymentInfo builder = new DeploymentInfo().setClassLoader(SimpleServletTestCase.class.getClassLoader()).setContextPath("/servletContext").setClassIntrospecter(TestClassIntrospector.INSTANCE).setDeploymentName("servletContext.war").setIdentityManager(identityManager).addWelcomePage("index.html").setResourceManager(new TestResourceLoader(SaveOriginalPostRequestTestCase.class)).setLoginConfig(new LoginConfig("FORM", "Test Realm", "/FormLoginServlet", "/error.html")).addServlets(securedRequestDumper, unsecuredRequestDumper, loginFormServlet, securedIndexRequestDumper);
DeploymentManager manager = container.addDeployment(builder);
manager.deploy();
path.addPrefixPath(builder.getContextPath(), manager.start());
DefaultServer.setRootHandler(path);
}
Aggregations