use of org.eclipse.jetty.websocket.common.test.Fuzzer in project jetty.project by eclipse.
the class TestABCase9 method testCase9_2_4.
/**
* Echo 4MB binary message (1 frame)
* @throws Exception on test failure
*/
@Test
@Stress("High I/O use")
public void testCase9_2_4() throws Exception {
byte[] data = new byte[4 * MBYTE];
Arrays.fill(data, (byte) 0x24);
ByteBuffer buf = ByteBuffer.wrap(data);
List<WebSocketFrame> send = new ArrayList<>();
send.add(new BinaryFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new BinaryFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this)) {
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.BULK);
fuzzer.send(send);
fuzzer.expect(expect, 8, TimeUnit.SECONDS);
}
}
use of org.eclipse.jetty.websocket.common.test.Fuzzer in project jetty.project by eclipse.
the class TestABCase1 method testCase1_1_5.
/**
* Echo 128 byte TEXT message (uses medium 2 byte payload length)
* @throws Exception on test failure
*/
@Test
public void testCase1_1_5() throws Exception {
byte[] payload = new byte[128];
Arrays.fill(payload, (byte) '*');
ByteBuffer buf = ByteBuffer.wrap(payload);
List<WebSocketFrame> send = new ArrayList<>();
send.add(new TextFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new TextFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this)) {
fuzzer.connect();
fuzzer.setSendMode(SendMode.BULK);
fuzzer.send(send);
fuzzer.expect(expect);
}
}
use of org.eclipse.jetty.websocket.common.test.Fuzzer in project jetty.project by eclipse.
the class TestABCase1 method testCase1_1_8.
/**
* Echo 65536 byte TEXT message (uses large 8 byte payload length).
* <p>
* Only send 1 TEXT frame from client, but in small segments (flushed after each).
* <p>
* This is done to test the parsing together of the frame on the server side.
* @throws Exception on test failure
*/
@Test
public void testCase1_1_8() throws Exception {
byte[] payload = new byte[65536];
Arrays.fill(payload, (byte) '*');
ByteBuffer buf = ByteBuffer.wrap(payload);
int segmentSize = 997;
List<WebSocketFrame> send = new ArrayList<>();
send.add(new TextFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new TextFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this)) {
fuzzer.connect();
fuzzer.setSendMode(SendMode.SLOW);
fuzzer.setSlowSendSegmentSize(segmentSize);
fuzzer.send(send);
fuzzer.expect(expect);
}
}
use of org.eclipse.jetty.websocket.common.test.Fuzzer in project jetty.project by eclipse.
the class TestABCase1 method testCase1_2_1.
/**
* Echo 0 byte BINARY message
* @throws Exception on test failure
*/
@Test
public void testCase1_2_1() throws Exception {
List<WebSocketFrame> send = new ArrayList<>();
send.add(new BinaryFrame());
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new BinaryFrame());
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this)) {
fuzzer.connect();
fuzzer.setSendMode(SendMode.BULK);
fuzzer.send(send);
fuzzer.expect(expect);
}
}
use of org.eclipse.jetty.websocket.common.test.Fuzzer in project jetty.project by eclipse.
the class TestABCase1 method testCase1_1_7.
/**
* Echo 65536 byte TEXT message (uses large 8 byte payload length)
* @throws Exception on test failure
*/
@Test
public void testCase1_1_7() throws Exception {
byte[] payload = new byte[65536];
Arrays.fill(payload, (byte) '*');
ByteBuffer buf = ByteBuffer.wrap(payload);
List<WebSocketFrame> send = new ArrayList<>();
send.add(new TextFrame().setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new TextFrame().setPayload(clone(buf)));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this)) {
fuzzer.connect();
fuzzer.setSendMode(SendMode.BULK);
fuzzer.send(send);
fuzzer.expect(expect);
}
}
Aggregations