431459 - Jetty WebSocket compression extensions fails to handle big messages properly

+ Setting up Assume for deregistered compression extension tests
This commit is contained in:
Joakim Erdfelt 2014-05-05 11:37:35 -07:00
parent c03388b640
commit c0e0f9bb83
4 changed files with 23 additions and 2 deletions

View File

@ -30,6 +30,7 @@ import org.eclipse.jetty.websocket.common.test.HttpResponse;
import org.eclipse.jetty.websocket.server.examples.MyEchoServlet; import org.eclipse.jetty.websocket.server.examples.MyEchoServlet;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Assume;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@ -53,6 +54,8 @@ public class ChromeTest
@Test @Test
public void testUpgradeWithWebkitDeflateExtension() throws Exception public void testUpgradeWithWebkitDeflateExtension() throws Exception
{ {
Assume.assumeTrue("Server has x-webkit-deflate-frame registered",server.getWebSocketServletFactory().getExtensionFactory().isAvailable("x-webkit-deflate-frame"));
BlockheadClient client = new BlockheadClient(server.getServerUri()); BlockheadClient client = new BlockheadClient(server.getServerUri());
try try
{ {

View File

@ -57,6 +57,9 @@ public class PerMessageDeflateExtensionTest
@Test @Test
public void testPerMessageDeflateDefault() throws Exception public void testPerMessageDeflateDefault() throws Exception
{ {
Assume.assumeTrue("Server has x-webkit-deflate-frame registered",
server.getWebSocketServletFactory().getExtensionFactory().isAvailable("permessage-deflate"));
BlockheadClient client = new BlockheadClient(server.getServerUri()); BlockheadClient client = new BlockheadClient(server.getServerUri());
client.clearExtensions(); client.clearExtensions();
client.addExtensions("permessage-deflate"); client.addExtensions("permessage-deflate");
@ -70,8 +73,7 @@ public class PerMessageDeflateExtensionTest
client.sendStandardRequest(); client.sendStandardRequest();
HttpResponse resp = client.expectUpgradeResponse(); HttpResponse resp = client.expectUpgradeResponse();
// Stop test here if server doesn't have permessage-deflate enabled. Assert.assertThat("Response",resp.getExtensionsHeader(),containsString("permessage-deflate"));
Assume.assumeThat("Response",resp.getExtensionsHeader(),containsString("permessage-deflate"));
String msg = "Hello"; String msg = "Hello";

View File

@ -34,6 +34,7 @@ import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.util.log.Logger;
import org.eclipse.jetty.util.ssl.SslContextFactory; import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
public class SimpleServletServer public class SimpleServletServer
{ {
@ -147,4 +148,17 @@ public class SimpleServletServer
e.printStackTrace(System.err); e.printStackTrace(System.err);
} }
} }
public WebSocketServletFactory getWebSocketServletFactory()
{
// Try filter approach first
WebSocketUpgradeFilter filter = (WebSocketUpgradeFilter)this.servlet.getServletContext().getAttribute(WebSocketUpgradeFilter.class.getName());
if (filter != null)
{
return filter.getFactory();
}
// Try servlet next
return (WebSocketServletFactory)this.servlet.getServletContext().getAttribute(WebSocketServletFactory.class.getName());
}
} }

View File

@ -130,6 +130,8 @@ public abstract class WebSocketServlet extends HttpServlet
configure(factory); configure(factory);
factory.init(); factory.init();
getServletContext().setAttribute(WebSocketServletFactory.class.getName(),factory);
} }
catch (Exception x) catch (Exception x)
{ {