use of org.eclipse.jetty.websocket.common.frames.PingFrame in project jetty.project by eclipse.
the class TestABCase4 method testCase4_2_3.
/**
* Send small text, then frame with opcode 13 (reserved), then ping
* @throws Exception on test failure
*/
@Test
public void testCase4_2_3() throws Exception {
List<WebSocketFrame> send = new ArrayList<>();
send.add(new TextFrame().setPayload("hello"));
// intentionally bad
send.add(new BadFrame((byte) 13));
send.add(new PingFrame());
List<WebSocketFrame> expect = new ArrayList<>();
// echo
expect.add(new TextFrame().setPayload("hello"));
expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this);
StacklessLogging logging = new StacklessLogging(Parser.class)) {
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.BULK);
fuzzer.send(send);
fuzzer.expect(expect);
}
}
use of org.eclipse.jetty.websocket.common.frames.PingFrame in project jetty.project by eclipse.
the class TestABCase7 method testCase7_1_3.
/**
* Close frame, then ping frame (no pong received)
* @throws Exception on test failure
*/
@Test
public void testCase7_1_3() throws Exception {
List<WebSocketFrame> send = new ArrayList<>();
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
send.add(new PingFrame().setPayload("out of band ping"));
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);
fuzzer.expectNoMoreFrames();
}
}
use of org.eclipse.jetty.websocket.common.frames.PingFrame in project jetty.project by eclipse.
the class TestABCase2 method testCase2_11.
/**
* 10 pings, sent slowly
* @throws Exception on test failure
*/
@Test
public void testCase2_11() throws Exception {
// send 10 pings (slowly) each with unique payload
// send close
// expect 10 pongs with OUR payload
// expect close
int pingCount = 10;
List<WebSocketFrame> send = new ArrayList<>();
List<WebSocketFrame> expect = new ArrayList<>();
for (int i = 0; i < pingCount; i++) {
String payload = String.format("ping-%d[%X]", i, i);
send.add(new PingFrame().setPayload(payload));
expect.add(new PongFrame().setPayload(payload));
}
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this)) {
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.SLOW);
fuzzer.setSlowSendSegmentSize(5);
fuzzer.send(send);
fuzzer.expect(expect);
}
}
use of org.eclipse.jetty.websocket.common.frames.PingFrame in project jetty.project by eclipse.
the class TestABCase2 method testCase2_4.
/**
* Ping with 125 byte binary payload
* @throws Exception on test failure
*/
@Test
public void testCase2_4() throws Exception {
byte[] payload = new byte[125];
Arrays.fill(payload, (byte) 0xFE);
List<WebSocketFrame> send = new ArrayList<>();
send.add(new PingFrame().setPayload(payload));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new PongFrame().setPayload(copyOf(payload)));
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.frames.PingFrame in project jetty.project by eclipse.
the class TestABCase2 method testCase2_6.
/**
* Ping with 125 byte binary payload (slow send)
* @throws Exception on test failure
*/
@Test
public void testCase2_6() throws Exception {
byte[] payload = new byte[125];
Arrays.fill(payload, (byte) '6');
List<WebSocketFrame> send = new ArrayList<>();
send.add(new PingFrame().setPayload(payload));
send.add(new CloseInfo(StatusCode.NORMAL, "Test 2.6").asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new PongFrame().setPayload(copyOf(payload)));
expect.add(new CloseInfo(StatusCode.NORMAL, "Test 2.6").asFrame());
try (Fuzzer fuzzer = new Fuzzer(this)) {
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.SLOW);
fuzzer.setSlowSendSegmentSize(1);
fuzzer.send(send);
fuzzer.expect(expect);
}
}
Aggregations