Search in sources :

Example 1 with AnnotatedClientEndpoint

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());
}
Also used : ServerWebSocketContainer(io.undertow.websockets.jsr.ServerWebSocketContainer) UndertowSession(io.undertow.websockets.jsr.UndertowSession) AnnotatedClientEndpoint(io.undertow.websockets.jsr.test.annotated.AnnotatedClientEndpoint) URI(java.net.URI) Session(javax.websocket.Session) UndertowSession(io.undertow.websockets.jsr.UndertowSession)

Aggregations

ServerWebSocketContainer (io.undertow.websockets.jsr.ServerWebSocketContainer)1 UndertowSession (io.undertow.websockets.jsr.UndertowSession)1 AnnotatedClientEndpoint (io.undertow.websockets.jsr.test.annotated.AnnotatedClientEndpoint)1 URI (java.net.URI)1 Session (javax.websocket.Session)1