Search in sources :

Example 1 with WebSocketClientExtension

use of io.netty.handler.codec.http.websocketx.extensions.WebSocketClientExtension 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);
}
Also used : HashMap(java.util.HashMap) WebSocketClientExtension(io.netty.handler.codec.http.websocketx.extensions.WebSocketClientExtension) WebSocketExtensionData(io.netty.handler.codec.http.websocketx.extensions.WebSocketExtensionData) Test(org.junit.Test)

Example 2 with WebSocketClientExtension

use of io.netty.handler.codec.http.websocketx.extensions.WebSocketClientExtension 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);
}
Also used : WebSocketClientExtension(io.netty.handler.codec.http.websocketx.extensions.WebSocketClientExtension) WebSocketExtensionData(io.netty.handler.codec.http.websocketx.extensions.WebSocketExtensionData) Test(org.junit.Test)

Example 3 with WebSocketClientExtension

use of io.netty.handler.codec.http.websocketx.extensions.WebSocketClientExtension in project netty by netty.

the class PerMessageDeflateClientExtensionHandshakerTest method testCustomHandshake.

@Test
public void testCustomHandshake() {
    WebSocketClientExtension extension;
    Map<String, String> parameters;
    // initialize
    PerMessageDeflateClientExtensionHandshaker handshaker = new PerMessageDeflateClientExtensionHandshaker(6, true, 10, true, true);
    parameters = new HashMap<String, String>();
    parameters.put(CLIENT_MAX_WINDOW, "12");
    parameters.put(SERVER_MAX_WINDOW, "10");
    parameters.put(CLIENT_NO_CONTEXT, null);
    parameters.put(SERVER_NO_CONTEXT, null);
    // execute
    extension = handshaker.handshakeExtension(new WebSocketExtensionData(PERMESSAGE_DEFLATE_EXTENSION, parameters));
    // test
    assertNotNull(extension);
    assertEquals(WebSocketClientExtension.RSV1, extension.rsv());
    assertTrue(extension.newExtensionDecoder() instanceof PerMessageDeflateDecoder);
    assertTrue(extension.newExtensionEncoder() instanceof PerMessageDeflateEncoder);
    // initialize
    parameters = new HashMap<String, String>();
    parameters.put(SERVER_MAX_WINDOW, "10");
    parameters.put(SERVER_NO_CONTEXT, null);
    // execute
    extension = handshaker.handshakeExtension(new WebSocketExtensionData(PERMESSAGE_DEFLATE_EXTENSION, parameters));
    // test
    assertNotNull(extension);
    assertEquals(WebSocketClientExtension.RSV1, extension.rsv());
    assertTrue(extension.newExtensionDecoder() instanceof PerMessageDeflateDecoder);
    assertTrue(extension.newExtensionEncoder() instanceof PerMessageDeflateEncoder);
    // initialize
    parameters = new HashMap<String, String>();
    // execute
    extension = handshaker.handshakeExtension(new WebSocketExtensionData(PERMESSAGE_DEFLATE_EXTENSION, parameters));
    // test
    assertNull(extension);
}
Also used : WebSocketClientExtension(io.netty.handler.codec.http.websocketx.extensions.WebSocketClientExtension) WebSocketExtensionData(io.netty.handler.codec.http.websocketx.extensions.WebSocketExtensionData) Test(org.junit.Test)

Example 4 with WebSocketClientExtension

use of io.netty.handler.codec.http.websocketx.extensions.WebSocketClientExtension in project netty by netty.

the class DeflateFrameClientExtensionHandshakerTest method testNormalHandshake.

@Test
public void testNormalHandshake() {
    DeflateFrameClientExtensionHandshaker handshaker = new DeflateFrameClientExtensionHandshaker(false);
    WebSocketClientExtension extension = handshaker.handshakeExtension(new WebSocketExtensionData(DEFLATE_FRAME_EXTENSION, Collections.<String, String>emptyMap()));
    assertNotNull(extension);
    assertEquals(WebSocketClientExtension.RSV1, extension.rsv());
    assertTrue(extension.newExtensionDecoder() instanceof PerFrameDeflateDecoder);
    assertTrue(extension.newExtensionEncoder() instanceof PerFrameDeflateEncoder);
}
Also used : WebSocketClientExtension(io.netty.handler.codec.http.websocketx.extensions.WebSocketClientExtension) WebSocketExtensionData(io.netty.handler.codec.http.websocketx.extensions.WebSocketExtensionData) Test(org.junit.Test)

Aggregations

WebSocketClientExtension (io.netty.handler.codec.http.websocketx.extensions.WebSocketClientExtension)4 WebSocketExtensionData (io.netty.handler.codec.http.websocketx.extensions.WebSocketExtensionData)4 Test (org.junit.Test)4 HashMap (java.util.HashMap)1