Simplifying testcase, relying on flush not sleep.

This commit is contained in:
Joakim Erdfelt 2018-03-12 16:33:39 -05:00
parent eaefc6a9c2
commit 0361cf6cd3
1 changed files with 24 additions and 19 deletions

View File

@ -21,7 +21,6 @@ package org.eclipse.jetty.websocket.server.ab;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.StringUtil;
@ -278,20 +277,24 @@ public class TestABCase6 extends AbstractABCase
byte part2[] = Hex.asByteArray("F4908080"); // invalid
byte part3[] = StringUtil.getUtf8Bytes("edited");
ByteBuffer b1 = ByteBuffer.wrap(part1);
ByteBuffer b2 = ByteBuffer.wrap(part2);
ByteBuffer b3 = ByteBuffer.wrap(part3);
List<WebSocketFrame> send = new ArrayList<>();
send.add(new TextFrame().setPayload(b1).setFin(false));
send.add(new ContinuationFrame().setPayload(b2).setFin(true));
send.add(new ContinuationFrame().setPayload(b3).setFin(true));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new CloseInfo(StatusCode.BAD_PAYLOAD).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this))
{
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.BULK);
fuzzer.send(new TextFrame().setPayload(ByteBuffer.wrap(part1)).setFin(false));
TimeUnit.SECONDS.sleep(1);
fuzzer.send(new ContinuationFrame().setPayload(ByteBuffer.wrap(part2)).setFin(false));
TimeUnit.SECONDS.sleep(1);
fuzzer.send(new ContinuationFrame().setPayload(ByteBuffer.wrap(part3)).setFin(true));
fuzzer.setSendMode(Fuzzer.SendMode.PER_FRAME);
fuzzer.send(send);
fuzzer.expect(expect);
}
}
@ -313,18 +316,24 @@ public class TestABCase6 extends AbstractABCase
byte part2[] = Hex.asByteArray("90"); // continue code point & invalid
byte part3[] = Hex.asByteArray("8080656469746564"); // continue code point & finish
ByteBuffer b1 = ByteBuffer.wrap(part1);
ByteBuffer b2 = ByteBuffer.wrap(part2);
ByteBuffer b3 = ByteBuffer.wrap(part3);
List<WebSocketFrame> send = new ArrayList<>();
send.add(new TextFrame().setPayload(b1).setFin(false));
send.add(new ContinuationFrame().setPayload(b2).setFin(true));
send.add(new ContinuationFrame().setPayload(b3).setFin(true));
send.add(new CloseInfo(StatusCode.NORMAL).asFrame());
List<WebSocketFrame> expect = new ArrayList<>();
expect.add(new CloseInfo(StatusCode.BAD_PAYLOAD).asFrame());
try (Fuzzer fuzzer = new Fuzzer(this))
{
fuzzer.connect();
fuzzer.setSendMode(Fuzzer.SendMode.BULK);
fuzzer.send(new TextFrame().setPayload(ByteBuffer.wrap(part1)).setFin(false));
TimeUnit.SECONDS.sleep(1);
fuzzer.send(new ContinuationFrame().setPayload(ByteBuffer.wrap(part2)).setFin(false));
TimeUnit.SECONDS.sleep(1);
fuzzer.send(new ContinuationFrame().setPayload(ByteBuffer.wrap(part3)).setFin(true));
fuzzer.setSendMode(Fuzzer.SendMode.PER_FRAME);
fuzzer.send(send);
fuzzer.expect(expect);
}
}
@ -371,9 +380,7 @@ public class TestABCase6 extends AbstractABCase
part3.limit(splits[2]);
fuzzer.send(part1); // the header + good utf
TimeUnit.MILLISECONDS.sleep(500);
fuzzer.send(part2); // the bad UTF
TimeUnit.MILLISECONDS.sleep(500);
fuzzer.send(part3); // the rest (shouldn't work)
fuzzer.expect(expect);
@ -404,9 +411,7 @@ public class TestABCase6 extends AbstractABCase
ByteBuffer net = fuzzer.asNetworkBuffer(send);
fuzzer.send(net,6);
fuzzer.send(net,11);
TimeUnit.SECONDS.sleep(1);
fuzzer.send(net,1);
TimeUnit.SECONDS.sleep(1);
fuzzer.send(net,100); // the rest
fuzzer.expect(expect);