diff --git a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrAsyncRemote.java b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrAsyncRemote.java index 574aa265385..9021065b7ce 100644 --- a/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrAsyncRemote.java +++ b/jetty-websocket/javax-websocket-client-impl/src/main/java/org/eclipse/jetty/websocket/jsr356/JsrAsyncRemote.java @@ -32,6 +32,8 @@ import org.eclipse.jetty.util.BufferUtil; import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.common.WebSocketFrame; +import org.eclipse.jetty.websocket.common.frames.BinaryFrame; +import org.eclipse.jetty.websocket.common.frames.TextFrame; import org.eclipse.jetty.websocket.common.message.MessageOutputStream; import org.eclipse.jetty.websocket.common.message.MessageWriter; import org.eclipse.jetty.websocket.common.util.TextUtil; @@ -73,7 +75,7 @@ public class JsrAsyncRemote extends AbstractJsrRemote implements RemoteEndpoint. { LOG.debug("sendBinary({},{})",BufferUtil.toDetailString(data),handler); } - WebSocketFrame frame = WebSocketFrame.binary().setPayload(data).setFin(true); + WebSocketFrame frame = new BinaryFrame().setPayload(data).setFin(true); jettyRemote.sendFrame(frame,new SendHandlerWriteCallback(handler)); } @@ -183,7 +185,7 @@ public class JsrAsyncRemote extends AbstractJsrRemote implements RemoteEndpoint. { LOG.debug("sendText({},{})",TextUtil.hint(text),handler); } - WebSocketFrame frame = WebSocketFrame.text(text).setFin(true); + WebSocketFrame frame = new TextFrame().setPayload(text).setFin(true); jettyRemote.sendFrame(frame,new SendHandlerWriteCallback(handler)); } diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ServerWriteThread.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ServerWriteThread.java index d3a705c5632..66f6d7244a0 100644 --- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ServerWriteThread.java +++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/ServerWriteThread.java @@ -27,6 +27,7 @@ import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer.ServerConnection; import org.eclipse.jetty.websocket.common.WebSocketFrame; +import org.eclipse.jetty.websocket.common.frames.TextFrame; public class ServerWriteThread extends Thread { @@ -71,7 +72,7 @@ public class ServerWriteThread extends Thread { while (m.get() < messageCount) { - conn.write(WebSocketFrame.text(message)); + conn.write(new TextFrame().setPayload(message)); if (exchanger != null) { diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/WebSocketClientTest.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/WebSocketClientTest.java index 69ef01ec208..bc914f60ec8 100644 --- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/WebSocketClientTest.java +++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/WebSocketClientTest.java @@ -34,6 +34,7 @@ import org.eclipse.jetty.websocket.api.UpgradeRequest; import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer; import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer.ServerConnection; import org.eclipse.jetty.websocket.common.WebSocketFrame; +import org.eclipse.jetty.websocket.common.frames.TextFrame; import org.eclipse.jetty.websocket.common.io.FutureWriteCallback; import org.junit.After; import org.junit.Assert; @@ -179,7 +180,7 @@ public class WebSocketClientTest Assert.assertThat("Session.upgradeResponse",sess.getUpgradeResponse(),notNullValue()); // Have server send initial message - srvSock.write(WebSocketFrame.text("Hello World")); + srvSock.write(new TextFrame().setPayload("Hello World")); // Verify connect future.get(500,TimeUnit.MILLISECONDS); diff --git a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/blockhead/BlockheadServer.java b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/blockhead/BlockheadServer.java index b51e06e7a26..c5b0b6b845b 100644 --- a/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/blockhead/BlockheadServer.java +++ b/jetty-websocket/websocket-client/src/test/java/org/eclipse/jetty/websocket/client/blockhead/BlockheadServer.java @@ -53,7 +53,6 @@ import org.eclipse.jetty.websocket.api.WebSocketPolicy; import org.eclipse.jetty.websocket.api.WriteCallback; import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig; import org.eclipse.jetty.websocket.api.extensions.Frame; -import org.eclipse.jetty.websocket.api.extensions.Frame.Type; import org.eclipse.jetty.websocket.api.extensions.IncomingFrames; import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames; import org.eclipse.jetty.websocket.common.AcceptHash; @@ -220,7 +219,7 @@ public class BlockheadServer } incomingFrames.incomingFrame(WebSocketFrame.copy(frame)); - if (frame.getType() == Type.CLOSE) + if (frame.getOpCode() == OpCode.CLOSE) { CloseInfo close = new CloseInfo(frame); LOG.debug("Close frame: {}",close); @@ -246,7 +245,7 @@ public class BlockheadServer callback.writeSuccess(); } - if (frame.getType().getOpCode() == OpCode.CLOSE) + if (frame.getOpCode() == OpCode.CLOSE) { disconnect(); } diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/Generator.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/Generator.java index 3b919a439c6..b431dbbff10 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/Generator.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/Generator.java @@ -129,7 +129,7 @@ public class Generator throw new ProtocolException("RSV3 not allowed to be set"); } - if (frame.getType().isControl()) + if (OpCode.isControlFrame(frame.getOpCode())) { /* * RFC 6455 Section 5.5 @@ -151,7 +151,7 @@ public class Generator * * close frame payload is specially formatted which is checked in CloseInfo */ - if (frame.getType().getOpCode() == OpCode.CLOSE) + if (frame.getOpCode() == OpCode.CLOSE) { ByteBuffer payload = frame.getPayload(); diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketFrame.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketFrame.java index 7035834a255..ddbe0b0e8df 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketFrame.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/WebSocketFrame.java @@ -56,21 +56,6 @@ import org.eclipse.jetty.websocket.common.frames.TextFrame; */ public abstract class WebSocketFrame implements Frame { - public static BinaryFrame binary() - { - return new BinaryFrame(); - } - - public static BinaryFrame binary(byte buf[]) - { - return new BinaryFrame(buf); - } - - public static BinaryFrame binary(ByteBuffer buf) - { - return new BinaryFrame(buf); - } - public static WebSocketFrame copy(Frame copy) { WebSocketFrame frame = null; @@ -104,26 +89,6 @@ public abstract class WebSocketFrame implements Frame return frame; } - public static PingFrame ping() - { - return new PingFrame(); - } - - public static PongFrame pong() - { - return new PongFrame(); - } - - public static TextFrame text() - { - return new TextFrame(); - } - - public static TextFrame text(String msg) - { - return new TextFrame(msg); - } - /** * Combined FIN + RSV1 + RSV2 + RSV3 + OpCode byte. *

@@ -149,9 +114,6 @@ public abstract class WebSocketFrame implements Frame protected int payloadLength = 0; - // FIXME: Remove - private Type type; - /** * Construct form opcode */ @@ -178,7 +140,6 @@ public abstract class WebSocketFrame implements Frame finRsvOp |= frame.isRsv3()?0x10:0x00; finRsvOp |= frame.getOpCode() & 0x0F; - type = frame.getType(); masked = frame.isMasked(); if (masked) { @@ -193,7 +154,6 @@ public abstract class WebSocketFrame implements Frame protected void copyHeaders(WebSocketFrame copy) { finRsvOp = copy.finRsvOp; - type = copy.type; masked = copy.masked; mask = null; if (copy.mask != null) @@ -289,7 +249,7 @@ public abstract class WebSocketFrame implements Frame @Override public Type getType() { - return type; + return Type.from(getOpCode()); } @Override @@ -414,15 +374,6 @@ public abstract class WebSocketFrame implements Frame protected WebSocketFrame setOpCode(byte op) { this.finRsvOp = (byte)((finRsvOp & 0xF0) | (op & 0x0F)); - - if (op == OpCode.UNDEFINED) - { - this.type = null; - } - else - { - this.type = Frame.Type.from(op); - } return this; } diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/AbstractEventDriver.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/AbstractEventDriver.java index 1a069cefafa..2e214b80be8 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/AbstractEventDriver.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/events/AbstractEventDriver.java @@ -110,7 +110,7 @@ public abstract class AbstractEventDriver implements IncomingFrames, EventDriver { onFrame(frame); - byte opcode = frame.getType().getOpCode(); + byte opcode = frame.getOpCode(); switch (opcode) { case OpCode.CLOSE: diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/FrameCompressionExtension.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/FrameCompressionExtension.java index fda22eaeab6..fefe1195576 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/FrameCompressionExtension.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/FrameCompressionExtension.java @@ -24,6 +24,7 @@ import java.nio.ByteBuffer; import org.eclipse.jetty.websocket.api.WriteCallback; import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig; import org.eclipse.jetty.websocket.api.extensions.Frame; +import org.eclipse.jetty.websocket.common.OpCode; import org.eclipse.jetty.websocket.common.extensions.AbstractExtension; import org.eclipse.jetty.websocket.common.frames.DataFrame; @@ -44,7 +45,7 @@ public class FrameCompressionExtension extends AbstractExtension @Override public synchronized void incomingFrame(Frame frame) { - if (frame.getType().isControl() || !frame.isRsv1()) + if (OpCode.isControlFrame(frame.getOpCode()) || !frame.isRsv1()) { // Cannot modify incoming control frames or ones with RSV1 set. nextIncomingFrame(frame); @@ -84,7 +85,7 @@ public class FrameCompressionExtension extends AbstractExtension @Override public synchronized void outgoingFrame(Frame frame, WriteCallback callback) { - if (frame.getType().isControl()) + if (OpCode.isControlFrame(frame.getOpCode())) { // skip, cannot compress control frames. nextOutgoingFrame(frame,callback); diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/MessageDeflateCompressionExtension.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/MessageDeflateCompressionExtension.java index 79c7987a586..5446be7397b 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/MessageDeflateCompressionExtension.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/compress/MessageDeflateCompressionExtension.java @@ -23,6 +23,7 @@ import java.nio.ByteBuffer; import org.eclipse.jetty.websocket.api.WriteCallback; import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig; import org.eclipse.jetty.websocket.api.extensions.Frame; +import org.eclipse.jetty.websocket.common.OpCode; import org.eclipse.jetty.websocket.common.extensions.AbstractExtension; import org.eclipse.jetty.websocket.common.frames.DataFrame; @@ -44,7 +45,7 @@ public class MessageDeflateCompressionExtension extends AbstractExtension @Override public void incomingFrame(Frame frame) { - if (frame.getType().isControl() || !frame.isRsv1()) + if (OpCode.isControlFrame(frame.getOpCode()) || !frame.isRsv1()) { // Cannot modify incoming control frames or ones with RSV1 set. nextIncomingFrame(frame); @@ -90,7 +91,7 @@ public class MessageDeflateCompressionExtension extends AbstractExtension @Override public void outgoingFrame(Frame frame, WriteCallback callback) { - if (frame.getType().isControl()) + if (OpCode.isControlFrame(frame.getOpCode())) { // skip, cannot compress control frames. nextOutgoingFrame(frame,callback); diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/fragment/FragmentExtension.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/fragment/FragmentExtension.java index 9803a821eee..8bbc63367aa 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/fragment/FragmentExtension.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/extensions/fragment/FragmentExtension.java @@ -24,6 +24,7 @@ import java.nio.ByteBuffer; import org.eclipse.jetty.websocket.api.WriteCallback; import org.eclipse.jetty.websocket.api.extensions.ExtensionConfig; import org.eclipse.jetty.websocket.api.extensions.Frame; +import org.eclipse.jetty.websocket.common.OpCode; import org.eclipse.jetty.websocket.common.extensions.AbstractExtension; import org.eclipse.jetty.websocket.common.frames.DataFrame; @@ -57,7 +58,7 @@ public class FragmentExtension extends AbstractExtension @Override public void outgoingFrame(Frame frame, WriteCallback callback) { - if (frame.getType().isControl()) + if (OpCode.isControlFrame(frame.getOpCode())) { // Cannot fragment Control Frames nextOutgoingFrame(frame,callback); diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/frames/CloseFrame.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/frames/CloseFrame.java index 101cf4b1830..129843511b4 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/frames/CloseFrame.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/frames/CloseFrame.java @@ -28,6 +28,12 @@ public class CloseFrame extends ControlFrame super(OpCode.CLOSE); } + @Override + public Type getType() + { + return Type.CLOSE; + } + /** * Truncate arbitrary reason into something that will fit into the CloseFrame limits. * diff --git a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/WriteBytesProvider.java b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/WriteBytesProvider.java index 82895df0b9b..1b86b213c14 100644 --- a/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/WriteBytesProvider.java +++ b/jetty-websocket/websocket-common/src/main/java/org/eclipse/jetty/websocket/common/io/WriteBytesProvider.java @@ -34,6 +34,7 @@ import org.eclipse.jetty.util.log.Log; import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.api.extensions.Frame; import org.eclipse.jetty.websocket.common.Generator; +import org.eclipse.jetty.websocket.common.OpCode; /** * Interface for working with bytes destined for {@link EndPoint#write(Callback, ByteBuffer...)} @@ -190,12 +191,12 @@ public class WriteBytesProvider implements Callback FrameEntry entry = new FrameEntry(frame,callback); - switch (frame.getType()) + switch (frame.getOpCode()) { - case PING: + case OpCode.PING: queue.addFirst(entry); break; - case CLOSE: + case OpCode.CLOSE: closed.set(true); // drop the rest of the queue? queue.addLast(entry); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorParserRoundtripTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorParserRoundtripTest.java index ae4ff939ff0..069f8ec2154 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorParserRoundtripTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/GeneratorParserRoundtripTest.java @@ -50,7 +50,7 @@ public class GeneratorParserRoundtripTest { // Generate Buffer BufferUtil.flipToFill(out); - WebSocketFrame frame = WebSocketFrame.text(message); + WebSocketFrame frame = new TextFrame().setPayload(message); ByteBuffer header = gen.generateHeaderBytes(frame); ByteBuffer payload = gen.getPayloadWindow(frame.getPayloadLength(),frame); out.put(header); @@ -90,7 +90,7 @@ public class GeneratorParserRoundtripTest try { // Setup Frame - WebSocketFrame frame = WebSocketFrame.text(message); + WebSocketFrame frame = new TextFrame().setPayload(message); // Add masking byte mask[] = new byte[4]; 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 9b493e8dcd6..be2fa8ca17d 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 @@ -30,8 +30,10 @@ import org.eclipse.jetty.util.log.Logger; import org.eclipse.jetty.websocket.api.StatusCode; import org.eclipse.jetty.websocket.api.WebSocketPolicy; import org.eclipse.jetty.websocket.api.extensions.Frame; +import org.eclipse.jetty.websocket.common.frames.BinaryFrame; import org.eclipse.jetty.websocket.common.frames.CloseFrame; import org.eclipse.jetty.websocket.common.frames.PingFrame; +import org.eclipse.jetty.websocket.common.frames.TextFrame; import org.junit.Assert; import org.junit.Test; @@ -155,7 +157,7 @@ public class GeneratorTest @Test public void testText_Hello() { - WebSocketFrame frame = WebSocketFrame.text("Hello"); + WebSocketFrame frame = new TextFrame().setPayload("Hello"); byte utf[] = StringUtil.getUtf8Bytes("Hello"); assertGeneratedBytes("8105" + Hex.asHex(utf),frame); } @@ -163,7 +165,7 @@ public class GeneratorTest @Test public void testText_Masked() { - WebSocketFrame frame = WebSocketFrame.text("Hello"); + WebSocketFrame frame = new TextFrame().setPayload("Hello"); byte maskingKey[] = Hex.asByteArray("11223344"); frame.setMask(maskingKey); @@ -189,7 +191,7 @@ public class GeneratorTest // we are testing that masking works as intended, even if the provided // payload does not start at position 0. LOG.debug("Payload = {}",BufferUtil.toDetailString(payload)); - WebSocketFrame frame = WebSocketFrame.text().setPayload(payload); + WebSocketFrame frame = new TextFrame().setPayload(payload); byte maskingKey[] = Hex.asByteArray("11223344"); frame.setMask(maskingKey); @@ -249,7 +251,7 @@ public class GeneratorTest byte payload[] = new byte[10240]; Arrays.fill(payload,(byte)0x44); - WebSocketFrame frame = WebSocketFrame.binary(payload); + WebSocketFrame frame = new BinaryFrame(payload); // Generate int windowSize = 1024; @@ -277,7 +279,7 @@ public class GeneratorTest byte mask[] = new byte[] { 0x2A, (byte)0xF0, 0x0F, 0x00 }; - WebSocketFrame frame = WebSocketFrame.binary(payload); + WebSocketFrame frame = new BinaryFrame(payload); frame.setMask(mask); // masking! // Generate 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 3854ee09b1d..ab8bbc343df 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 @@ -80,7 +80,7 @@ public class RFC6455ExamplesGeneratorTest @Test public void testSingleMaskedTextMessage() { - WebSocketFrame text = WebSocketFrame.text("Hello"); + WebSocketFrame text = new TextFrame().setPayload("Hello"); text.setMask(new byte[] { 0x37, (byte)0xfa, 0x21, 0x3d }); @@ -173,7 +173,7 @@ public class RFC6455ExamplesGeneratorTest @Test public void testSingleUnmaskedTextMessage() { - WebSocketFrame text = WebSocketFrame.text("Hello"); + WebSocketFrame text = new TextFrame().setPayload("Hello"); ByteBuffer actual = UnitGenerator.generate(text); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_1.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_1.java index 8fc8564bb44..a5c0d49ea56 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_1.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase1_1.java @@ -35,6 +35,7 @@ import org.eclipse.jetty.websocket.common.Parser; import org.eclipse.jetty.websocket.common.UnitGenerator; import org.eclipse.jetty.websocket.common.UnitParser; import org.eclipse.jetty.websocket.common.WebSocketFrame; +import org.eclipse.jetty.websocket.common.frames.TextFrame; import org.junit.Assert; import org.junit.Test; @@ -53,7 +54,7 @@ public class TestABCase1_1 Arrays.fill(buf,(byte)'*'); String text = new String(buf,StringUtil.__UTF8_CHARSET); - Frame textFrame = WebSocketFrame.text(text); + Frame textFrame = new TextFrame().setPayload(text); ByteBuffer actual = UnitGenerator.generate(textFrame); @@ -88,7 +89,7 @@ public class TestABCase1_1 builder.append("*"); } - WebSocketFrame textFrame = WebSocketFrame.text(builder.toString()); + WebSocketFrame textFrame = new TextFrame().setPayload(builder.toString()); ByteBuffer actual = UnitGenerator.generate(textFrame); @@ -127,7 +128,7 @@ public class TestABCase1_1 builder.append("*"); } - WebSocketFrame textFrame = WebSocketFrame.text(builder.toString()); + WebSocketFrame textFrame = new TextFrame().setPayload(builder.toString()); ByteBuffer actual = UnitGenerator.generate(textFrame); @@ -166,7 +167,7 @@ public class TestABCase1_1 builder.append("*"); } - WebSocketFrame textFrame = WebSocketFrame.text(builder.toString()); + WebSocketFrame textFrame = new TextFrame().setPayload(builder.toString()); ByteBuffer actual = UnitGenerator.generate(textFrame); @@ -205,7 +206,7 @@ public class TestABCase1_1 builder.append("*"); } - WebSocketFrame textFrame = WebSocketFrame.text(builder.toString()); + WebSocketFrame textFrame = new TextFrame().setPayload(builder.toString()); ByteBuffer actual = UnitGenerator.generate(textFrame); @@ -242,7 +243,7 @@ public class TestABCase1_1 builder.append("*"); } - WebSocketFrame textFrame = WebSocketFrame.text(builder.toString()); + WebSocketFrame textFrame = new TextFrame().setPayload(builder.toString()); ByteBuffer actual = UnitGenerator.generate(textFrame); @@ -270,7 +271,7 @@ public class TestABCase1_1 @Test public void testGenerateEmptyTextCase1_1_1() { - WebSocketFrame textFrame = WebSocketFrame.text(""); + WebSocketFrame textFrame = new TextFrame().setPayload(""); ByteBuffer actual = UnitGenerator.generate(textFrame); 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 1d0e24f77bc..4e6d435b42f 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 @@ -34,6 +34,7 @@ import org.eclipse.jetty.websocket.common.Parser; import org.eclipse.jetty.websocket.common.UnitGenerator; import org.eclipse.jetty.websocket.common.UnitParser; import org.eclipse.jetty.websocket.common.WebSocketFrame; +import org.eclipse.jetty.websocket.common.frames.BinaryFrame; import org.junit.Assert; import org.junit.Test; @@ -58,7 +59,7 @@ public class TestABCase1_2 bb.flip(); - WebSocketFrame binaryFrame = WebSocketFrame.binary().setPayload(bb); + WebSocketFrame binaryFrame = new BinaryFrame().setPayload(bb); ByteBuffer actual = UnitGenerator.generate(binaryFrame); @@ -96,7 +97,7 @@ public class TestABCase1_2 bb.flip(); - WebSocketFrame binaryFrame = WebSocketFrame.binary().setPayload(bb); + WebSocketFrame binaryFrame = new BinaryFrame().setPayload(bb); ByteBuffer actual = UnitGenerator.generate(binaryFrame); @@ -138,7 +139,7 @@ public class TestABCase1_2 bb.flip(); - WebSocketFrame binaryFrame = WebSocketFrame.binary().setPayload(bb); + WebSocketFrame binaryFrame = new BinaryFrame().setPayload(bb); ByteBuffer actual = UnitGenerator.generate(binaryFrame); @@ -179,7 +180,7 @@ public class TestABCase1_2 } bb.flip(); - WebSocketFrame binaryFrame = WebSocketFrame.binary().setPayload(bb); + WebSocketFrame binaryFrame = new BinaryFrame().setPayload(bb); ByteBuffer actual = UnitGenerator.generate(binaryFrame); @@ -222,7 +223,7 @@ public class TestABCase1_2 bb.flip(); - WebSocketFrame binaryFrame = WebSocketFrame.binary().setPayload(bb); + WebSocketFrame binaryFrame = new BinaryFrame().setPayload(bb); ByteBuffer actual = UnitGenerator.generate(binaryFrame); @@ -261,7 +262,7 @@ public class TestABCase1_2 bb.flip(); - WebSocketFrame binaryFrame = WebSocketFrame.binary().setPayload(bb); + WebSocketFrame binaryFrame = new BinaryFrame().setPayload(bb); ByteBuffer actual = UnitGenerator.generate(binaryFrame); @@ -289,7 +290,7 @@ public class TestABCase1_2 @Test public void testGenerateEmptyBinaryCase1_2_1() { - WebSocketFrame binaryFrame = WebSocketFrame.binary(new byte[] {}); + WebSocketFrame binaryFrame = new BinaryFrame(new byte[] {}); ByteBuffer actual = UnitGenerator.generate(binaryFrame); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase2.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase2.java index e964c2ce170..4ccc9be7dae 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase2.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase2.java @@ -102,7 +102,7 @@ public class TestABCase2 @Test public void testGenerateEmptyPingCase2_1() { - WebSocketFrame pingFrame = WebSocketFrame.ping(); + WebSocketFrame pingFrame = new PingFrame(); ByteBuffer actual = UnitGenerator.generate(pingFrame); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase3.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase3.java index 01cfdc6a288..ce6e363170a 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase3.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/ab/TestABCase3.java @@ -27,6 +27,8 @@ import org.eclipse.jetty.websocket.api.ProtocolException; import org.eclipse.jetty.websocket.common.CloseInfo; import org.eclipse.jetty.websocket.common.UnitGenerator; import org.eclipse.jetty.websocket.common.WebSocketFrame; +import org.eclipse.jetty.websocket.common.frames.PingFrame; +import org.eclipse.jetty.websocket.common.frames.PongFrame; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -45,21 +47,21 @@ public class TestABCase3 List data = new ArrayList<>(); // @formatter:off data.add(new WebSocketFrame[] - { WebSocketFrame.ping().setFin(false) }); + { new PingFrame().setFin(false) }); data.add(new WebSocketFrame[] - { WebSocketFrame.ping().setRsv1(true) }); + { new PingFrame().setRsv1(true) }); data.add(new WebSocketFrame[] - { WebSocketFrame.ping().setRsv2(true) }); + { new PingFrame().setRsv2(true) }); data.add(new WebSocketFrame[] - { WebSocketFrame.ping().setRsv3(true) }); + { new PingFrame().setRsv3(true) }); data.add(new WebSocketFrame[] - { WebSocketFrame.pong().setFin(false) }); + { new PongFrame().setFin(false) }); data.add(new WebSocketFrame[] - { WebSocketFrame.ping().setRsv1(true) }); + { new PingFrame().setRsv1(true) }); data.add(new WebSocketFrame[] - { WebSocketFrame.pong().setRsv2(true) }); + { new PongFrame().setRsv2(true) }); data.add(new WebSocketFrame[] - { WebSocketFrame.pong().setRsv3(true) }); + { new PongFrame().setRsv3(true) }); data.add(new WebSocketFrame[] { new CloseInfo().asFrame().setFin(false) }); data.add(new WebSocketFrame[] 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 b69c8275859..1998828f285 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 @@ -160,7 +160,7 @@ public class EventDriverTest { conn.start(); conn.open(); - driver.incomingFrame(WebSocketFrame.text("Hello World")); + driver.incomingFrame(new TextFrame().setPayload("Hello World")); driver.incomingFrame(new CloseInfo(StatusCode.NORMAL).asFrame()); socket.capture.assertEventCount(3); 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 b554fe0ba5e..5aefccb1106 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 @@ -71,7 +71,7 @@ public class FragmentExtensionTest // Manually create frame and pass into extension for (String q : quote) { - Frame frame = WebSocketFrame.text(q); + Frame frame = new TextFrame().setPayload(q); ext.incomingFrame(frame); } @@ -158,7 +158,7 @@ public class FragmentExtensionTest // Write quote as separate frames for (String section : quote) { - Frame frame = WebSocketFrame.text(section); + Frame frame = new TextFrame().setPayload(section); ext.outgoingFrame(frame,null); } @@ -230,7 +230,7 @@ public class FragmentExtensionTest // Write quote as separate frames for (String section : quote) { - Frame frame = WebSocketFrame.text(section); + Frame frame = new TextFrame().setPayload(section); ext.outgoingFrame(frame,null); } diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/IdentityExtensionTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/IdentityExtensionTest.java index b1a4528f723..f6569f2140b 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/IdentityExtensionTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/IdentityExtensionTest.java @@ -33,6 +33,7 @@ import org.eclipse.jetty.websocket.common.OpCode; import org.eclipse.jetty.websocket.common.OutgoingFramesCapture; import org.eclipse.jetty.websocket.common.WebSocketFrame; import org.eclipse.jetty.websocket.common.extensions.identity.IdentityExtension; +import org.eclipse.jetty.websocket.common.frames.TextFrame; import org.junit.Assert; import org.junit.Test; @@ -49,7 +50,7 @@ public class IdentityExtensionTest Extension ext = new IdentityExtension(); ext.setNextIncomingFrames(capture); - Frame frame = WebSocketFrame.text("hello"); + Frame frame = new TextFrame().setPayload("hello"); ext.incomingFrame(frame); capture.assertFrameCount(1); @@ -78,7 +79,7 @@ public class IdentityExtensionTest Extension ext = new IdentityExtension(); ext.setNextOutgoingFrames(capture); - Frame frame = WebSocketFrame.text("hello"); + Frame frame = new TextFrame().setPayload("hello"); ext.outgoingFrame(frame,null); capture.assertFrameCount(1); diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/FrameCompressionExtensionTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/FrameCompressionExtensionTest.java index 68f47308ebc..9e47cd823c5 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/FrameCompressionExtensionTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/extensions/compress/FrameCompressionExtensionTest.java @@ -42,6 +42,7 @@ import org.eclipse.jetty.websocket.common.OutgoingNetworkBytesCapture; import org.eclipse.jetty.websocket.common.Parser; import org.eclipse.jetty.websocket.common.UnitParser; import org.eclipse.jetty.websocket.common.WebSocketFrame; +import org.eclipse.jetty.websocket.common.frames.TextFrame; import org.junit.Assert; import org.junit.Test; @@ -109,7 +110,7 @@ public class FrameCompressionExtensionTest OutgoingNetworkBytesCapture capture = new OutgoingNetworkBytesCapture(generator); ext.setNextOutgoingFrames(capture); - Frame frame = WebSocketFrame.text(text); + Frame frame = new TextFrame().setPayload(text); ext.outgoingFrame(frame,null); capture.assertBytes(0,expectedHex); @@ -228,8 +229,8 @@ public class FrameCompressionExtensionTest OutgoingNetworkBytesCapture capture = new OutgoingNetworkBytesCapture(generator); ext.setNextOutgoingFrames(capture); - ext.outgoingFrame(WebSocketFrame.text("Hello"),null); - ext.outgoingFrame(WebSocketFrame.text("There"),null); + ext.outgoingFrame(new TextFrame().setPayload("Hello"),null); + ext.outgoingFrame(new TextFrame().setPayload("There"),null); capture.assertBytes(0,"c107f248cdc9c90700"); capture.assertBytes(1,"c1070ac9482d4a0500"); 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 fa0961c1ac4..ed13e3f1661 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 @@ -288,7 +288,7 @@ public class MessageCompressionExtensionTest // Write quote as separate frames for (String section : quote) { - Frame frame = WebSocketFrame.text(section); + Frame frame = new TextFrame().setPayload(section); ext.outgoingFrame(frame,null); } 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 7d70e205e9c..62cda9e8151 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 @@ -33,6 +33,7 @@ import org.eclipse.jetty.websocket.common.Hex; import org.eclipse.jetty.websocket.common.UnitGenerator; import org.eclipse.jetty.websocket.common.WebSocketFrame; import org.eclipse.jetty.websocket.common.frames.BinaryFrame; +import org.eclipse.jetty.websocket.common.frames.TextFrame; import org.junit.Assert; import org.junit.Test; @@ -56,7 +57,7 @@ public class WriteBytesProviderTest bytesProvider = new WriteBytesProvider(generator,flushCallback); TrackingCallback frameCallback = new TrackingCallback(); - Frame frame = WebSocketFrame.text("Test"); + Frame frame = new TextFrame().setPayload("Test"); // place in to bytes provider bytesProvider.enqueue(frame,frameCallback); @@ -86,7 +87,7 @@ public class WriteBytesProviderTest // Create frames for provider TrackingCallback textCallback = new TrackingCallback(); TrackingCallback closeCallback = new TrackingCallback(); - bytesProvider.enqueue(WebSocketFrame.text("Bye"),textCallback); + bytesProvider.enqueue(new TextFrame().setPayload("Bye"),textCallback); bytesProvider.enqueue(new CloseInfo().asFrame(),closeCallback); // get bytes out diff --git a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/payload/DeMaskProcessorTest.java b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/payload/DeMaskProcessorTest.java index 492ec0650c6..2c8debdb70d 100644 --- a/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/payload/DeMaskProcessorTest.java +++ b/jetty-websocket/websocket-common/src/test/java/org/eclipse/jetty/websocket/common/io/payload/DeMaskProcessorTest.java @@ -45,7 +45,7 @@ public class DeMaskProcessorTest // Use a string that is not multiple of 4 in length to test if/else branches in DeMaskProcessor String message = "0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF01"; - WebSocketFrame frame = WebSocketFrame.text(message); + WebSocketFrame frame = new TextFrame().setPayload(message); frame.setMask(TypeUtil.fromHexString("11223344")); ByteBuffer buf = UnitGenerator.generate(frame); diff --git a/jetty-websocket/websocket-mux-extension/src/main/java/org/eclipse/jetty/websocket/mux/MuxGenerator.java b/jetty-websocket/websocket-mux-extension/src/main/java/org/eclipse/jetty/websocket/mux/MuxGenerator.java index 7b86cbe5dcc..20a9611d02b 100644 --- a/jetty-websocket/websocket-mux-extension/src/main/java/org/eclipse/jetty/websocket/mux/MuxGenerator.java +++ b/jetty-websocket/websocket-mux-extension/src/main/java/org/eclipse/jetty/websocket/mux/MuxGenerator.java @@ -28,6 +28,7 @@ import org.eclipse.jetty.websocket.api.WriteCallback; import org.eclipse.jetty.websocket.api.extensions.Frame; import org.eclipse.jetty.websocket.api.extensions.OutgoingFrames; import org.eclipse.jetty.websocket.common.WebSocketFrame; +import org.eclipse.jetty.websocket.common.frames.BinaryFrame; import org.eclipse.jetty.websocket.mux.op.MuxAddChannelRequest; import org.eclipse.jetty.websocket.mux.op.MuxAddChannelResponse; import org.eclipse.jetty.websocket.mux.op.MuxDropChannel; @@ -66,12 +67,12 @@ public class MuxGenerator b |= (byte)(frame.isRsv1()?0x40:0x00); // rsv1 b |= (byte)(frame.isRsv2()?0x20:0x00); // rsv2 b |= (byte)(frame.isRsv3()?0x10:0x00); // rsv3 - b |= (byte)(frame.getType().getOpCode() & 0x0F); // opcode + b |= (byte)(frame.getOpCode() & 0x0F); // opcode muxPayload.put(b); BufferUtil.put(frame.getPayload(),muxPayload); // build muxed frame - WebSocketFrame muxFrame = WebSocketFrame.binary(); + WebSocketFrame muxFrame = new BinaryFrame(); BufferUtil.flipToFlush(muxPayload,0); muxFrame.setPayload(muxPayload); // NOTE: the physical connection will handle masking rules for this frame. @@ -164,7 +165,7 @@ public class MuxGenerator } } BufferUtil.flipToFlush(payload,0); - WebSocketFrame frame = WebSocketFrame.binary(); + WebSocketFrame frame = new BinaryFrame(); frame.setPayload(payload); outgoing.outgoingFrame(frame,callback); } diff --git a/jetty-websocket/websocket-mux-extension/src/main/java/org/eclipse/jetty/websocket/mux/MuxParser.java b/jetty-websocket/websocket-mux-extension/src/main/java/org/eclipse/jetty/websocket/mux/MuxParser.java index 34df02caf40..fd1d9f06fcd 100644 --- a/jetty-websocket/websocket-mux-extension/src/main/java/org/eclipse/jetty/websocket/mux/MuxParser.java +++ b/jetty-websocket/websocket-mux-extension/src/main/java/org/eclipse/jetty/websocket/mux/MuxParser.java @@ -81,7 +81,7 @@ public class MuxParser return; // nothing to parse } - if (frame.getType().getOpCode() != OpCode.BINARY) + if (frame.getOpCode() != OpCode.BINARY) { LOG.debug("Not a binary opcode (base frame), skipping"); return; // not a binary opcode diff --git a/jetty-websocket/websocket-mux-extension/src/test/java/org/eclipse/jetty/websocket/mux/add/MuxerAddServerTest.java b/jetty-websocket/websocket-mux-extension/src/test/java/org/eclipse/jetty/websocket/mux/add/MuxerAddServerTest.java index c543c4375bc..180e97a511d 100644 --- a/jetty-websocket/websocket-mux-extension/src/test/java/org/eclipse/jetty/websocket/mux/add/MuxerAddServerTest.java +++ b/jetty-websocket/websocket-mux-extension/src/test/java/org/eclipse/jetty/websocket/mux/add/MuxerAddServerTest.java @@ -23,6 +23,7 @@ import static org.hamcrest.Matchers.*; import org.eclipse.jetty.websocket.api.WebSocketPolicy; import org.eclipse.jetty.websocket.common.OpCode; import org.eclipse.jetty.websocket.common.WebSocketFrame; +import org.eclipse.jetty.websocket.common.frames.TextFrame; import org.eclipse.jetty.websocket.mux.MuxDecoder; import org.eclipse.jetty.websocket.mux.MuxEncoder; import org.eclipse.jetty.websocket.mux.MuxOp; @@ -97,7 +98,7 @@ public class MuxerAddServerTest clientRead.reset(); // Send simple echo request - clientWrite.frame(1,WebSocketFrame.text("Hello World")); + clientWrite.frame(1,new TextFrame().setPayload("Hello World")); // Test for echo response (is there a user echo websocket connected to the sub-channel?) clientRead.assertHasFrame(OpCode.TEXT,1L,1); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/AnnotatedMaxMessageSizeTest.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/AnnotatedMaxMessageSizeTest.java index ef44827b874..88b54394fa6 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/AnnotatedMaxMessageSizeTest.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/AnnotatedMaxMessageSizeTest.java @@ -27,6 +27,7 @@ import java.util.concurrent.TimeUnit; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; import org.eclipse.jetty.websocket.common.WebSocketFrame; +import org.eclipse.jetty.websocket.common.frames.TextFrame; import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient; import org.eclipse.jetty.websocket.server.examples.echo.BigEchoSocket; import org.eclipse.jetty.websocket.server.helper.IncomingFramesCapture; @@ -89,7 +90,7 @@ public class AnnotatedMaxMessageSizeTest // Generate text frame String msg = "this is an echo ... cho ... ho ... o"; - client.write(WebSocketFrame.text(msg)); + client.write(new TextFrame().setPayload(msg)); // Read frame (hopefully text frame) IncomingFramesCapture capture = client.readFrames(1,TimeUnit.MILLISECONDS,500); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ChromeTest.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ChromeTest.java index 68bc1b1a3a2..f99d21be89a 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ChromeTest.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ChromeTest.java @@ -23,6 +23,7 @@ import static org.hamcrest.Matchers.*; import java.util.concurrent.TimeUnit; import org.eclipse.jetty.websocket.common.WebSocketFrame; +import org.eclipse.jetty.websocket.common.frames.TextFrame; import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient; import org.eclipse.jetty.websocket.server.blockhead.HttpResponse; import org.eclipse.jetty.websocket.server.examples.MyEchoServlet; @@ -66,7 +67,7 @@ public class ChromeTest // Generate text frame String msg = "this is an echo ... cho ... ho ... o"; - client.write(WebSocketFrame.text(msg)); + client.write(new TextFrame().setPayload(msg)); // Read frame (hopefully text frame) IncomingFramesCapture capture = client.readFrames(1,TimeUnit.MILLISECONDS,500); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/FirefoxTest.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/FirefoxTest.java index fc20291e2cc..97ed456e9d3 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/FirefoxTest.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/FirefoxTest.java @@ -23,6 +23,7 @@ import static org.hamcrest.Matchers.*; import java.util.concurrent.TimeUnit; import org.eclipse.jetty.websocket.common.WebSocketFrame; +import org.eclipse.jetty.websocket.common.frames.TextFrame; import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient; import org.eclipse.jetty.websocket.server.examples.MyEchoServlet; import org.eclipse.jetty.websocket.server.helper.IncomingFramesCapture; @@ -62,7 +63,7 @@ public class FirefoxTest // Generate text frame String msg = "this is an echo ... cho ... ho ... o"; - client.write(WebSocketFrame.text(msg)); + client.write(new TextFrame().setPayload(msg)); // Read frame (hopefully text frame) IncomingFramesCapture capture = client.readFrames(1,TimeUnit.MILLISECONDS,500); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/FragmentExtensionTest.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/FragmentExtensionTest.java index b84ee24b9e3..75bf3d6ac32 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/FragmentExtensionTest.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/FragmentExtensionTest.java @@ -23,6 +23,7 @@ import static org.hamcrest.Matchers.*; import java.util.concurrent.TimeUnit; import org.eclipse.jetty.websocket.common.WebSocketFrame; +import org.eclipse.jetty.websocket.common.frames.TextFrame; import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient; import org.eclipse.jetty.websocket.server.blockhead.HttpResponse; import org.eclipse.jetty.websocket.server.helper.EchoServlet; @@ -86,7 +87,7 @@ public class FragmentExtensionTest Assert.assertThat("Response",resp.getExtensionsHeader(),containsString("fragment")); String msg = "Sent as a long message that should be split"; - client.write(WebSocketFrame.text(msg)); + client.write(new TextFrame().setPayload(msg)); String parts[] = split(msg,fragSize); IncomingFramesCapture capture = client.readFrames(parts.length,TimeUnit.MILLISECONDS,1000); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/FrameCompressionExtensionTest.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/FrameCompressionExtensionTest.java index 78a6be25a28..3ef1c86d670 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/FrameCompressionExtensionTest.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/FrameCompressionExtensionTest.java @@ -23,6 +23,7 @@ import static org.hamcrest.Matchers.*; import java.util.concurrent.TimeUnit; import org.eclipse.jetty.websocket.common.WebSocketFrame; +import org.eclipse.jetty.websocket.common.frames.TextFrame; import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient; import org.eclipse.jetty.websocket.server.blockhead.HttpResponse; import org.eclipse.jetty.websocket.server.helper.EchoServlet; @@ -72,7 +73,7 @@ public class FrameCompressionExtensionTest String msg = "Hello"; // Client sends first message - client.write(WebSocketFrame.text(msg)); + client.write(new TextFrame().setPayload(msg)); IncomingFramesCapture capture = client.readFrames(1,TimeUnit.MILLISECONDS,1000); WebSocketFrame frame = capture.getFrames().poll(); @@ -81,7 +82,7 @@ public class FrameCompressionExtensionTest // Client sends second message client.clearCaptured(); msg = "There"; - client.write(WebSocketFrame.text(msg)); + client.write(new TextFrame().setPayload(msg)); capture = client.readFrames(1,TimeUnit.SECONDS,1); frame = capture.getFrames().poll(); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/IdentityExtensionTest.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/IdentityExtensionTest.java index 47fa7caa52f..ebb7f48883b 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/IdentityExtensionTest.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/IdentityExtensionTest.java @@ -23,6 +23,7 @@ import static org.hamcrest.Matchers.*; import java.util.concurrent.TimeUnit; import org.eclipse.jetty.websocket.common.WebSocketFrame; +import org.eclipse.jetty.websocket.common.frames.TextFrame; import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient; import org.eclipse.jetty.websocket.server.blockhead.HttpResponse; import org.eclipse.jetty.websocket.server.helper.EchoServlet; @@ -70,7 +71,7 @@ public class IdentityExtensionTest Assert.assertThat("Response",resp.getExtensionsHeader(),containsString("identity")); - client.write(WebSocketFrame.text("Hello")); + client.write(new TextFrame().setPayload("Hello")); IncomingFramesCapture capture = client.readFrames(1,TimeUnit.MILLISECONDS,1000); WebSocketFrame frame = capture.getFrames().poll(); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/IdleTimeoutTest.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/IdleTimeoutTest.java index 9c0cf49ea45..a710acfd8e5 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/IdleTimeoutTest.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/IdleTimeoutTest.java @@ -21,6 +21,7 @@ package org.eclipse.jetty.websocket.server; import java.util.concurrent.TimeUnit; import org.eclipse.jetty.websocket.common.WebSocketFrame; +import org.eclipse.jetty.websocket.common.frames.TextFrame; import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient; import org.eclipse.jetty.websocket.server.helper.RFCSocket; import org.eclipse.jetty.websocket.servlet.WebSocketServlet; @@ -81,7 +82,7 @@ public class IdleTimeoutTest // Server could be in a half-closed state at this point. // Where the server read is closed (due to timeout), but the server write is still open. // The server could not read this frame, if it is in this half closed state - client.write(WebSocketFrame.text("Hello")); + client.write(new TextFrame().setPayload("Hello")); // Expect server to be disconnected at this point client.expectServerDisconnect(); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/LoadTest.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/LoadTest.java index cd688c78544..dcacc6c8a8c 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/LoadTest.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/LoadTest.java @@ -32,6 +32,7 @@ import org.eclipse.jetty.websocket.api.annotations.OnWebSocketConnect; import org.eclipse.jetty.websocket.api.annotations.OnWebSocketMessage; import org.eclipse.jetty.websocket.api.annotations.WebSocket; import org.eclipse.jetty.websocket.common.WebSocketFrame; +import org.eclipse.jetty.websocket.common.frames.TextFrame; import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient; import org.eclipse.jetty.websocket.servlet.WebSocketServlet; import org.eclipse.jetty.websocket.servlet.WebSocketServletFactory; @@ -98,7 +99,7 @@ public class LoadTest { for (int i = 0; i < iterations; i++) { - client.write(WebSocketFrame.text("msg-" + i)); + client.write(new TextFrame().setPayload("msg-" + i)); if ((i % 100) == 0) { LOG.info("Client Wrote {} msgs",i); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketServerSessionTest.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketServerSessionTest.java index 61940904dbb..b761dedef2a 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketServerSessionTest.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/WebSocketServerSessionTest.java @@ -27,6 +27,7 @@ import java.util.concurrent.TimeUnit; import org.eclipse.jetty.toolchain.test.AdvancedRunner; import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.common.WebSocketFrame; +import org.eclipse.jetty.websocket.common.frames.TextFrame; import org.eclipse.jetty.websocket.server.blockhead.BlockheadClient; import org.eclipse.jetty.websocket.server.helper.IncomingFramesCapture; import org.eclipse.jetty.websocket.server.helper.SessionServlet; @@ -68,7 +69,7 @@ public class WebSocketServerSessionTest client.sendStandardRequest(); client.expectUpgradeResponse(); - client.write(WebSocketFrame.text("harsh-disconnect")); + client.write(new TextFrame().setPayload("harsh-disconnect")); client.awaitDisconnect(1,TimeUnit.SECONDS); } @@ -90,10 +91,10 @@ public class WebSocketServerSessionTest client.expectUpgradeResponse(); // Ask the server socket for specific parameter map info - client.write(WebSocketFrame.text("getParameterMap|snack")); - client.write(WebSocketFrame.text("getParameterMap|amount")); - client.write(WebSocketFrame.text("getParameterMap|brand")); - client.write(WebSocketFrame.text("getParameterMap|cost")); // intentionall invalid + client.write(new TextFrame().setPayload("getParameterMap|snack")); + client.write(new TextFrame().setPayload("getParameterMap|amount")); + client.write(new TextFrame().setPayload("getParameterMap|brand")); + client.write(new TextFrame().setPayload("getParameterMap|cost")); // intentionall invalid // Read frame (hopefully text frame) IncomingFramesCapture capture = client.readFrames(4,TimeUnit.MILLISECONDS,500); 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 c8432a0af68..bb0ef085438 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 @@ -179,7 +179,7 @@ public class WebSocketServletRFCTest // Generate text frame String msg = "this is an echo ... cho ... ho ... o"; - client.write(WebSocketFrame.text(msg)); + client.write(new TextFrame().setPayload(msg)); // Read frame (hopefully text frame) IncomingFramesCapture capture = client.readFrames(1,TimeUnit.MILLISECONDS,500); @@ -212,7 +212,7 @@ public class WebSocketServletRFCTest try (StacklessLogging context = new StacklessLogging(EventDriver.class)) { // Generate text frame - client.write(WebSocketFrame.text("CRASH")); + client.write(new TextFrame().setPayload("CRASH")); // Read frame (hopefully close frame) IncomingFramesCapture capture = client.readFrames(1,TimeUnit.MILLISECONDS,500); @@ -258,7 +258,7 @@ public class WebSocketServletRFCTest // Generate text frame String msg = "this is an echo ... cho ... ho ... o"; - client.write(WebSocketFrame.text(msg)); + client.write(new TextFrame().setPayload(msg)); // Read frame (hopefully text frame) IncomingFramesCapture capture = client.readFrames(1,TimeUnit.MILLISECONDS,500); @@ -337,7 +337,7 @@ public class WebSocketServletRFCTest // Generate text frame String msg = "this is an echo ... cho ... ho ... o"; - client.write(WebSocketFrame.text(msg)); + client.write(new TextFrame().setPayload(msg)); // Read frame (hopefully text frame) IncomingFramesCapture capture = client.readFrames(1,TimeUnit.MILLISECONDS,500); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase1.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase1.java index 637c842907f..178a78f13a3 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase1.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase1.java @@ -26,6 +26,7 @@ import java.util.List; import org.eclipse.jetty.websocket.api.StatusCode; import org.eclipse.jetty.websocket.common.CloseInfo; import org.eclipse.jetty.websocket.common.WebSocketFrame; +import org.eclipse.jetty.websocket.common.frames.BinaryFrame; import org.eclipse.jetty.websocket.common.frames.TextFrame; import org.eclipse.jetty.websocket.server.ab.Fuzzer.SendMode; import org.junit.Test; @@ -39,11 +40,11 @@ public class TestABCase1 extends AbstractABCase public void testCase1_1_1() throws Exception { List send = new ArrayList<>(); - send.add(WebSocketFrame.text()); + send.add(new TextFrame()); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text()); + expect.add(new TextFrame()); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -72,11 +73,11 @@ public class TestABCase1 extends AbstractABCase ByteBuffer buf = ByteBuffer.wrap(payload); List send = new ArrayList<>(); - send.add(WebSocketFrame.text().setPayload(buf)); + send.add(new TextFrame().setPayload(buf)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text().setPayload(clone(buf))); + expect.add(new TextFrame().setPayload(clone(buf))); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -105,11 +106,11 @@ public class TestABCase1 extends AbstractABCase ByteBuffer buf = ByteBuffer.wrap(payload); List send = new ArrayList<>(); - send.add(WebSocketFrame.text().setPayload(buf)); + send.add(new TextFrame().setPayload(buf)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text().setPayload(clone(buf))); + expect.add(new TextFrame().setPayload(clone(buf))); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -138,11 +139,11 @@ public class TestABCase1 extends AbstractABCase ByteBuffer buf = ByteBuffer.wrap(payload); List send = new ArrayList<>(); - send.add(WebSocketFrame.text().setPayload(buf)); + send.add(new TextFrame().setPayload(buf)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text().setPayload(clone(buf))); + expect.add(new TextFrame().setPayload(clone(buf))); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -171,11 +172,11 @@ public class TestABCase1 extends AbstractABCase ByteBuffer buf = ByteBuffer.wrap(payload); List send = new ArrayList<>(); - send.add(WebSocketFrame.text().setPayload(buf)); + send.add(new TextFrame().setPayload(buf)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text().setPayload(clone(buf))); + expect.add(new TextFrame().setPayload(clone(buf))); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -204,11 +205,11 @@ public class TestABCase1 extends AbstractABCase ByteBuffer buf = ByteBuffer.wrap(payload); List send = new ArrayList<>(); - send.add(WebSocketFrame.text().setPayload(buf)); + send.add(new TextFrame().setPayload(buf)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text().setPayload(clone(buf))); + expect.add(new TextFrame().setPayload(clone(buf))); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -275,11 +276,11 @@ public class TestABCase1 extends AbstractABCase int segmentSize = 997; List send = new ArrayList<>(); - send.add(WebSocketFrame.text().setPayload(buf)); + send.add(new TextFrame().setPayload(buf)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text().setPayload(clone(buf))); + expect.add(new TextFrame().setPayload(clone(buf))); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -305,11 +306,11 @@ public class TestABCase1 extends AbstractABCase public void testCase1_2_1() throws Exception { List send = new ArrayList<>(); - send.add(WebSocketFrame.binary()); + send.add(new BinaryFrame()); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.binary()); + expect.add(new BinaryFrame()); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -338,11 +339,11 @@ public class TestABCase1 extends AbstractABCase ByteBuffer buf = ByteBuffer.wrap(payload); List send = new ArrayList<>(); - send.add(WebSocketFrame.binary().setPayload(buf)); + send.add(new BinaryFrame().setPayload(buf)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.binary().setPayload(clone(buf))); + expect.add(new BinaryFrame().setPayload(clone(buf))); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -371,11 +372,11 @@ public class TestABCase1 extends AbstractABCase ByteBuffer buf = ByteBuffer.wrap(payload); List send = new ArrayList<>(); - send.add(WebSocketFrame.binary().setPayload(buf)); + send.add(new BinaryFrame().setPayload(buf)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.binary().setPayload(clone(buf))); + expect.add(new BinaryFrame().setPayload(clone(buf))); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -404,11 +405,11 @@ public class TestABCase1 extends AbstractABCase ByteBuffer buf = ByteBuffer.wrap(payload); List send = new ArrayList<>(); - send.add(WebSocketFrame.binary().setPayload(buf)); + send.add(new BinaryFrame().setPayload(buf)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.binary().setPayload(clone(buf))); + expect.add(new BinaryFrame().setPayload(clone(buf))); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -437,11 +438,11 @@ public class TestABCase1 extends AbstractABCase ByteBuffer buf = ByteBuffer.wrap(payload); List send = new ArrayList<>(); - send.add(WebSocketFrame.binary().setPayload(buf)); + send.add(new BinaryFrame().setPayload(buf)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.binary().setPayload(clone(buf))); + expect.add(new BinaryFrame().setPayload(clone(buf))); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -470,11 +471,11 @@ public class TestABCase1 extends AbstractABCase ByteBuffer buf = ByteBuffer.wrap(payload); List send = new ArrayList<>(); - send.add(WebSocketFrame.binary().setPayload(buf)); + send.add(new BinaryFrame().setPayload(buf)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.binary().setPayload(clone(buf))); + expect.add(new BinaryFrame().setPayload(clone(buf))); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -503,11 +504,11 @@ public class TestABCase1 extends AbstractABCase ByteBuffer buf = ByteBuffer.wrap(payload); List send = new ArrayList<>(); - send.add(WebSocketFrame.binary().setPayload(buf)); + send.add(new BinaryFrame().setPayload(buf)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.binary().setPayload(clone(buf))); + expect.add(new BinaryFrame().setPayload(clone(buf))); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -541,11 +542,11 @@ public class TestABCase1 extends AbstractABCase int segmentSize = 997; List send = new ArrayList<>(); - send.add(WebSocketFrame.binary().setPayload(buf)); + send.add(new BinaryFrame().setPayload(buf)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.binary().setPayload(clone(buf))); + expect.add(new BinaryFrame().setPayload(clone(buf))); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase2.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase2.java index 1991e14f266..94922db5cff 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase2.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase2.java @@ -45,9 +45,9 @@ public class TestABCase2 extends AbstractABCase @Test public void testCase2_1() throws Exception { - WebSocketFrame send = WebSocketFrame.ping(); + WebSocketFrame send = new PingFrame(); - WebSocketFrame expect = WebSocketFrame.pong(); + WebSocketFrame expect = new PongFrame(); Fuzzer fuzzer = new Fuzzer(this); try @@ -309,7 +309,7 @@ public class TestABCase2 extends AbstractABCase public void testCase2_7() throws Exception { List send = new ArrayList<>(); - send.add(WebSocketFrame.pong()); // unsolicited pong + send.add(new PongFrame()); // unsolicited pong 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/TestABCase3.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase3.java index 6c224338261..6f14f48deea 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 @@ -26,7 +26,9 @@ import org.eclipse.jetty.toolchain.test.AdvancedRunner; import org.eclipse.jetty.websocket.api.StatusCode; import org.eclipse.jetty.websocket.common.CloseInfo; import org.eclipse.jetty.websocket.common.WebSocketFrame; +import org.eclipse.jetty.websocket.common.frames.BinaryFrame; import org.eclipse.jetty.websocket.common.frames.PingFrame; +import org.eclipse.jetty.websocket.common.frames.TextFrame; import org.junit.Test; import org.junit.runner.RunWith; @@ -42,7 +44,7 @@ public class TestABCase3 extends AbstractABCase @Test public void testCase3_1() throws Exception { - WebSocketFrame send = WebSocketFrame.text("small").setRsv1(true); // intentionally bad + WebSocketFrame send = new TextFrame().setPayload("small").setRsv1(true); // intentionally bad WebSocketFrame expect = new CloseInfo(StatusCode.PROTOCOL).asFrame(); @@ -67,12 +69,12 @@ public class TestABCase3 extends AbstractABCase public void testCase3_2() throws Exception { List send = new ArrayList<>(); - send.add(WebSocketFrame.text("small")); - send.add(WebSocketFrame.text("small").setRsv2(true)); // intentionally bad + send.add(new TextFrame().setPayload("small")); + send.add(new TextFrame().setPayload("small").setRsv2(true)); // intentionally bad send.add(new PingFrame("ping")); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text("small")); // echo on good frame + expect.add(new TextFrame().setPayload("small")); // echo on good frame expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -96,12 +98,12 @@ public class TestABCase3 extends AbstractABCase public void testCase3_3() throws Exception { List send = new ArrayList<>(); - send.add(WebSocketFrame.text("small")); - send.add(WebSocketFrame.text("small").setRsv1(true).setRsv2(true)); // intentionally bad + send.add(new TextFrame().setPayload("small")); + send.add(new TextFrame().setPayload("small").setRsv1(true).setRsv2(true)); // intentionally bad send.add(new PingFrame("ping")); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text("small")); // echo on good frame + expect.add(new TextFrame().setPayload("small")); // echo on good frame expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -125,12 +127,12 @@ public class TestABCase3 extends AbstractABCase public void testCase3_4() throws Exception { List send = new ArrayList<>(); - send.add(WebSocketFrame.text("small")); - send.add(WebSocketFrame.text("small").setRsv3(true)); // intentionally bad + send.add(new TextFrame().setPayload("small")); + send.add(new TextFrame().setPayload("small").setRsv3(true)); // intentionally bad send.add(new PingFrame("ping")); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text("small")); // echo on good frame + expect.add(new TextFrame().setPayload("small")); // echo on good frame expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -158,7 +160,7 @@ public class TestABCase3 extends AbstractABCase Arrays.fill(payload,(byte)0xFF); List send = new ArrayList<>(); - send.add(WebSocketFrame.binary(payload).setRsv3(true).setRsv1(true)); // intentionally bad + send.add(new BinaryFrame(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/TestABCase4.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase4.java index 76bd45c54a2..ba2a85f5491 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase4.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase4.java @@ -27,6 +27,8 @@ import org.eclipse.jetty.util.StringUtil; import org.eclipse.jetty.websocket.api.StatusCode; import org.eclipse.jetty.websocket.common.CloseInfo; import org.eclipse.jetty.websocket.common.WebSocketFrame; +import org.eclipse.jetty.websocket.common.frames.PingFrame; +import org.eclipse.jetty.websocket.common.frames.TextFrame; import org.junit.Test; import org.junit.runner.RunWith; @@ -98,12 +100,12 @@ public class TestABCase4 extends AbstractABCase public void testCase4_1_3() throws Exception { List send = new ArrayList<>(); - send.add(WebSocketFrame.text("hello")); + send.add(new TextFrame().setPayload("hello")); send.add(new BadFrame((byte)5)); // intentionally bad - send.add(WebSocketFrame.ping()); + send.add(new PingFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text("hello")); // echo + expect.add(new TextFrame().setPayload("hello")); // echo expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -129,12 +131,12 @@ public class TestABCase4 extends AbstractABCase ByteBuffer buf = ByteBuffer.wrap(StringUtil.getUtf8Bytes("bad")); List send = new ArrayList<>(); - send.add(WebSocketFrame.text("hello")); + send.add(new TextFrame().setPayload("hello")); send.add(new BadFrame((byte)6).setPayload(buf)); // intentionally bad - send.add(WebSocketFrame.ping()); + send.add(new PingFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text("hello")); // echo + expect.add(new TextFrame().setPayload("hello")); // echo expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -160,12 +162,12 @@ public class TestABCase4 extends AbstractABCase ByteBuffer buf = ByteBuffer.wrap(StringUtil.getUtf8Bytes("bad")); List send = new ArrayList<>(); - send.add(WebSocketFrame.text("hello")); + send.add(new TextFrame().setPayload("hello")); send.add(new BadFrame((byte)7).setPayload(buf)); // intentionally bad - send.add(WebSocketFrame.ping()); + send.add(new PingFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text("hello")); // echo + expect.add(new TextFrame().setPayload("hello")); // echo expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -243,12 +245,12 @@ public class TestABCase4 extends AbstractABCase public void testCase4_2_3() throws Exception { List send = new ArrayList<>(); - send.add(WebSocketFrame.text("hello")); + send.add(new TextFrame().setPayload("hello")); send.add(new BadFrame((byte)13)); // intentionally bad - send.add(WebSocketFrame.ping()); + send.add(new PingFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text("hello")); // echo + expect.add(new TextFrame().setPayload("hello")); // echo expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -274,12 +276,12 @@ public class TestABCase4 extends AbstractABCase ByteBuffer buf = ByteBuffer.wrap(StringUtil.getUtf8Bytes("bad")); List send = new ArrayList<>(); - send.add(WebSocketFrame.text("hello")); + send.add(new TextFrame().setPayload("hello")); send.add(new BadFrame((byte)14).setPayload(buf)); // intentionally bad - send.add(WebSocketFrame.ping()); + send.add(new PingFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text("hello")); // echo + expect.add(new TextFrame().setPayload("hello")); // echo expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -305,12 +307,12 @@ public class TestABCase4 extends AbstractABCase ByteBuffer buf = ByteBuffer.wrap(StringUtil.getUtf8Bytes("bad")); List send = new ArrayList<>(); - send.add(WebSocketFrame.text("hello")); + send.add(new TextFrame().setPayload("hello")); send.add(new BadFrame((byte)15).setPayload(buf)); // intentionally bad - send.add(WebSocketFrame.ping()); + send.add(new PingFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text("hello")); // echo + expect.add(new TextFrame().setPayload("hello")); // echo expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); 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 b94fc6b4487..c1777e3a861 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 @@ -226,7 +226,7 @@ public class TestABCase5 extends AbstractABCase send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text("fragment1fragment2")); + expect.add(new TextFrame().setPayload("fragment1fragment2")); expect.add(new CloseInfo(StatusCode.PROTOCOL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -361,7 +361,7 @@ public class TestABCase5 extends AbstractABCase List expect2 = new ArrayList<>(); expect2.add(new PongFrame("pong-2")); - expect2.add(WebSocketFrame.text("f1,f2,f3,f4,f5")); + expect2.add(new TextFrame().setPayload("f1,f2,f3,f4,f5")); expect2.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -438,7 +438,7 @@ public class TestABCase5 extends AbstractABCase List expect2 = new ArrayList<>(); expect2.add(new PongFrame("pong-2")); - expect2.add(WebSocketFrame.text("f1,f2,f3,f4,f5")); + expect2.add(new TextFrame().setPayload("f1,f2,f3,f4,f5")); expect2.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -484,7 +484,7 @@ public class TestABCase5 extends AbstractABCase List expect2 = new ArrayList<>(); expect2.add(new PongFrame("pong-2")); - expect2.add(WebSocketFrame.text("f1,f2,f3,f4,f5")); + expect2.add(new TextFrame().setPayload("f1,f2,f3,f4,f5")); expect2.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -520,7 +520,7 @@ public class TestABCase5 extends AbstractABCase send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text("hello, world")); + expect.add(new TextFrame().setPayload("hello, world")); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -549,7 +549,7 @@ public class TestABCase5 extends AbstractABCase send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text("hello, world")); + expect.add(new TextFrame().setPayload("hello, world")); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -578,7 +578,7 @@ public class TestABCase5 extends AbstractABCase send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text("hello, world")); + expect.add(new TextFrame().setPayload("hello, world")); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -610,7 +610,7 @@ public class TestABCase5 extends AbstractABCase List expect = new ArrayList<>(); expect.add(new PongFrame("ping")); - expect.add(WebSocketFrame.text("hello, world")); + expect.add(new TextFrame().setPayload("hello, world")); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -641,7 +641,7 @@ public class TestABCase5 extends AbstractABCase List expect = new ArrayList<>(); expect.add(new PongFrame("ping")); - expect.add(WebSocketFrame.text("hello, world")); + expect.add(new TextFrame().setPayload("hello, world")); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -672,7 +672,7 @@ public class TestABCase5 extends AbstractABCase List expect = new ArrayList<>(); expect.add(new PongFrame("ping")); - expect.add(WebSocketFrame.text("hello, world")); + expect.add(new TextFrame().setPayload("hello, world")); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase6.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase6.java index ae9d6a1aee4..1b1e266c254 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase6.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase6.java @@ -82,11 +82,11 @@ public class TestABCase6 extends AbstractABCase public void testCase6_1_1() throws Exception { List send = new ArrayList<>(); - send.add(WebSocketFrame.text()); + send.add(new TextFrame()); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text()); + expect.add(new TextFrame()); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -116,7 +116,7 @@ public class TestABCase6 extends AbstractABCase send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text()); + expect.add(new TextFrame()); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -146,7 +146,7 @@ public class TestABCase6 extends AbstractABCase send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text("middle")); + expect.add(new TextFrame().setPayload("middle")); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase7.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase7.java index 1e927783a0e..584a33b53f2 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase7.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/ab/TestABCase7.java @@ -55,11 +55,11 @@ public class TestABCase7 extends AbstractABCase public void testCase7_1_1() throws Exception { List send = new ArrayList<>(); - send.add(WebSocketFrame.text("Hello World")); + send.add(new TextFrame().setPayload("Hello World")); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text("Hello World")); + expect.add(new TextFrame().setPayload("Hello World")); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -140,7 +140,7 @@ public class TestABCase7 extends AbstractABCase { List send = new ArrayList<>(); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); - send.add(WebSocketFrame.text("out of band text")); + send.add(new TextFrame().setPayload("out of band text")); List expect = new ArrayList<>(); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); 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 5171414e1aa..0641e8b354a 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 @@ -149,11 +149,11 @@ public class TestABCase9 extends AbstractABCase String msg = StringUtil.toUTF8String(utf,0,utf.length); List send = new ArrayList<>(); - send.add(WebSocketFrame.text(msg)); + send.add(new TextFrame().setPayload(msg)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text(msg)); + expect.add(new TextFrame().setPayload(msg)); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -185,7 +185,7 @@ public class TestABCase9 extends AbstractABCase send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text().setPayload(clone(buf))); + expect.add(new TextFrame().setPayload(clone(buf))); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -214,11 +214,11 @@ public class TestABCase9 extends AbstractABCase ByteBuffer buf = ByteBuffer.wrap(utf); List send = new ArrayList<>(); - send.add(WebSocketFrame.text().setPayload(buf)); + send.add(new TextFrame().setPayload(buf)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text().setPayload(clone(buf))); + expect.add(new TextFrame().setPayload(clone(buf))); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -247,11 +247,11 @@ public class TestABCase9 extends AbstractABCase ByteBuffer buf = ByteBuffer.wrap(utf); List send = new ArrayList<>(); - send.add(WebSocketFrame.text().setPayload(buf)); + send.add(new TextFrame().setPayload(buf)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text().setPayload(clone(buf))); + expect.add(new TextFrame().setPayload(clone(buf))); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -280,11 +280,11 @@ public class TestABCase9 extends AbstractABCase ByteBuffer buf = ByteBuffer.wrap(utf); List send = new ArrayList<>(); - send.add(WebSocketFrame.text().setPayload(buf)); + send.add(new TextFrame().setPayload(buf)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text().setPayload(clone(buf))); + expect.add(new TextFrame().setPayload(clone(buf))); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -313,11 +313,11 @@ public class TestABCase9 extends AbstractABCase ByteBuffer buf = ByteBuffer.wrap(utf); List send = new ArrayList<>(); - send.add(WebSocketFrame.text().setPayload(buf)); + send.add(new TextFrame().setPayload(buf)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.text().setPayload(clone(buf))); + expect.add(new TextFrame().setPayload(clone(buf))); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -344,11 +344,11 @@ public class TestABCase9 extends AbstractABCase Arrays.fill(data,(byte)0x21); List send = new ArrayList<>(); - send.add(WebSocketFrame.binary(data)); + send.add(new BinaryFrame(data)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.binary(copyOf(data))); + expect.add(new BinaryFrame().setPayload(copyOf(data))); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -376,11 +376,11 @@ public class TestABCase9 extends AbstractABCase ByteBuffer buf = ByteBuffer.wrap(data); List send = new ArrayList<>(); - send.add(WebSocketFrame.binary().setPayload(buf)); + send.add(new BinaryFrame().setPayload(buf)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.binary().setPayload(clone(buf))); + expect.add(new BinaryFrame().setPayload(clone(buf))); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -409,11 +409,11 @@ public class TestABCase9 extends AbstractABCase ByteBuffer buf = ByteBuffer.wrap(data); List send = new ArrayList<>(); - send.add(WebSocketFrame.binary().setPayload(buf)); + send.add(new BinaryFrame().setPayload(buf)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.binary().setPayload(clone(buf))); + expect.add(new BinaryFrame().setPayload(clone(buf))); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -442,11 +442,11 @@ public class TestABCase9 extends AbstractABCase ByteBuffer buf = ByteBuffer.wrap(data); List send = new ArrayList<>(); - send.add(WebSocketFrame.binary().setPayload(buf)); + send.add(new BinaryFrame().setPayload(buf)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.binary().setPayload(clone(buf))); + expect.add(new BinaryFrame().setPayload(clone(buf))); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -475,11 +475,11 @@ public class TestABCase9 extends AbstractABCase ByteBuffer buf = ByteBuffer.wrap(data); List send = new ArrayList<>(); - send.add(WebSocketFrame.binary().setPayload(buf)); + send.add(new BinaryFrame().setPayload(buf)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.binary().setPayload(clone(buf))); + expect.add(new BinaryFrame().setPayload(clone(buf))); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); @@ -508,11 +508,11 @@ public class TestABCase9 extends AbstractABCase ByteBuffer buf = ByteBuffer.wrap(data); List send = new ArrayList<>(); - send.add(WebSocketFrame.binary().setPayload(buf)); + send.add(new BinaryFrame().setPayload(buf)); send.add(new CloseInfo(StatusCode.NORMAL).asFrame()); List expect = new ArrayList<>(); - expect.add(WebSocketFrame.binary().setPayload(clone(buf))); + expect.add(new BinaryFrame().setPayload(clone(buf))); expect.add(new CloseInfo(StatusCode.NORMAL).asFrame()); Fuzzer fuzzer = new Fuzzer(this); diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/blockhead/BlockheadClient.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/blockhead/BlockheadClient.java index 35e6d5b98af..7fe948890c1 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/blockhead/BlockheadClient.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/blockhead/BlockheadClient.java @@ -428,7 +428,7 @@ public class BlockheadClient implements IncomingFrames, OutgoingFrames, Connecti LOG.info("Client parsed {} frames",count); } - if (frame.getType() == Frame.Type.CLOSE) + if (frame.getOpCode() == OpCode.CLOSE) { CloseInfo close = new CloseInfo(frame); ioState.onCloseRemote(close); @@ -495,7 +495,7 @@ public class BlockheadClient implements IncomingFrames, OutgoingFrames, Connecti bufferPool.release(headerBuf); } - if (frame.getType().getOpCode() == OpCode.CLOSE) + if (frame.getOpCode() == OpCode.CLOSE) { disconnect(); } diff --git a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/examples/echo/EchoFragmentSocket.java b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/examples/echo/EchoFragmentSocket.java index 1a5bdae2eec..e158b3a7603 100644 --- a/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/examples/echo/EchoFragmentSocket.java +++ b/jetty-websocket/websocket-server/src/test/java/org/eclipse/jetty/websocket/server/examples/echo/EchoFragmentSocket.java @@ -27,6 +27,7 @@ import org.eclipse.jetty.websocket.api.Session; import org.eclipse.jetty.websocket.api.annotations.OnWebSocketFrame; import org.eclipse.jetty.websocket.api.annotations.WebSocket; import org.eclipse.jetty.websocket.api.extensions.Frame; +import org.eclipse.jetty.websocket.common.OpCode; /** * Echo back the incoming text or binary as 2 frames of (roughly) equal size. @@ -37,8 +38,9 @@ public class EchoFragmentSocket @OnWebSocketFrame public void onFrame(Session session, Frame frame) { - if (frame.getType().isData()) + if (!frame.getType().isData()) { + // Don't process non-data frames return; }