use of io.undertow.websockets.jsr.test.annotated.AnnotatedClientEndpoint in project undertow by undertow-io.
the class JsrWebSocketServer07Test method testErrorHandling.
// FIXME UNDERTOW-1862 @Test
public void testErrorHandling() throws Exception {
ServerWebSocketContainer builder = new ServerWebSocketContainer(TestClassIntrospector.INSTANCE, DefaultServer.getWorkerSupplier(), DefaultServer.getBufferPool(), Collections.emptyList(), false, false);
builder.addEndpoint(ServerEndpointConfig.Builder.create(ProgramaticErrorEndpoint.class, "/").configurator(new InstanceConfigurator(new ProgramaticErrorEndpoint())).build());
deployServlet(builder);
AnnotatedClientEndpoint c = new AnnotatedClientEndpoint();
Session session = ContainerProvider.getWebSocketContainer().connectToServer(c, new URI("ws://" + DefaultServer.getHostAddress("default") + ":" + DefaultServer.getHostPort("default") + "/"));
assertEquals("hi", ProgramaticErrorEndpoint.getMessage());
session.getAsyncRemote().sendText("app-error");
assertEquals("app-error", ProgramaticErrorEndpoint.getMessage());
assertEquals("ERROR: java.lang.RuntimeException", ProgramaticErrorEndpoint.getMessage());
assertTrue(c.isOpen());
session.getBasicRemote().sendText("io-error");
assertEquals("io-error", ProgramaticErrorEndpoint.getMessage());
assertEquals("ERROR: java.lang.RuntimeException", ProgramaticErrorEndpoint.getMessage());
assertTrue(c.isOpen());
((UndertowSession) session).forceClose();
assertEquals("CLOSED", ProgramaticErrorEndpoint.getMessage());
}
Aggregations