From 16c406b55c5ca16ab7a1a236cd93adea72dd2f9e Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Tue, 14 Jan 2020 15:15:56 +1100 Subject: [PATCH] Issue #4475 - add test for fragmented frames Signed-off-by: Lachlan Roberts --- .../jsr356/server/TextStreamTest.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/TextStreamTest.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/TextStreamTest.java index d241fd4d4a4..f8418f79927 100644 --- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/TextStreamTest.java +++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/TextStreamTest.java @@ -155,6 +155,31 @@ public class TextStreamTest } } + @Test + public void testFragmented() throws Exception + { + URI uri = URI.create("ws://localhost:" + connector.getLocalPort() + "/test"); + ClientTextStreamer client = new ClientTextStreamer(); + Session session = wsClient.connectToServer(client, uri); + + final int numLoops = 20; + for (int i = 0; i < numLoops; i++) + { + session.getBasicRemote().sendText("firstFrame" + i, false); + session.getBasicRemote().sendText("|secondFrame" + i, false); + session.getBasicRemote().sendText("|finalFrame" + i, true); + } + session.close(); + + QueuedTextStreamer queuedTextStreamer = queuedTextStreamerFuture.get(5, TimeUnit.SECONDS); + for (int i = 0; i < numLoops; i++) + { + String msg = queuedTextStreamer.messages.poll(5, TimeUnit.SECONDS); + String expected = "firstFrame" + i + "|secondFrame" + i + "|finalFrame" + i; + assertThat(msg, Matchers.is(expected)); + } + } + private char[] randomChars(int size) { char[] data = new char[size];