431459 - Jetty WebSocket compression extensions fails to handle big messages properly
+ Setting up Assume for deregistered compression extension tests
This commit is contained in:
parent
c03388b640
commit
c0e0f9bb83
|
@ -30,6 +30,7 @@ import org.eclipse.jetty.websocket.common.test.HttpResponse;
|
|||
import org.eclipse.jetty.websocket.server.examples.MyEchoServlet;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Assume;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -53,6 +54,8 @@ public class ChromeTest
|
|||
@Test
|
||||
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());
|
||||
try
|
||||
{
|
||||
|
|
|
@ -57,6 +57,9 @@ public class PerMessageDeflateExtensionTest
|
|||
@Test
|
||||
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());
|
||||
client.clearExtensions();
|
||||
client.addExtensions("permessage-deflate");
|
||||
|
@ -70,8 +73,7 @@ public class PerMessageDeflateExtensionTest
|
|||
client.sendStandardRequest();
|
||||
HttpResponse resp = client.expectUpgradeResponse();
|
||||
|
||||
// Stop test here if server doesn't have permessage-deflate enabled.
|
||||
Assume.assumeThat("Response",resp.getExtensionsHeader(),containsString("permessage-deflate"));
|
||||
Assert.assertThat("Response",resp.getExtensionsHeader(),containsString("permessage-deflate"));
|
||||
|
||||
String msg = "Hello";
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
|||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory;
|
||||
|
||||
public class SimpleServletServer
|
||||
{
|
||||
|
@ -147,4 +148,17 @@ public class SimpleServletServer
|
|||
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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,6 +130,8 @@ public abstract class WebSocketServlet extends HttpServlet
|
|||
configure(factory);
|
||||
|
||||
factory.init();
|
||||
|
||||
getServletContext().setAttribute(WebSocketServletFactory.class.getName(),factory);
|
||||
}
|
||||
catch (Exception x)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue