use of org.eclipse.jetty.websocket.common.test.Fuzzer in project jetty.project by eclipse.
the class TestABCase2 method testCase2_5.
/**
* Ping with 126 byte binary payload
* @throws Exception on test failure
*/
@Test
public void testCase2_5() throws Exception {
try (StacklessLogging scope = new StacklessLogging(Parser.class)) {
// intentionally too big
byte[] payload = new byte[126];
Arrays.fill(payload, (byte) '5');
ByteBuffer buf = ByteBuffer.wrap(payload);
List<WebSocketFrame> send = new ArrayList<>();
// trick websocket frame into making extra large payload for ping
send.add(new BadFrame(OpCode.PING).setPayload(buf));
send.add(new CloseInfo(StatusCode.NORMAL, "Test 2.5").asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this)) {
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.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 TestABCase2 method testCase2_7.
/**
* Unsolicited pong frame without payload
* @throws Exception on test failure
*/
@Test
public void testCase2_7() throws Exception {
List<WebSocketFrame> send = new ArrayList<>();
// unsolicited pong
send.add(new PongFrame());
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
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);
}
}
use of org.eclipse.jetty.websocket.common.test.Fuzzer in project jetty.project by eclipse.
the class TestABCase2 method testCase2_8.
/**
* Unsolicited pong frame with basic payload
* @throws Exception on test failure
*/
@Test
public void testCase2_8() throws Exception {
List<WebSocketFrame> send = new ArrayList<>();
// unsolicited pong
send.add(new PongFrame().setPayload("unsolicited"));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
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);
}
}
use of org.eclipse.jetty.websocket.common.test.Fuzzer in project jetty.project by eclipse.
the class TestABCase2 method testCase2_9.
/**
* Unsolicited pong frame, then ping with basic payload
* @throws Exception on test failure
*/
@Test
public void testCase2_9() throws Exception {
List<WebSocketFrame> send = new ArrayList<>();
// unsolicited pong
send.add(new PongFrame().setPayload("unsolicited"));
// our ping
send.add(new PingFrame().setPayload("our ping"));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
// our pong
expect.add(new PongFrame().setPayload("our ping"));
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);
}
}
use of org.eclipse.jetty.websocket.common.test.Fuzzer in project jetty.project by eclipse.
the class TestABCase1 method testCase1_2_7.
/**
* Echo 65536 byte BINARY message (uses large 8 byte payload length)
* @throws Exception on test failure
*/
@Test
public void testCase1_2_7() throws Exception {
byte[] payload = new byte[65536];
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);
}
}
Aggregations