use of org.eclipse.jetty.websocket.common.test.Fuzzer in project jetty.project by eclipse.
the class TestABCase1 method testCase1_2_3.
/**
* Echo 126 byte BINARY message (uses medium 2 byte payload length)
* @throws Exception on test failure
*/
@Test
public void testCase1_2_3() throws Exception {
byte[] payload = new byte[126];
Arrays.fill(payload, (byte) 0xFE);
ByteBuffer buf = ByteBuffer.wrap(payload);
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(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_1.
/**
* Echo 0 byte TEXT message
* @throws Exception on test failure
*/
@Test
public void testCase1_1_1() throws Exception {
List<WebSocketFrame> send = new ArrayList<>();
send.add(new TextFrame());
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new TextFrame());
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_2_5.
/**
* Echo 128 byte BINARY message (uses medium 2 byte payload length)
* @throws Exception on test failure
*/
@Test
public void testCase1_2_5() throws Exception {
byte[] payload = new byte[128];
Arrays.fill(payload, (byte) 0xFE);
ByteBuffer buf = ByteBuffer.wrap(payload);
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(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 TestABCase7_GoodStatusCodes method testStatusCodeWithReason.
/**
* the good close code, with reason
* @throws Exception on test failure
*/
@Test
public void testStatusCodeWithReason() throws Exception {
ByteBuffer payload = ByteBuffer.allocate(256);
payload.putChar((char) statusCode);
payload.put(StringUtil.getBytes("Reason"));
payload.flip();
List<WebSocketFrame> send = new ArrayList<>();
send.add(new CloseFrame().setPayload(payload.slice()));
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new CloseFrame().setPayload(clone(payload)));
try (Fuzzer fuzzer = new Fuzzer(this)) {
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.BULK);
fuzzer.send(send);
fuzzer.expect(expect);
fuzzer.expectNoMoreFrames();
}
}
use of org.eclipse.jetty.websocket.common.test.Fuzzer in project jetty.project by eclipse.
the class TestABCase9 method testCase9_1_5.
/**
* Echo 8MB text message (1 frame)
* @throws Exception on test failure
*/
@Test
@Stress("High I/O use")
public void testCase9_1_5() throws Exception {
byte[] utf = new byte[8 * MBYTE];
Arrays.fill(utf, (byte) 'y');
ByteBuffer buf = ByteBuffer.wrap(utf);
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(Fuzzer.SendMode.BULK);
fuzzer.send(send);
fuzzer.expect(expect, 16, TimeUnit.SECONDS);
}
}
Aggregations