Search in sources :

Example 11 with FrameChecker

use of io.undertow.websockets.utils.FrameChecker in project undertow by undertow-io.

the class AnnotatedEndpointTest method testEncodingAndDecodingText.

@Test
public void testEncodingAndDecodingText() throws Exception {
    final byte[] payload = "hello".getBytes();
    final FutureResult<?> latch = new FutureResult<>();
    WebSocketTestClient client = new WebSocketTestClient(WebSocketVersion.V13, new URI("ws://" + DefaultServer.getHostAddress("default") + ":" + DefaultServer.getHostPort("default") + "/ws/encoding/Stuart"));
    client.connect();
    client.send(new TextWebSocketFrame(Unpooled.wrappedBuffer(payload)), new FrameChecker(TextWebSocketFrame.class, "hello Stuart".getBytes(), latch));
    latch.getIoFuture().get();
    client.destroy();
}
Also used : WebSocketTestClient(io.undertow.websockets.utils.WebSocketTestClient) FutureResult(org.xnio.FutureResult) TextWebSocketFrame(io.netty.handler.codec.http.websocketx.TextWebSocketFrame) FrameChecker(io.undertow.websockets.utils.FrameChecker) URI(java.net.URI) Test(org.junit.Test)

Example 12 with FrameChecker

use of io.undertow.websockets.utils.FrameChecker in project undertow by undertow-io.

the class AnnotatedEndpointTest method testStringOnMessageAddedProgramatically.

@Test
public void testStringOnMessageAddedProgramatically() throws Exception {
    final byte[] payload = "foo".getBytes();
    final FutureResult<?> latch = new FutureResult<>();
    WebSocketTestClient client = new WebSocketTestClient(WebSocketVersion.V13, new URI("ws://" + DefaultServer.getHostAddress("default") + ":" + DefaultServer.getHostPort("default") + "/ws/programmatic"));
    client.connect();
    client.send(new TextWebSocketFrame(Unpooled.wrappedBuffer(payload)), new FrameChecker(TextWebSocketFrame.class, "oof".getBytes(), latch));
    latch.getIoFuture().get();
    client.destroy();
}
Also used : WebSocketTestClient(io.undertow.websockets.utils.WebSocketTestClient) FutureResult(org.xnio.FutureResult) TextWebSocketFrame(io.netty.handler.codec.http.websocketx.TextWebSocketFrame) FrameChecker(io.undertow.websockets.utils.FrameChecker) URI(java.net.URI) Test(org.junit.Test)

Example 13 with FrameChecker

use of io.undertow.websockets.utils.FrameChecker in project undertow by undertow-io.

the class AnnotatedEndpointTest method testEncodingWithGenericSuperclass.

@Test
public void testEncodingWithGenericSuperclass() throws Exception {
    final byte[] payload = "hello".getBytes();
    final FutureResult<?> latch = new FutureResult<>();
    WebSocketTestClient client = new WebSocketTestClient(WebSocketVersion.V13, new URI("ws://" + DefaultServer.getHostAddress("default") + ":" + DefaultServer.getHostPort("default") + "/ws/encodingGenerics/Stuart"));
    client.connect();
    client.send(new TextWebSocketFrame(Unpooled.wrappedBuffer(payload)), new FrameChecker(TextWebSocketFrame.class, "hello Stuart".getBytes(), latch));
    latch.getIoFuture().get();
    client.destroy();
}
Also used : WebSocketTestClient(io.undertow.websockets.utils.WebSocketTestClient) FutureResult(org.xnio.FutureResult) TextWebSocketFrame(io.netty.handler.codec.http.websocketx.TextWebSocketFrame) FrameChecker(io.undertow.websockets.utils.FrameChecker) URI(java.net.URI) Test(org.junit.Test)

Example 14 with FrameChecker

use of io.undertow.websockets.utils.FrameChecker in project undertow by undertow-io.

the class AnnotatedEndpointTest method testStringOnMessage.

@Test
public void testStringOnMessage() throws Exception {
    final byte[] payload = "hello".getBytes();
    final FutureResult<?> latch = new FutureResult<>();
    WebSocketTestClient client = new WebSocketTestClient(WebSocketVersion.V13, new URI("ws://" + DefaultServer.getHostAddress("default") + ":" + DefaultServer.getHostPort("default") + "/ws/chat/Stuart"));
    client.connect();
    client.send(new TextWebSocketFrame(Unpooled.wrappedBuffer(payload)), new FrameChecker(TextWebSocketFrame.class, "hello Stuart".getBytes(), latch));
    latch.getIoFuture().get();
    client.destroy();
}
Also used : WebSocketTestClient(io.undertow.websockets.utils.WebSocketTestClient) FutureResult(org.xnio.FutureResult) TextWebSocketFrame(io.netty.handler.codec.http.websocketx.TextWebSocketFrame) FrameChecker(io.undertow.websockets.utils.FrameChecker) URI(java.net.URI) Test(org.junit.Test)

Example 15 with FrameChecker

use of io.undertow.websockets.utils.FrameChecker in project undertow by undertow-io.

the class AnnotatedEndpointTest method testEncodingAndDecodingBinary.

@Test
public void testEncodingAndDecodingBinary() throws Exception {
    final byte[] payload = "hello".getBytes();
    final FutureResult<?> latch = new FutureResult<>();
    WebSocketTestClient client = new WebSocketTestClient(WebSocketVersion.V13, new URI("ws://" + DefaultServer.getHostAddress("default") + ":" + DefaultServer.getHostPort("default") + "/ws/encoding/Stuart"));
    client.connect();
    client.send(new BinaryWebSocketFrame(Unpooled.wrappedBuffer(payload)), new FrameChecker(TextWebSocketFrame.class, "hello Stuart".getBytes(), latch));
    latch.getIoFuture().get();
    client.destroy();
}
Also used : WebSocketTestClient(io.undertow.websockets.utils.WebSocketTestClient) FutureResult(org.xnio.FutureResult) FrameChecker(io.undertow.websockets.utils.FrameChecker) TextWebSocketFrame(io.netty.handler.codec.http.websocketx.TextWebSocketFrame) BinaryWebSocketFrame(io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame) URI(java.net.URI) Test(org.junit.Test)

Aggregations

FrameChecker (io.undertow.websockets.utils.FrameChecker)30 WebSocketTestClient (io.undertow.websockets.utils.WebSocketTestClient)30 URI (java.net.URI)30 FutureResult (org.xnio.FutureResult)30 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)19 TextWebSocketFrame (io.netty.handler.codec.http.websocketx.TextWebSocketFrame)18 Test (org.junit.Test)16 ServerWebSocketContainer (io.undertow.websockets.jsr.ServerWebSocketContainer)14 UndertowSession (io.undertow.websockets.jsr.UndertowSession)14 AnnotatedClientEndpoint (io.undertow.websockets.jsr.test.annotated.AnnotatedClientEndpoint)14 AtomicReference (java.util.concurrent.atomic.AtomicReference)14 Endpoint (javax.websocket.Endpoint)14 EndpointConfig (javax.websocket.EndpointConfig)14 Session (javax.websocket.Session)14 ServerEndpointConfig (javax.websocket.server.ServerEndpointConfig)14 MessageHandler (javax.websocket.MessageHandler)11 BinaryWebSocketFrame (io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame)9 ByteBuffer (java.nio.ByteBuffer)9 IOException (java.io.IOException)8 WebSocketConnectionCallback (io.undertow.websockets.WebSocketConnectionCallback)5