Search in sources :

Example 71 with Fuzzer

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

the class TestABCase9 method testCase9_2_4.

/**
     * Echo 4MB binary message (1 frame)
     * @throws Exception on test failure
     */
@Test
@Stress("High I/O use")
public void testCase9_2_4() throws Exception {
    byte[] data = new byte[4 * MBYTE];
    Arrays.fill(data, (byte) 0x24);
    ByteBuffer buf = ByteBuffer.wrap(data);
    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(Fuzzer.SendMode.BULK);
        fuzzer.send(send);
        fuzzer.expect(expect, 8, TimeUnit.SECONDS);
    }
}
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) ByteBuffer(java.nio.ByteBuffer) CloseInfo(org.eclipse.jetty.websocket.common.CloseInfo) Test(org.junit.Test) Stress(org.eclipse.jetty.toolchain.test.annotation.Stress)

Example 72 with Fuzzer

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

the class TestABCase1 method testCase1_1_5.

/**
     * Echo 128 byte TEXT message (uses medium 2 byte payload length)
     * @throws Exception on test failure
     */
@Test
public void testCase1_1_5() throws Exception {
    byte[] payload = new byte[128];
    Arrays.fill(payload, (byte) '*');
    ByteBuffer buf = ByteBuffer.wrap(payload);
    List<WebSocketFrame> send = new ArrayList<>();
    send.add(new TextFrame().setPayload(buf));
    send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
    List<WebSocketFrame> expect = new ArrayList<>();
    expect.add(new TextFrame().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);
    }
}
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) ByteBuffer(java.nio.ByteBuffer) CloseInfo(org.eclipse.jetty.websocket.common.CloseInfo) Test(org.junit.Test)

Example 73 with Fuzzer

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

the class TestABCase1 method testCase1_1_8.

/**
     * Echo 65536 byte TEXT message (uses large 8 byte payload length).
     * <p>
     * Only send 1 TEXT frame from client, but in small segments (flushed after each).
     * <p>
     * This is done to test the parsing together of the frame on the server side.
     * @throws Exception on test failure
     */
@Test
public void testCase1_1_8() throws Exception {
    byte[] payload = new byte[65536];
    Arrays.fill(payload, (byte) '*');
    ByteBuffer buf = ByteBuffer.wrap(payload);
    int segmentSize = 997;
    List<WebSocketFrame> send = new ArrayList<>();
    send.add(new TextFrame().setPayload(buf));
    send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
    List<WebSocketFrame> expect = new ArrayList<>();
    expect.add(new TextFrame().setPayload(clone(buf)));
    expect.add(new CloseInfo(StatusCode.NORMAL).asFrame());
    try (Fuzzer fuzzer = new Fuzzer(this)) {
        fuzzer.connect();
        fuzzer.setSendMode(SendMode.SLOW);
        fuzzer.setSlowSendSegmentSize(segmentSize);
        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) ByteBuffer(java.nio.ByteBuffer) CloseInfo(org.eclipse.jetty.websocket.common.CloseInfo) Test(org.junit.Test)

Example 74 with Fuzzer

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

the class TestABCase1 method testCase1_2_1.

/**
     * Echo 0 byte BINARY message
     * @throws Exception on test failure
     */
@Test
public void testCase1_2_1() throws Exception {
    List<WebSocketFrame> send = new ArrayList<>();
    send.add(new BinaryFrame());
    send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
    List<WebSocketFrame> expect = new ArrayList<>();
    expect.add(new BinaryFrame());
    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);
    }
}
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) CloseInfo(org.eclipse.jetty.websocket.common.CloseInfo) Test(org.junit.Test)

Example 75 with Fuzzer

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

the class TestABCase1 method testCase1_1_7.

/**
     * Echo 65536 byte TEXT message (uses large 8 byte payload length)
     * @throws Exception on test failure
     */
@Test
public void testCase1_1_7() throws Exception {
    byte[] payload = new byte[65536];
    Arrays.fill(payload, (byte) '*');
    ByteBuffer buf = ByteBuffer.wrap(payload);
    List<WebSocketFrame> send = new ArrayList<>();
    send.add(new TextFrame().setPayload(buf));
    send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
    List<WebSocketFrame> expect = new ArrayList<>();
    expect.add(new TextFrame().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);
    }
}
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) ByteBuffer(java.nio.ByteBuffer) 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