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");
}
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);
}
Aggregations