use of org.eclipse.jetty.websocket.common.CloseInfo in project jetty.project by eclipse.
the class TestABCase5 method testCase5_16.
/**
* (continuation!fin, text!fin, continuation+fin) * 2
* @throws Exception on test failure
*/
@Test
public void testCase5_16() throws Exception {
List<WebSocketFrame> send = new ArrayList<>();
// bad frame
send.add(new ContinuationFrame().setPayload("fragment1").setFin(false));
send.add(new TextFrame().setPayload("fragment2").setFin(false));
send.add(new ContinuationFrame().setPayload("fragment3").setFin(true));
// bad frame
send.add(new ContinuationFrame().setPayload("fragment4").setFin(false));
send.add(new TextFrame().setPayload("fragment5").setFin(false));
send.add(new ContinuationFrame().setPayload("fragment6").setFin(true));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this);
StacklessLogging supress = new StacklessLogging(Parser.class)) {
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.BULK);
fuzzer.sendAndIgnoreBrokenPipe(send);
fuzzer.expect(expect);
}
}
use of org.eclipse.jetty.websocket.common.CloseInfo in project jetty.project by eclipse.
the class TestABCase5 method testCase5_7.
/**
* Send text fragmented in 2 packets, with ping between them (framewise)
* @throws Exception on test failure
*/
@Test
public void testCase5_7() throws Exception {
List<WebSocketFrame> send = new ArrayList<>();
send.add(new TextFrame().setPayload("hello, ").setFin(false));
send.add(new PingFrame().setPayload("ping"));
send.add(new ContinuationFrame().setPayload("world").setFin(true));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new PongFrame().setPayload("ping"));
expect.add(new TextFrame().setPayload("hello, world"));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this);
StacklessLogging supress = new StacklessLogging(Parser.class)) {
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.PER_FRAME);
fuzzer.send(send);
fuzzer.expect(expect);
}
}
use of org.eclipse.jetty.websocket.common.CloseInfo in project jetty.project by eclipse.
the class TestABCase5 method testCase5_11.
/**
* Send continuation+fin, then text+fin (slowly)
* @throws Exception on test failure
*/
@Test
public void testCase5_11() throws Exception {
List<WebSocketFrame> send = new ArrayList<>();
send.add(new ContinuationFrame().setPayload("sorry").setFin(true));
send.add(new TextFrame().setPayload("hello, world"));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this);
StacklessLogging supress = new StacklessLogging(Parser.class)) {
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.SLOW);
fuzzer.setSlowSendSegmentSize(1);
fuzzer.sendAndIgnoreBrokenPipe(send);
fuzzer.expect(expect);
}
}
use of org.eclipse.jetty.websocket.common.CloseInfo in project jetty.project by eclipse.
the class TestABCase5 method testCase5_4.
/**
* Send text fragmented in 2 packets (framewise)
* @throws Exception on test failure
*/
@Test
public void testCase5_4() throws Exception {
List<WebSocketFrame> send = new ArrayList<>();
send.add(new TextFrame().setPayload("hello, ").setFin(false));
send.add(new ContinuationFrame().setPayload("world").setFin(true));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new TextFrame().setPayload("hello, world"));
expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this);
StacklessLogging supress = new StacklessLogging(Parser.class)) {
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.PER_FRAME);
fuzzer.send(send);
fuzzer.expect(expect);
}
}
use of org.eclipse.jetty.websocket.common.CloseInfo in project jetty.project by eclipse.
the class TestABCase5 method testCase5_19.
/**
* send text message fragmented in 5 frames, with 2 pings and wait between.
* @throws Exception on test failure
*/
@Test
@Slow
public void testCase5_19() throws Exception {
// phase 1
List<WebSocketFrame> send1 = new ArrayList<>();
send1.add(new TextFrame().setPayload("f1").setFin(false));
send1.add(new ContinuationFrame().setPayload(",f2").setFin(false));
send1.add(new PingFrame().setPayload("pong-1"));
List<WebSocketFrame> expect1 = new ArrayList<>();
expect1.add(new PongFrame().setPayload("pong-1"));
// phase 2
List<WebSocketFrame> send2 = new ArrayList<>();
send2.add(new ContinuationFrame().setPayload(",f3").setFin(false));
send2.add(new ContinuationFrame().setPayload(",f4").setFin(false));
send2.add(new PingFrame().setPayload("pong-2"));
send2.add(new ContinuationFrame().setPayload(",f5").setFin(true));
send2.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect2 = new ArrayList<>();
expect2.add(new PongFrame().setPayload("pong-2"));
expect2.add(new TextFrame().setPayload("f1,f2,f3,f4,f5"));
expect2.add(new CloseInfo(StatusCode.NORMAL).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this);
StacklessLogging supress = new StacklessLogging(Parser.class)) {
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.BULK);
// phase 1
fuzzer.send(send1);
fuzzer.expect(expect1);
// delay
TimeUnit.SECONDS.sleep(1);
// phase 2
fuzzer.send(send2);
fuzzer.expect(expect2);
}
}
Aggregations