Search in sources :

Example 81 with Fuzzer

use of org.eclipse.jetty.websocket.common.test.Fuzzer in project jetty.project by eclipse.

the class TestABCase5 method testCase5_17.

/**
     * (continuation+fin, text!fin, continuation+fin) * 2
     * @throws Exception on test failure
     */
@Test
public void testCase5_17() throws Exception {
    List<WebSocketFrame> send = new ArrayList<>();
    // nothing to continue
    send.add(new ContinuationFrame().setPayload("fragment1").setFin(true));
    send.add(new TextFrame().setPayload("fragment2").setFin(false));
    send.add(new ContinuationFrame().setPayload("fragment3").setFin(true));
    // nothing to continue
    send.add(new ContinuationFrame().setPayload("fragment4").setFin(true));
    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.send(send);
        fuzzer.expect(expect);
    }
}
Also used : Fuzzer(org.eclipse.jetty.websocket.common.test.Fuzzer) ArrayList(java.util.ArrayList) TextFrame(org.eclipse.jetty.websocket.common.frames.TextFrame) WebSocketFrame(org.eclipse.jetty.websocket.common.WebSocketFrame) ContinuationFrame(org.eclipse.jetty.websocket.common.frames.ContinuationFrame) StacklessLogging(org.eclipse.jetty.util.log.StacklessLogging) CloseInfo(org.eclipse.jetty.websocket.common.CloseInfo) Test(org.junit.Test)

Example 82 with Fuzzer

use of org.eclipse.jetty.websocket.common.test.Fuzzer in project jetty.project by eclipse.

the class TestABCase5 method testCase5_20_slow.

/**
     * send text message fragmented in 5 frames, with 2 pings and wait between. (framewise)
     * @throws Exception on test failure
     */
@Test
public void testCase5_20_slow() throws Exception {
    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> 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> expect1 = new ArrayList<>();
    expect1.add(new PongFrame().setPayload("pong-1"));
    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.SLOW);
        fuzzer.setSlowSendSegmentSize(1);
        fuzzer.send(send1);
        fuzzer.expect(expect1);
        TimeUnit.SECONDS.sleep(1);
        fuzzer.send(send2);
        fuzzer.expect(expect2);
    }
}
Also used : PongFrame(org.eclipse.jetty.websocket.common.frames.PongFrame) Fuzzer(org.eclipse.jetty.websocket.common.test.Fuzzer) PingFrame(org.eclipse.jetty.websocket.common.frames.PingFrame) ArrayList(java.util.ArrayList) TextFrame(org.eclipse.jetty.websocket.common.frames.TextFrame) WebSocketFrame(org.eclipse.jetty.websocket.common.WebSocketFrame) ContinuationFrame(org.eclipse.jetty.websocket.common.frames.ContinuationFrame) StacklessLogging(org.eclipse.jetty.util.log.StacklessLogging) CloseInfo(org.eclipse.jetty.websocket.common.CloseInfo) Test(org.junit.Test)

Example 83 with Fuzzer

use of org.eclipse.jetty.websocket.common.test.Fuzzer in project jetty.project by eclipse.

the class TestABCase5 method testCase5_9.

/**
     * Send continuation+fin, then text+fin
     * @throws Exception on test failure
     */
@Test
public void testCase5_9() 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.BULK);
        fuzzer.send(send);
        fuzzer.expect(expect);
    }
}
Also used : Fuzzer(org.eclipse.jetty.websocket.common.test.Fuzzer) ArrayList(java.util.ArrayList) TextFrame(org.eclipse.jetty.websocket.common.frames.TextFrame) WebSocketFrame(org.eclipse.jetty.websocket.common.WebSocketFrame) ContinuationFrame(org.eclipse.jetty.websocket.common.frames.ContinuationFrame) StacklessLogging(org.eclipse.jetty.util.log.StacklessLogging) CloseInfo(org.eclipse.jetty.websocket.common.CloseInfo) Test(org.junit.Test)

Example 84 with Fuzzer

use of org.eclipse.jetty.websocket.common.test.Fuzzer in project jetty.project by eclipse.

the class TestABCase5 method testCase5_18.

/**
     * text message fragmented in 2 frames, both frames as opcode=TEXT
     * @throws Exception on test failure
     */
@Test
public void testCase5_18() throws Exception {
    List<WebSocketFrame> send = new ArrayList<>();
    send.add(new TextFrame().setPayload("fragment1").setFin(false));
    // bad frame, must be continuation
    send.add(new TextFrame().setPayload("fragment2").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.send(send);
        fuzzer.expect(expect);
    }
}
Also used : Fuzzer(org.eclipse.jetty.websocket.common.test.Fuzzer) ArrayList(java.util.ArrayList) TextFrame(org.eclipse.jetty.websocket.common.frames.TextFrame) WebSocketFrame(org.eclipse.jetty.websocket.common.WebSocketFrame) StacklessLogging(org.eclipse.jetty.util.log.StacklessLogging) CloseInfo(org.eclipse.jetty.websocket.common.CloseInfo) Test(org.junit.Test)

Example 85 with Fuzzer

use of org.eclipse.jetty.websocket.common.test.Fuzzer in project jetty.project by eclipse.

the class TestABCase3 method testCase3_5.

/**
     * Send binary frame with (RSV3 & RSV1), with no extensions defined.
     * @throws Exception on test failure
     */
@Test
public void testCase3_5() throws Exception {
    byte[] payload = new byte[8];
    Arrays.fill(payload, (byte) 0xFF);
    List<WebSocketFrame> send = new ArrayList<>();
    // intentionally bad
    send.add(new BinaryFrame().setPayload(payload).setRsv3(true).setRsv1(true));
    List<WebSocketFrame> expect = new ArrayList<>();
    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);
    }
}
Also used : Fuzzer(org.eclipse.jetty.websocket.common.test.Fuzzer) BinaryFrame(org.eclipse.jetty.websocket.common.frames.BinaryFrame) ArrayList(java.util.ArrayList) WebSocketFrame(org.eclipse.jetty.websocket.common.WebSocketFrame) StacklessLogging(org.eclipse.jetty.util.log.StacklessLogging) CloseInfo(org.eclipse.jetty.websocket.common.CloseInfo) Test(org.junit.Test)

Aggregations

WebSocketFrame (org.eclipse.jetty.websocket.common.WebSocketFrame)108 Fuzzer (org.eclipse.jetty.websocket.common.test.Fuzzer)108 ArrayList (java.util.ArrayList)106 Test (org.junit.Test)106 CloseInfo (org.eclipse.jetty.websocket.common.CloseInfo)104 TextFrame (org.eclipse.jetty.websocket.common.frames.TextFrame)59 StacklessLogging (org.eclipse.jetty.util.log.StacklessLogging)45 ByteBuffer (java.nio.ByteBuffer)43 PingFrame (org.eclipse.jetty.websocket.common.frames.PingFrame)27 ContinuationFrame (org.eclipse.jetty.websocket.common.frames.ContinuationFrame)26 PongFrame (org.eclipse.jetty.websocket.common.frames.PongFrame)17 BinaryFrame (org.eclipse.jetty.websocket.common.frames.BinaryFrame)15 Stress (org.eclipse.jetty.toolchain.test.annotation.Stress)6 CloseFrame (org.eclipse.jetty.websocket.common.frames.CloseFrame)6 Slow (org.eclipse.jetty.toolchain.test.annotation.Slow)5