Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Erdfelt2015-08-07 10:37:06 -0400
committerJoakim Erdfelt2015-08-07 10:37:06 -0400
commita71c543a7ed72af323ba6a02d9bed62477117b65 (patch)
tree637d329563a97f92e4f222f61f5d1695080a3cf0 /jetty-websocket/javax-websocket-server-impl
parent5c0906ed6cdff2e77073d788893a299925f79006 (diff)
downloadorg.eclipse.jetty.project-a71c543a7ed72af323ba6a02d9bed62477117b65.tar.gz
org.eclipse.jetty.project-a71c543a7ed72af323ba6a02d9bed62477117b65.tar.xz
org.eclipse.jetty.project-a71c543a7ed72af323ba6a02d9bed62477117b65.zip
Revert "Removing old websocket extensions x-webkit-deflate-frame and deflate-frame"
Diffstat (limited to 'jetty-websocket/javax-websocket-server-impl')
-rw-r--r--jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/ExtensionStackProcessingTest.java55
1 files changed, 54 insertions, 1 deletions
diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/ExtensionStackProcessingTest.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/ExtensionStackProcessingTest.java
index 30c2e9fd1a..3096f47a43 100644
--- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/ExtensionStackProcessingTest.java
+++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/ExtensionStackProcessingTest.java
@@ -39,7 +39,12 @@ import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.websocket.api.extensions.ExtensionFactory;
+import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames;
+import org.eclipse.jetty.websocket.client.io.WebSocketClientConnection;
+import org.eclipse.jetty.websocket.common.extensions.ExtensionStack;
+import org.eclipse.jetty.websocket.common.extensions.compress.DeflateFrameExtension;
import org.eclipse.jetty.websocket.jsr356.JsrExtension;
+import org.eclipse.jetty.websocket.jsr356.JsrSession;
import org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer;
import org.eclipse.jetty.websocket.jsr356.server.samples.echo.BasicEchoEndpoint;
import org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter;
@@ -83,7 +88,55 @@ public class ExtensionStackProcessingTest
{
server.stop();
}
-
+
+ @Test
+ public void testDeflateFrameExtension() throws Exception
+ {
+ Assume.assumeTrue("Server has deflate-frame extension registered",serverExtensionFactory.isAvailable("deflate-frame"));
+
+ ClientEndpointConfig config = ClientEndpointConfig.Builder.create()
+ .extensions(Arrays.<Extension>asList(new JsrExtension("deflate-frame")))
+ .build();
+
+ final String content = "deflate_me";
+ final CountDownLatch messageLatch = new CountDownLatch(1);
+ URI uri = URI.create("ws://localhost:" + connector.getLocalPort());
+ Session session = client.connectToServer(new EndpointAdapter()
+ {
+ @Override
+ public void onMessage(String message)
+ {
+ Assert.assertEquals(content, message);
+ messageLatch.countDown();
+ }
+ }, config, uri);
+
+ // Make sure everything is wired properly.
+ OutgoingFrames firstOut = ((JsrSession)session).getOutgoingHandler();
+ Assert.assertTrue(firstOut instanceof ExtensionStack);
+ ExtensionStack extensionStack = (ExtensionStack)firstOut;
+ Assert.assertTrue(extensionStack.isRunning());
+ OutgoingFrames secondOut = extensionStack.getNextOutgoing();
+ Assert.assertTrue(secondOut instanceof DeflateFrameExtension);
+ DeflateFrameExtension deflateExtension = (DeflateFrameExtension)secondOut;
+ Assert.assertTrue(deflateExtension.isRunning());
+ OutgoingFrames thirdOut = deflateExtension.getNextOutgoing();
+ Assert.assertTrue(thirdOut instanceof WebSocketClientConnection);
+
+ final CountDownLatch latch = new CountDownLatch(1);
+ session.getAsyncRemote().sendText(content, new SendHandler()
+ {
+ @Override
+ public void onResult(SendResult result)
+ {
+ latch.countDown();
+ }
+ });
+
+ Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
+ Assert.assertTrue(messageLatch.await(5, TimeUnit.SECONDS));
+ }
+
@Test
public void testPerMessageDeflateExtension() throws Exception
{

Back to the top