diff --git a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/OnPartialTest.java b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/OnPartialTest.java index 025d466adc1..3651c6c5563 100644 --- a/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/OnPartialTest.java +++ b/jetty-websocket/javax-websocket-server-impl/src/test/java/org/eclipse/jetty/websocket/jsr356/server/OnPartialTest.java @@ -89,7 +89,7 @@ public class OnPartialTest public void testOnTextPartial() throws Throwable { List frames = new ArrayList<>(); - frames.add(new TextFrame("Saved").setFin(false)); + frames.add(new TextFrame().setPayload("Saved").setFin(false)); frames.add(new ContinuationFrame(" by ").setFin(false)); frames.add(new ContinuationFrame("zero").setFin(true)); diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketRemoteEndpoint.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketRemoteEndpoint.java index caed2665aee..9e9690b2eb3 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketRemoteEndpoint.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketRemoteEndpoint.java @@ -122,7 +122,7 @@ public class WebSocketRemoteEndpoint implements RemoteEndpoint { LOG.debug("sendBytes with {}",BufferUtil.toDetailString(data)); } - blockingWrite(new BinaryFrame(data)); + blockingWrite(new BinaryFrame().setPayload(data)); } finally { @@ -144,7 +144,7 @@ public class WebSocketRemoteEndpoint implements RemoteEndpoint { LOG.debug("sendBytesByFuture with {}",BufferUtil.toDetailString(data)); } - return sendAsyncFrame(new BinaryFrame(data)); + return sendAsyncFrame(new BinaryFrame().setPayload(data)); } @Override @@ -156,7 +156,7 @@ public class WebSocketRemoteEndpoint implements RemoteEndpoint { LOG.debug("sendBytes({}, {})",BufferUtil.toDetailString(data),callback); } - sendFrame(new BinaryFrame(data),callback); + sendFrame(new BinaryFrame().setPayload(data),callback); } public void sendFrame(WebSocketFrame frame, WriteCallback callback) @@ -196,7 +196,7 @@ public class WebSocketRemoteEndpoint implements RemoteEndpoint } else { - frame = new BinaryFrame(fragment); + frame = new BinaryFrame().setPayload(fragment); } frame.setFin(isLast); blockingWrite(frame); @@ -241,7 +241,7 @@ public class WebSocketRemoteEndpoint implements RemoteEndpoint } else { - frame = new TextFrame(fragment); + frame = new TextFrame().setPayload(fragment); } frame.setFin(isLast); blockingWrite(frame); @@ -322,7 +322,7 @@ public class WebSocketRemoteEndpoint implements RemoteEndpoint try { msgType.set(TEXT); - WebSocketFrame frame = new TextFrame(text); + WebSocketFrame frame = new TextFrame().setPayload(text); if (LOG.isDebugEnabled()) { LOG.debug("sendString with {}",BufferUtil.toDetailString(frame.getPayload())); @@ -345,7 +345,7 @@ public class WebSocketRemoteEndpoint implements RemoteEndpoint public Future sendStringByFuture(String text) { msgType.set(TEXT); - TextFrame frame = new TextFrame(text); + TextFrame frame = new TextFrame().setPayload(text); if (LOG.isDebugEnabled()) { LOG.debug("sendStringByFuture with {}",BufferUtil.toDetailString(frame.getPayload())); @@ -358,7 +358,7 @@ public class WebSocketRemoteEndpoint implements RemoteEndpoint { Objects.requireNonNull(callback,"WriteCallback cannot be null"); msgType.set(TEXT); - TextFrame frame = new TextFrame(text); + TextFrame frame = new TextFrame().setPayload(text); if (LOG.isDebugEnabled()) { LOG.debug("sendString({},{})",BufferUtil.toDetailString(frame.getPayload()),callback); diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/frames/BinaryFrame.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/frames/BinaryFrame.java index aa2dfd9a5fe..3b355637b50 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/frames/BinaryFrame.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/frames/BinaryFrame.java @@ -30,21 +30,22 @@ public class BinaryFrame extends DataFrame super(OpCode.BINARY); } - public BinaryFrame(byte[] buf) + public BinaryFrame setPayload(ByteBuffer buf) + { + super.setPayload(buf); + return this; + } + + public BinaryFrame setPayload(byte[] buf) { - this(); setPayload(ByteBuffer.wrap(buf)); + return this; } - public BinaryFrame(ByteBuffer buf) + public BinaryFrame setPayload(String payload) { - this(); - setPayload(buf); - } - - public BinaryFrame(String payload) - { - this(StringUtil.getBytes(payload)); + setPayload(StringUtil.getUtf8Bytes(payload)); + return this; } @Override diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/frames/TextFrame.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/frames/TextFrame.java index fb1e702d956..4100f04025f 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/frames/TextFrame.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/frames/TextFrame.java @@ -23,7 +23,6 @@ import java.nio.ByteBuffer; import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.websocket.common.OpCode; -import org.eclipse.jetty.websocket.common.WebSocketFrame; public class TextFrame extends DataFrame { @@ -32,19 +31,13 @@ public class TextFrame extends DataFrame super(OpCode.TEXT); } - public TextFrame(String msg) - { - this(); - setPayload(msg); - } - @Override public Type getType() { return Type.TEXT; } - public WebSocketFrame setPayload(String str) + public TextFrame setPayload(String str) { setPayload(ByteBuffer.wrap(StringUtil.getUtf8Bytes(str))); return this; diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorTest.java index 55777f3675f..e76f01516d2 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorTest.java @@ -251,7 +251,7 @@ public class GeneratorTest byte payload[] = new byte[10240]; Arrays.fill(payload,(byte)0x44); - WebSocketFrame frame = new BinaryFrame(payload); + WebSocketFrame frame = new BinaryFrame().setPayload(payload); // Generate int windowSize = 1024; @@ -279,7 +279,7 @@ public class GeneratorTest byte mask[] = new byte[] { 0x2A, (byte)0xF0, 0x0F, 0x00 }; - WebSocketFrame frame = new BinaryFrame(payload); + WebSocketFrame frame = new BinaryFrame().setPayload(payload); frame.setMask(mask); // masking! // Generate diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ParserTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ParserTest.java index 6e1e687a978..f6237d4e754 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ParserTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ParserTest.java @@ -46,10 +46,10 @@ public class ParserTest public void testParseCase5_15() { List send = new ArrayList<>(); - send.add(new TextFrame("fragment1").setFin(false)); + send.add(new TextFrame().setPayload("fragment1").setFin(false)); send.add(new ContinuationFrame("fragment2").setFin(true)); send.add(new ContinuationFrame("fragment3").setFin(false)); // bad frame - send.add(new TextFrame("fragment4").setFin(true)); + send.add(new TextFrame().setPayload("fragment4").setFin(true)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); ByteBuffer completeBuf = UnitGenerator.generate(send); @@ -71,8 +71,8 @@ public class ParserTest public void testParseCase5_18() { List send = new ArrayList<>(); - send.add(new TextFrame("fragment1").setFin(false)); - send.add(new TextFrame("fragment2").setFin(true)); // bad frame, must be continuation + send.add(new TextFrame().setPayload("fragment1").setFin(false)); + send.add(new TextFrame().setPayload("fragment2").setFin(true)); // bad frame, must be continuation send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); ByteBuffer completeBuf = UnitGenerator.generate(send); @@ -92,7 +92,7 @@ public class ParserTest public void testParseCase5_19() { List send = new ArrayList<>(); - send.add(new TextFrame("f1").setFin(false)); + send.add(new TextFrame().setPayload("f1").setFin(false)); send.add(new ContinuationFrame(",f2").setFin(false)); send.add(new PingFrame().setPayload("pong-1")); send.add(new ContinuationFrame(",f3").setFin(false)); @@ -122,7 +122,7 @@ public class ParserTest { List send = new ArrayList<>(); send.add(new PongFrame().setPayload("ping")); - send.add(new TextFrame("hello, world")); + send.add(new TextFrame().setPayload("hello, world")); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); ByteBuffer completeBuf = UnitGenerator.generate(send); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/RFC6455ExamplesGeneratorTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/RFC6455ExamplesGeneratorTest.java index 0f1ad6d43c4..51d4d23f5c4 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/RFC6455ExamplesGeneratorTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/RFC6455ExamplesGeneratorTest.java @@ -35,7 +35,7 @@ public class RFC6455ExamplesGeneratorTest @Test public void testFragmentedUnmaskedTextMessage() { - WebSocketFrame text1 = new TextFrame("Hel").setFin(false); + WebSocketFrame text1 = new TextFrame().setPayload("Hel").setFin(false); WebSocketFrame text2 = new ContinuationFrame("lo"); ByteBuffer actual1 = UnitGenerator.generate(text1); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_2.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_2.java index 4e6d435b42f..a535f40fe25 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_2.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_2.java @@ -290,7 +290,7 @@ public class TestABCase1_2 @Test public void testGenerateEmptyBinaryCase1_2_1() { - WebSocketFrame binaryFrame = new BinaryFrame(new byte[] {}); + WebSocketFrame binaryFrame = new BinaryFrame().setPayload(new byte[] {}); ByteBuffer actual = UnitGenerator.generate(binaryFrame); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/events/EventDriverTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/events/EventDriverTest.java index 39800f52f74..01f29b438d8 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/events/EventDriverTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/events/EventDriverTest.java @@ -48,7 +48,7 @@ public class EventDriverTest private Frame makeBinaryFrame(String content, boolean fin) { - return new BinaryFrame(content).setFin(fin); + return new BinaryFrame().setPayload(content).setFin(fin); } @Test @@ -116,8 +116,8 @@ public class EventDriverTest { conn.open(); driver.incomingFrame(new PingFrame().setPayload("PING")); - driver.incomingFrame(new TextFrame("Text Me")); - driver.incomingFrame(new BinaryFrame("Hello Bin")); + driver.incomingFrame(new TextFrame().setPayload("Text Me")); + driver.incomingFrame(new BinaryFrame().setPayload("Hello Bin")); driver.incomingFrame(new CloseInfo(StatusCode.SHUTDOWN,"testcase").asFrame()); socket.capture.assertEventCount(6); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/FragmentExtensionTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/FragmentExtensionTest.java index 8f05db9224f..b5a83c8ab2b 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/FragmentExtensionTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/FragmentExtensionTest.java @@ -164,14 +164,14 @@ public class FragmentExtensionTest // Expected Frames List expectedFrames = new ArrayList<>(); - expectedFrames.add(new TextFrame("No amount of experim").setFin(false)); + expectedFrames.add(new TextFrame().setPayload("No amount of experim").setFin(false)); expectedFrames.add(new ContinuationFrame("entation can ever pr").setFin(false)); expectedFrames.add(new ContinuationFrame("ove me right;").setFin(true)); - expectedFrames.add(new TextFrame("a single experiment ").setFin(false)); + expectedFrames.add(new TextFrame().setPayload("a single experiment ").setFin(false)); expectedFrames.add(new ContinuationFrame("can prove me wrong.").setFin(true)); - expectedFrames.add(new TextFrame("-- Albert Einstein").setFin(true)); + expectedFrames.add(new TextFrame().setPayload("-- Albert Einstein").setFin(true)); capture.dump(); @@ -236,9 +236,9 @@ public class FragmentExtensionTest // Expected Frames List expectedFrames = new ArrayList<>(); - expectedFrames.add(new TextFrame("No amount of experimentation can ever prove me right;")); - expectedFrames.add(new TextFrame("a single experiment can prove me wrong.")); - expectedFrames.add(new TextFrame("-- Albert Einstein")); + expectedFrames.add(new TextFrame().setPayload("No amount of experimentation can ever prove me right;")); + expectedFrames.add(new TextFrame().setPayload("a single experiment can prove me wrong.")); + expectedFrames.add(new TextFrame().setPayload("-- Albert Einstein")); // capture.dump(); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/MessageCompressionExtensionTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/MessageCompressionExtensionTest.java index 05658e6b30f..41474772d39 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/MessageCompressionExtensionTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/MessageCompressionExtensionTest.java @@ -222,7 +222,7 @@ public class MessageCompressionExtensionTest // leave frames as-is, no compression, and pass into extension for (String q : quote) { - TextFrame frame = new TextFrame(q); + TextFrame frame = new TextFrame().setPayload(q); frame.setRsv1(false); // indication to extension that frame is not compressed (ie: a normal frame) ext.incomingFrame(frame); } diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/WriteBytesProviderTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/WriteBytesProviderTest.java index 97b68eb6435..b93a5b28946 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/WriteBytesProviderTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/WriteBytesProviderTest.java @@ -123,7 +123,7 @@ public class WriteBytesProviderTest int binPayloadSize = 50; byte bin[] = new byte[binPayloadSize]; Arrays.fill(bin,(byte)0x00); - BinaryFrame binFrame = new BinaryFrame(bin); + BinaryFrame binFrame = new BinaryFrame().setPayload(bin); byte maskingKey[] = Hex.asByteArray("11223344"); binFrame.setMask(maskingKey); bytesProvider.enqueue(binFrame,binCallback); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketServletRFCTest.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketServletRFCTest.java index bb0ef085438..5081abb2c21 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketServletRFCTest.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketServletRFCTest.java @@ -103,7 +103,7 @@ public class WebSocketServletRFCTest WebSocketFrame bin; - bin = new BinaryFrame(buf1).setFin(false); + bin = new BinaryFrame().setPayload(buf1).setFin(false); client.write(bin); // write buf1 (fin=false) diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase3.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase3.java index 9af659339ea..4a45b53ff2a 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase3.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase3.java @@ -160,7 +160,7 @@ public class TestABCase3 extends AbstractABCase Arrays.fill(payload,(byte)0xFF); List send = new ArrayList<>(); - send.add(new BinaryFrame(payload).setRsv3(true).setRsv1(true)); // intentionally bad + send.add(new BinaryFrame().setPayload(payload).setRsv3(true).setRsv1(true)); // intentionally bad List expect = new ArrayList<>(); expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame()); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase5.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase5.java index de530833929..9cde353572b 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase5.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase5.java @@ -78,7 +78,7 @@ public class TestABCase5 extends AbstractABCase { List send = new ArrayList<>(); send.add(new ContinuationFrame("sorry").setFin(true)); - send.add(new TextFrame("hello, world")); + send.add(new TextFrame().setPayload("hello, world")); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); @@ -106,7 +106,7 @@ public class TestABCase5 extends AbstractABCase { List send = new ArrayList<>(); send.add(new ContinuationFrame("sorry").setFin(true)); - send.add(new TextFrame("hello, world")); + send.add(new TextFrame().setPayload("hello, world")); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); @@ -135,7 +135,7 @@ public class TestABCase5 extends AbstractABCase { List send = new ArrayList<>(); send.add(new ContinuationFrame("sorry").setFin(false)); - send.add(new TextFrame("hello, world")); + send.add(new TextFrame().setPayload("hello, world")); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); @@ -163,7 +163,7 @@ public class TestABCase5 extends AbstractABCase { List send = new ArrayList<>(); send.add(new ContinuationFrame("sorry").setFin(false)); - send.add(new TextFrame("hello, world")); + send.add(new TextFrame().setPayload("hello, world")); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); @@ -191,7 +191,7 @@ public class TestABCase5 extends AbstractABCase { List send = new ArrayList<>(); send.add(new ContinuationFrame("sorry").setFin(false)); - send.add(new TextFrame("hello, world")); + send.add(new TextFrame().setPayload("hello, world")); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); @@ -219,10 +219,10 @@ public class TestABCase5 extends AbstractABCase public void testCase5_15() throws Exception { List send = new ArrayList<>(); - send.add(new TextFrame("fragment1").setFin(false)); + send.add(new TextFrame().setPayload("fragment1").setFin(false)); send.add(new ContinuationFrame("fragment2").setFin(true)); send.add(new ContinuationFrame("fragment3").setFin(false)); // bad frame - send.add(new TextFrame("fragment4").setFin(true)); + send.add(new TextFrame().setPayload("fragment4").setFin(true)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); @@ -251,10 +251,10 @@ public class TestABCase5 extends AbstractABCase { List send = new ArrayList<>(); send.add(new ContinuationFrame("fragment1").setFin(false)); // bad frame - send.add(new TextFrame("fragment2").setFin(false)); + send.add(new TextFrame().setPayload("fragment2").setFin(false)); send.add(new ContinuationFrame("fragment3").setFin(true)); send.add(new ContinuationFrame("fragment4").setFin(false)); // bad frame - send.add(new TextFrame("fragment5").setFin(false)); + send.add(new TextFrame().setPayload("fragment5").setFin(false)); send.add(new ContinuationFrame("fragment6").setFin(true)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); @@ -283,10 +283,10 @@ public class TestABCase5 extends AbstractABCase { List send = new ArrayList<>(); send.add(new ContinuationFrame("fragment1").setFin(true)); // nothing to continue - send.add(new TextFrame("fragment2").setFin(false)); + send.add(new TextFrame().setPayload("fragment2").setFin(false)); send.add(new ContinuationFrame("fragment3").setFin(true)); send.add(new ContinuationFrame("fragment4").setFin(true)); // nothing to continue - send.add(new TextFrame("fragment5").setFin(false)); + send.add(new TextFrame().setPayload("fragment5").setFin(false)); send.add(new ContinuationFrame("fragment6").setFin(true)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); @@ -314,8 +314,8 @@ public class TestABCase5 extends AbstractABCase public void testCase5_18() throws Exception { List send = new ArrayList<>(); - send.add(new TextFrame("fragment1").setFin(false)); - send.add(new TextFrame("fragment2").setFin(true)); // bad frame, must be continuation + send.add(new TextFrame().setPayload("fragment1").setFin(false)); + send.add(new TextFrame().setPayload("fragment2").setFin(true)); // bad frame, must be continuation send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); @@ -344,7 +344,7 @@ public class TestABCase5 extends AbstractABCase { // phase 1 List send1 = new ArrayList<>(); - send1.add(new TextFrame("f1").setFin(false)); + send1.add(new TextFrame().setPayload("f1").setFin(false)); send1.add(new ContinuationFrame(",f2").setFin(false)); send1.add(new PingFrame().setPayload("pong-1")); @@ -422,7 +422,7 @@ public class TestABCase5 extends AbstractABCase public void testCase5_20() throws Exception { List send1 = new ArrayList<>(); - send1.add(new TextFrame("f1").setFin(false)); + send1.add(new TextFrame().setPayload("f1").setFin(false)); send1.add(new ContinuationFrame(",f2").setFin(false)); send1.add(new PingFrame().setPayload("pong-1")); @@ -468,7 +468,7 @@ public class TestABCase5 extends AbstractABCase public void testCase5_20_slow() throws Exception { List send1 = new ArrayList<>(); - send1.add(new TextFrame("f1").setFin(false)); + send1.add(new TextFrame().setPayload("f1").setFin(false)); send1.add(new ContinuationFrame(",f2").setFin(false)); send1.add(new PingFrame().setPayload("pong-1")); @@ -515,7 +515,7 @@ public class TestABCase5 extends AbstractABCase public void testCase5_3() throws Exception { List send = new ArrayList<>(); - send.add(new TextFrame("hello, ").setFin(false)); + send.add(new TextFrame().setPayload("hello, ").setFin(false)); send.add(new ContinuationFrame("world").setFin(true)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); @@ -544,7 +544,7 @@ public class TestABCase5 extends AbstractABCase public void testCase5_4() throws Exception { List send = new ArrayList<>(); - send.add(new TextFrame("hello, ").setFin(false)); + send.add(new TextFrame().setPayload("hello, ").setFin(false)); send.add(new ContinuationFrame("world").setFin(true)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); @@ -573,7 +573,7 @@ public class TestABCase5 extends AbstractABCase public void testCase5_5() throws Exception { List send = new ArrayList<>(); - send.add(new TextFrame("hello, ").setFin(false)); + send.add(new TextFrame().setPayload("hello, ").setFin(false)); send.add(new ContinuationFrame("world").setFin(true)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); @@ -603,7 +603,7 @@ public class TestABCase5 extends AbstractABCase public void testCase5_6() throws Exception { List send = new ArrayList<>(); - send.add(new TextFrame("hello, ").setFin(false)); + send.add(new TextFrame().setPayload("hello, ").setFin(false)); send.add(new PingFrame().setPayload("ping")); send.add(new ContinuationFrame("world").setFin(true)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); @@ -634,7 +634,7 @@ public class TestABCase5 extends AbstractABCase public void testCase5_7() throws Exception { List send = new ArrayList<>(); - send.add(new TextFrame("hello, ").setFin(false)); + send.add(new TextFrame().setPayload("hello, ").setFin(false)); send.add(new PingFrame().setPayload("ping")); send.add(new ContinuationFrame("world").setFin(true)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); @@ -665,7 +665,7 @@ public class TestABCase5 extends AbstractABCase public void testCase5_8() throws Exception { List send = new ArrayList<>(); - send.add(new TextFrame("hello, ").setFin(false)); + send.add(new TextFrame().setPayload("hello, ").setFin(false)); send.add(new PingFrame().setPayload("ping")); send.add(new ContinuationFrame("world").setFin(true)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); @@ -699,7 +699,7 @@ public class TestABCase5 extends AbstractABCase List send = new ArrayList<>(); send.add(new ContinuationFrame("sorry").setFin(true)); - send.add(new TextFrame("hello, world")); + send.add(new TextFrame().setPayload("hello, world")); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase9.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase9.java index 0641e8b354a..8be2b8ce455 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase9.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase9.java @@ -344,7 +344,7 @@ public class TestABCase9 extends AbstractABCase Arrays.fill(data,(byte)0x21); List send = new ArrayList<>(); - send.add(new BinaryFrame(data)); + send.add(new BinaryFrame().setPayload(data)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>();