use of org.eclipse.jetty.websocket.common.WebSocketFrame in project jetty.project by eclipse.
the class TestABCase9 method testCase9_1_1.
/**
* Echo 64KB text message (1 frame)
* @throws Exception on test failure
*/
@Test
public void testCase9_1_1() throws Exception {
byte[] utf = new byte[64 * KBYTE];
Arrays.fill(utf, (byte) 'y');
String msg = StringUtil.toUTF8String(utf, 0, utf.length);
List<WebSocketFrame> send = new ArrayList<>();
send.add(new TextFrame().setPayload(msg));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new TextFrame().setPayload(msg));
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.WebSocketFrame in project jetty.project by eclipse.
the class TestABCase5 method testCase5_5.
/**
* Send text fragmented in 2 packets (slowly)
* @throws Exception on test failure
*/
@Test
public void testCase5_5() 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.SLOW);
fuzzer.setSlowSendSegmentSize(1);
fuzzer.send(send);
fuzzer.expect(expect);
}
}
use of org.eclipse.jetty.websocket.common.WebSocketFrame in project jetty.project by eclipse.
the class TestABCase5 method testCase5_2.
/**
* Send pong fragmented in 2 packets
* @throws Exception on test failure
*/
@Test
public void testCase5_2() throws Exception {
List<WebSocketFrame> send = new ArrayList<>();
send.add(new PongFrame().setPayload("hello, ").setFin(false));
send.add(new ContinuationFrame().setPayload("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.BULK);
fuzzer.send(send);
fuzzer.expect(expect);
}
}
use of org.eclipse.jetty.websocket.common.WebSocketFrame 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.WebSocketFrame 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);
}
}
Aggregations