From 05f397caa43ea11d5bd05ff8495ac538a16fa1df Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Wed, 14 Dec 2016 13:20:28 -0700 Subject: [PATCH] Issue #1114 - Adding initial stop/start test logic --- .../server/WebSocketUpgradeFilterTest.java | 43 ++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketUpgradeFilterTest.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketUpgradeFilterTest.java index fabffcc3405..b5474308cb4 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketUpgradeFilterTest.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketUpgradeFilterTest.java @@ -291,7 +291,7 @@ public class WebSocketUpgradeFilterTest } @Test - public void testConfiguration() throws Exception + public void testNormalConfiguration() throws Exception { URI destUri = serverUri.resolve("/info/"); @@ -311,4 +311,45 @@ public class WebSocketUpgradeFilterTest assertThat("payload", payload, containsString("session.maxTextMessageSize=" + (10 * 1024 * 1024))); } } + + @Test + public void testStopStartOfHandler() throws Exception + { + URI destUri = serverUri.resolve("/info/"); + + try (BlockheadClient client = new BlockheadClient(destUri)) + { + client.connect(); + client.sendStandardRequest(); + client.expectUpgradeResponse(); + + client.write(new TextFrame().setPayload("hello 1")); + + EventQueue frames = client.readFrames(1, 1000, TimeUnit.MILLISECONDS); + String payload = frames.poll().getPayloadAsUTF8(); + + // If we can connect and send a text message, we know that the endpoint was + // added properly, and the response will help us verify the policy configuration too + assertThat("payload", payload, containsString("session.maxTextMessageSize=" + (10 * 1024 * 1024))); + } + + server.getHandler().stop(); + server.getHandler().start(); + + try (BlockheadClient client = new BlockheadClient(destUri)) + { + client.connect(); + client.sendStandardRequest(); + client.expectUpgradeResponse(); + + client.write(new TextFrame().setPayload("hello 2")); + + EventQueue frames = client.readFrames(1, 1000, TimeUnit.MILLISECONDS); + String payload = frames.poll().getPayloadAsUTF8(); + + // If we can connect and send a text message, we know that the endpoint was + // added properly, and the response will help us verify the policy configuration too + assertThat("payload", payload, containsString("session.maxTextMessageSize=" + (10 * 1024 * 1024))); + } + } }