Search in sources :

Example 1 with OutgoingNetworkBytesCapture

use of org.eclipse.jetty.websocket.common.test.OutgoingNetworkBytesCapture in project jetty.project by eclipse.

the class DeflateFrameExtensionTest method testGeneratedTwoFrames.

@Test
public void testGeneratedTwoFrames() throws IOException {
    WebSocketPolicy policy = WebSocketPolicy.newClientPolicy();
    DeflateFrameExtension ext = new DeflateFrameExtension();
    ext.setBufferPool(bufferPool);
    ext.setPolicy(policy);
    ext.setConfig(new ExtensionConfig(ext.getName()));
    Generator generator = new Generator(policy, bufferPool, true);
    generator.configureFromExtensions(Collections.singletonList(ext));
    OutgoingNetworkBytesCapture capture = new OutgoingNetworkBytesCapture(generator);
    ext.setNextOutgoingFrames(capture);
    ext.outgoingFrame(new TextFrame().setPayload("Hello"), null, BatchMode.OFF);
    ext.outgoingFrame(new TextFrame().setPayload("There"), null, BatchMode.OFF);
    capture.assertBytes(0, "c107f248cdc9c90700");
}
Also used : WebSocketPolicy(org.eclipse.jetty.websocket.api.WebSocketPolicy) ExtensionConfig(org.eclipse.jetty.websocket.api.extensions.ExtensionConfig) TextFrame(org.eclipse.jetty.websocket.common.frames.TextFrame) OutgoingNetworkBytesCapture(org.eclipse.jetty.websocket.common.test.OutgoingNetworkBytesCapture) Generator(org.eclipse.jetty.websocket.common.Generator) AbstractExtensionTest(org.eclipse.jetty.websocket.common.extensions.AbstractExtensionTest) Test(org.junit.Test)

Example 2 with OutgoingNetworkBytesCapture

use of org.eclipse.jetty.websocket.common.test.OutgoingNetworkBytesCapture in project jetty.project by eclipse.

the class DeflateFrameExtensionTest method assertOutgoing.

private void assertOutgoing(String text, String expectedHex) throws IOException {
    WebSocketPolicy policy = WebSocketPolicy.newClientPolicy();
    DeflateFrameExtension ext = new DeflateFrameExtension();
    ext.setBufferPool(bufferPool);
    ext.setPolicy(policy);
    ExtensionConfig config = ExtensionConfig.parse("deflate-frame");
    ext.setConfig(config);
    Generator generator = new Generator(policy, bufferPool, true);
    generator.configureFromExtensions(Collections.singletonList(ext));
    OutgoingNetworkBytesCapture capture = new OutgoingNetworkBytesCapture(generator);
    ext.setNextOutgoingFrames(capture);
    Frame frame = new TextFrame().setPayload(text);
    ext.outgoingFrame(frame, null, BatchMode.OFF);
    capture.assertBytes(0, expectedHex);
}
Also used : WebSocketPolicy(org.eclipse.jetty.websocket.api.WebSocketPolicy) BinaryFrame(org.eclipse.jetty.websocket.common.frames.BinaryFrame) WebSocketFrame(org.eclipse.jetty.websocket.common.WebSocketFrame) TextFrame(org.eclipse.jetty.websocket.common.frames.TextFrame) Frame(org.eclipse.jetty.websocket.api.extensions.Frame) ExtensionConfig(org.eclipse.jetty.websocket.api.extensions.ExtensionConfig) TextFrame(org.eclipse.jetty.websocket.common.frames.TextFrame) OutgoingNetworkBytesCapture(org.eclipse.jetty.websocket.common.test.OutgoingNetworkBytesCapture) Generator(org.eclipse.jetty.websocket.common.Generator)

Aggregations

WebSocketPolicy (org.eclipse.jetty.websocket.api.WebSocketPolicy)2 ExtensionConfig (org.eclipse.jetty.websocket.api.extensions.ExtensionConfig)2 Generator (org.eclipse.jetty.websocket.common.Generator)2 TextFrame (org.eclipse.jetty.websocket.common.frames.TextFrame)2 OutgoingNetworkBytesCapture (org.eclipse.jetty.websocket.common.test.OutgoingNetworkBytesCapture)2 Frame (org.eclipse.jetty.websocket.api.extensions.Frame)1 WebSocketFrame (org.eclipse.jetty.websocket.common.WebSocketFrame)1 AbstractExtensionTest (org.eclipse.jetty.websocket.common.extensions.AbstractExtensionTest)1 BinaryFrame (org.eclipse.jetty.websocket.common.frames.BinaryFrame)1 Test (org.junit.Test)1