use of io.netty.handler.codec.http.websocketx.extensions.WebSocketExtensionData in project netty by netty.
the class WebSocketServerCompressionHandlerTest method testClientNoContext.
@Test
public void testClientNoContext() {
EmbeddedChannel ch = new EmbeddedChannel(new WebSocketServerCompressionHandler());
HttpRequest req = newUpgradeRequest(PERMESSAGE_DEFLATE_EXTENSION + "; " + CLIENT_NO_CONTEXT);
ch.writeInbound(req);
HttpResponse res = newUpgradeResponse(null);
ch.writeOutbound(res);
HttpResponse res2 = ch.readOutbound();
List<WebSocketExtensionData> exts = WebSocketExtensionUtil.extractExtensions(res2.headers().get(HttpHeaderNames.SEC_WEBSOCKET_EXTENSIONS));
Assert.assertEquals(PERMESSAGE_DEFLATE_EXTENSION, exts.get(0).name());
Assert.assertTrue(exts.get(0).parameters().isEmpty());
Assert.assertTrue(ch.pipeline().get(PerMessageDeflateDecoder.class) != null);
Assert.assertTrue(ch.pipeline().get(PerMessageDeflateEncoder.class) != null);
}
use of io.netty.handler.codec.http.websocketx.extensions.WebSocketExtensionData in project netty by netty.
the class DeflateFrameClientExtensionHandshakerTest method testFailedHandshake.
@Test
public void testFailedHandshake() {
// initialize
DeflateFrameClientExtensionHandshaker handshaker = new DeflateFrameClientExtensionHandshaker(false);
Map<String, String> parameters = new HashMap<String, String>();
parameters.put("invalid", "12");
// execute
WebSocketClientExtension extension = handshaker.handshakeExtension(new WebSocketExtensionData(DEFLATE_FRAME_EXTENSION, parameters));
// test
assertNull(extension);
}
use of io.netty.handler.codec.http.websocketx.extensions.WebSocketExtensionData in project netty by netty.
the class DeflateFrameServerExtensionHandshakerTest method testNormalHandshake.
@Test
public void testNormalHandshake() {
// initialize
DeflateFrameServerExtensionHandshaker handshaker = new DeflateFrameServerExtensionHandshaker();
// execute
WebSocketServerExtension extension = handshaker.handshakeExtension(new WebSocketExtensionData(DEFLATE_FRAME_EXTENSION, Collections.<String, String>emptyMap()));
// test
assertNotNull(extension);
assertEquals(WebSocketServerExtension.RSV1, extension.rsv());
assertTrue(extension.newExtensionDecoder() instanceof PerFrameDeflateDecoder);
assertTrue(extension.newExtensionEncoder() instanceof PerFrameDeflateEncoder);
}
use of io.netty.handler.codec.http.websocketx.extensions.WebSocketExtensionData in project netty by netty.
the class PerMessageDeflateClientExtensionHandshakerTest method testNormalHandshake.
@Test
public void testNormalHandshake() {
PerMessageDeflateClientExtensionHandshaker handshaker = new PerMessageDeflateClientExtensionHandshaker();
WebSocketClientExtension extension = handshaker.handshakeExtension(new WebSocketExtensionData(PERMESSAGE_DEFLATE_EXTENSION, Collections.<String, String>emptyMap()));
assertNotNull(extension);
assertEquals(WebSocketClientExtension.RSV1, extension.rsv());
assertTrue(extension.newExtensionDecoder() instanceof PerMessageDeflateDecoder);
assertTrue(extension.newExtensionEncoder() instanceof PerMessageDeflateEncoder);
}
use of io.netty.handler.codec.http.websocketx.extensions.WebSocketExtensionData in project netty by netty.
the class WebSocketServerCompressionHandlerTest method testClientWindowSizeUnavailable.
@Test
public void testClientWindowSizeUnavailable() {
EmbeddedChannel ch = new EmbeddedChannel(new WebSocketServerExtensionHandler(new PerMessageDeflateServerExtensionHandshaker(6, false, 10, false, false)));
HttpRequest req = newUpgradeRequest(PERMESSAGE_DEFLATE_EXTENSION);
ch.writeInbound(req);
HttpResponse res = newUpgradeResponse(null);
ch.writeOutbound(res);
HttpResponse res2 = ch.readOutbound();
List<WebSocketExtensionData> exts = WebSocketExtensionUtil.extractExtensions(res2.headers().get(HttpHeaderNames.SEC_WEBSOCKET_EXTENSIONS));
Assert.assertEquals(PERMESSAGE_DEFLATE_EXTENSION, exts.get(0).name());
Assert.assertTrue(exts.get(0).parameters().isEmpty());
Assert.assertTrue(ch.pipeline().get(PerMessageDeflateDecoder.class) != null);
Assert.assertTrue(ch.pipeline().get(PerMessageDeflateEncoder.class) != null);
}
Aggregations