diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/api/OpCode.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/api/OpCode.java index 717854c502e..42fe39da0ee 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/api/OpCode.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/api/OpCode.java @@ -5,7 +5,6 @@ import java.util.Map; import org.eclipse.jetty.websocket.frames.BinaryFrame; import org.eclipse.jetty.websocket.frames.CloseFrame; -import org.eclipse.jetty.websocket.frames.ContinuationFrame; import org.eclipse.jetty.websocket.frames.PingFrame; import org.eclipse.jetty.websocket.frames.PongFrame; import org.eclipse.jetty.websocket.frames.TextFrame; diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/frames/BaseFrame.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/frames/BaseFrame.java index 2576d2e3f15..d658d0af26a 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/frames/BaseFrame.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/frames/BaseFrame.java @@ -37,8 +37,6 @@ public class BaseFrame private int payloadLength; private byte mask[]; - // internal tracking - private int continuationIndex = 0; /** * Default constructor @@ -55,19 +53,7 @@ public class BaseFrame this.opcode = opcode; } - /** - * The number of fragments this frame consists of. - *

- * For every {@link OpCode#CONTINUATION} opcode encountered, this increments by one. - *

- * Note: Not part of the Base Framing Protocol / header information. - * - * @return the number of continuation fragments encountered. - */ - public int getContinuationIndex() - { - return continuationIndex; - } + public byte[] getMask() { @@ -128,14 +114,9 @@ public class BaseFrame masked = false; payloadLength = -1; mask = null; - continuationIndex = 0; - } - - public void setContinuationIndex(int continuationIndex) - { - this.continuationIndex = continuationIndex; } + public void setFin(boolean fin) { this.fin = fin; diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/frames/BinaryFrame.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/frames/BinaryFrame.java index d5779df97ba..47eb1b3ce63 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/frames/BinaryFrame.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/frames/BinaryFrame.java @@ -10,7 +10,6 @@ import org.eclipse.jetty.websocket.api.OpCode; */ public class BinaryFrame extends DataFrame { - private ByteBuffer data; // TODO: make this a standard byte buffer? /** * Default unspecified data @@ -18,17 +17,7 @@ public class BinaryFrame extends DataFrame public BinaryFrame() { super(OpCode.BINARY); - } - - /** - * Get the data - * - * @return the raw bytebuffer data (can be null) - */ - public ByteBuffer getData() - { - return data; - } + } @Override public OpCode getOpCode() @@ -36,29 +25,14 @@ public class BinaryFrame extends DataFrame return OpCode.BINARY; } - /** - * Set the data and payload length. - * - * @param buf - * the bytebuffer to set - */ - public void setData(byte buf[]) + + + + @Override + public void setPayload(ByteBuffer buffer) { - int len = buf.length; - this.data = ByteBuffer.allocate(len); - this.setPayloadLength(len); - } - - /** - * Set the data and payload length. - * - * @param buf - * the byte array to set - */ - public void setData(ByteBuffer buffer) - { - this.data = buffer; - this.setPayloadLength(buffer.capacity()); + // TODO Auto-generated method stub + super.setPayload(buffer); } @Override @@ -67,7 +41,7 @@ public class BinaryFrame extends DataFrame StringBuilder b = new StringBuilder(); b.append("BinaryFrame["); b.append("len=").append(getPayloadLength()); - b.append(",data=").append(BufferUtil.toDetailString(getData())); + b.append(",data=").append(BufferUtil.toDetailString(getPayload())); b.append("]"); return b.toString(); } diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/frames/ContinuationFrame.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/frames/ContinuationFrame.java deleted file mode 100644 index 8aafc912dd7..00000000000 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/frames/ContinuationFrame.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.eclipse.jetty.websocket.frames; - -import org.eclipse.jetty.websocket.api.OpCode; - -public class ContinuationFrame extends BaseFrame -{ - public ContinuationFrame() - { - super(OpCode.CONTINUATION); - } -} diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/frames/DataFrame.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/frames/DataFrame.java index 4deffc8af42..11d26ffa29a 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/frames/DataFrame.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/frames/DataFrame.java @@ -1,16 +1,97 @@ package org.eclipse.jetty.websocket.frames; +import java.nio.ByteBuffer; + import org.eclipse.jetty.websocket.api.OpCode; public abstract class DataFrame extends BaseFrame { + // internal tracking + private int continuationIndex = 0; + private boolean continuation = false; + private ByteBuffer payload; + public DataFrame() { super(); } - + public DataFrame(OpCode opcode) { super(opcode); } + + /** + * Get the data + * + * @return the raw bytebuffer data (can be null) + */ + public ByteBuffer getPayload() + { + return payload; + } + + /** + * Set the data and payload length. + * + * @param buf + * the bytebuffer to set + */ + protected void setPayload(byte buf[]) + { + int len = buf.length; + this.payload = ByteBuffer.allocate(len); + this.setPayloadLength(len); + } + + + /** + * Set the data and payload length. + * + * @param buf + * the byte array to set + */ + protected void setPayload(ByteBuffer buffer) + { + this.payload = buffer; + this.setPayloadLength(buffer.capacity()); + } + + + /** + * The number of fragments this frame consists of. + *

+ * For every {@link OpCode#CONTINUATION} opcode encountered, this increments by one. + *

+ * Note: Not part of the Base Framing Protocol / header information. + * + * @return the number of continuation fragments encountered. + */ + public int getContinuationIndex() + { + return continuationIndex; + } + + public void setContinuationIndex(int continuationIndex) + { + this.continuationIndex = continuationIndex; + } + + @Override + public void reset() + { + super.reset(); + continuationIndex = 0; + } + + public boolean isContinuation() + { + return continuation; + } + + public void setContinuation(boolean continuation) + { + this.continuation = continuation; + } + } diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/frames/TextFrame.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/frames/TextFrame.java index fcf708b8aec..56f8bd1040d 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/frames/TextFrame.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/frames/TextFrame.java @@ -1,5 +1,7 @@ package org.eclipse.jetty.websocket.frames; +import java.nio.ByteBuffer; + import org.eclipse.jetty.websocket.api.OpCode; /** @@ -7,8 +9,6 @@ import org.eclipse.jetty.websocket.api.OpCode; */ public class TextFrame extends DataFrame { - private StringBuilder data = new StringBuilder(); - /** * Default constructor (unspecified data) */ @@ -26,17 +26,7 @@ public class TextFrame extends DataFrame public TextFrame(String message) { this(); - setData(message); - } - - /** - * Get the data - * - * @return the raw StringBuilder data (can be null) - */ - public StringBuilder getData() - { - return data; + setPayload(message); } /** @@ -45,24 +35,18 @@ public class TextFrame extends DataFrame * @param str * the String to set */ - public void setData(String str) + public void setPayload(String str) { int len = str.length(); - this.data = new StringBuilder(str); + ByteBuffer b = ByteBuffer.allocate(len); + b.put(str.getBytes()); // TODO validate utf-8 + this.setPayload(b); this.setPayloadLength(len); } - - /** - * Set the data and payload length. - * - * @param str - * the StringBuilder to set - */ - public void setData(StringBuilder str) + + public String getPayloadAsText() { - int len = str.length(); - this.data = str; - this.setPayloadLength(len); + return new String(getPayload().array()); } @Override @@ -71,7 +55,7 @@ public class TextFrame extends DataFrame StringBuilder b = new StringBuilder(); b.append("TextFrame["); b.append("len=").append(getPayloadLength()); - b.append(",data=").append(data); + b.append(",data=").append(getPayload()); // TODO pp b.append("]"); return b.toString(); } diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/generator/BinaryFrameGenerator.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/generator/BinaryFrameGenerator.java index a8d464d0fd9..bd95025811b 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/generator/BinaryFrameGenerator.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/generator/BinaryFrameGenerator.java @@ -16,6 +16,6 @@ public class BinaryFrameGenerator extends FrameGenerator @Override public ByteBuffer payload(BinaryFrame binary) { - return binary.getData(); + return binary.getPayload(); } } diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/generator/FrameGenerator.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/generator/FrameGenerator.java index f8a567fdcb8..8a36e39af11 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/generator/FrameGenerator.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/generator/FrameGenerator.java @@ -3,9 +3,11 @@ package org.eclipse.jetty.websocket.generator; import java.nio.ByteBuffer; import org.eclipse.jetty.io.ByteBufferPool; +import org.eclipse.jetty.websocket.api.OpCode; import org.eclipse.jetty.websocket.api.PolicyViolationException; import org.eclipse.jetty.websocket.api.WebSocketPolicy; import org.eclipse.jetty.websocket.frames.BaseFrame; +import org.eclipse.jetty.websocket.frames.DataFrame; public abstract class FrameGenerator { @@ -48,7 +50,24 @@ public abstract class FrameGenerator // TODO: extensions can negotiate this (somehow) throw new PolicyViolationException("RSV3 not allowed to be set"); } - b |= (frame.getOpCode().getCode() & 0x0F); + + // TODO ewe + if ( frame instanceof DataFrame) + { + if ( ((DataFrame)frame).isContinuation() ) + { + b |= OpCode.CONTINUATION.getCode() & 0x0F; + } + else + { + b |= (frame.getOpCode().getCode() & 0x0F); + } + } + else + { + b |= (frame.getOpCode().getCode() & 0x0F); + } + framing.put(b); // is masked diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/generator/TextFrameGenerator.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/generator/TextFrameGenerator.java index d1fbf341c4e..77f007e0544 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/generator/TextFrameGenerator.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/generator/TextFrameGenerator.java @@ -17,19 +17,7 @@ public class TextFrameGenerator extends FrameGenerator @Override public ByteBuffer payload(TextFrame text) - { - try - { - String data = text.getData().toString(); - ByteBuffer payload = ByteBuffer.allocate(data.length()); - payload.put(data.getBytes("UTF-8")); - return payload; - } - catch (UnsupportedEncodingException e) - { - // TODO improve ex handling - throw new WebSocketException("text frame was not correctly encoded"); - } - + { + return text.getPayload(); } } diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/parser/BinaryPayloadParser.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/parser/BinaryPayloadParser.java index cfbb61803db..a2a14f617d1 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/parser/BinaryPayloadParser.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/parser/BinaryPayloadParser.java @@ -49,7 +49,7 @@ public class BinaryPayloadParser extends FrameParser if (payload.position() >= payloadLength) { - frame.setData(payload); + frame.setPayload(payload); return true; } } diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/parser/Parser.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/parser/Parser.java index 566e73b7bec..65a68207111 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/parser/Parser.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/parser/Parser.java @@ -12,6 +12,7 @@ import org.eclipse.jetty.websocket.api.OpCode; import org.eclipse.jetty.websocket.api.WebSocketException; import org.eclipse.jetty.websocket.api.WebSocketPolicy; import org.eclipse.jetty.websocket.frames.BaseFrame; +import org.eclipse.jetty.websocket.frames.DataFrame; /** * Parsing of a frames in WebSocket land. @@ -139,7 +140,11 @@ public class Parser } parser.reset(); parser.initFrame(fin,rsv1,rsv2,rsv3,opcode); - parser.getFrame().setContinuationIndex(currentContinuationIndex); + + if ( parser.getFrame() instanceof DataFrame ) + { + ((DataFrame)parser.getFrame()).setContinuationIndex(currentContinuationIndex); + } state = State.BASE_FRAMING; break; diff --git a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/parser/TextPayloadParser.java b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/parser/TextPayloadParser.java index 0b40ebb2377..90fb8737a9a 100644 --- a/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/parser/TextPayloadParser.java +++ b/jetty-websocket/websocket-core/src/main/java/org/eclipse/jetty/websocket/parser/TextPayloadParser.java @@ -49,7 +49,7 @@ public class TextPayloadParser extends FrameParser if (payload.position() >= payloadLength) { payload.flip(); - frame.setData(BufferUtil.toString(payload,StringUtil.__UTF8_CHARSET)); + frame.setPayload(BufferUtil.toString(payload,StringUtil.__UTF8_CHARSET)); return true; } } diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/GeneratorParserRoundtripTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/GeneratorParserRoundtripTest.java index bca799dbe1e..221dfc88704 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/GeneratorParserRoundtripTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/GeneratorParserRoundtripTest.java @@ -47,7 +47,7 @@ public class GeneratorParserRoundtripTest capture.assertHasFrame(TextFrame.class,1); TextFrame txt = (TextFrame)capture.getFrames().get(0); - Assert.assertThat("Text parsed",txt.getData().toString(),is(message)); + Assert.assertThat("Text parsed",txt.getPayloadAsText(),is(message)); } @Test @@ -82,6 +82,6 @@ public class GeneratorParserRoundtripTest TextFrame txt = (TextFrame)capture.getFrames().get(0); Assert.assertTrue("Text.isMasked",txt.isMasked()); - Assert.assertThat("Text parsed",txt.getData().toString(),is(message)); + Assert.assertThat("Text parsed",txt.getPayloadAsText(),is(message)); } } diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/generator/RFC6455ExamplesGeneratorTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/generator/RFC6455ExamplesGeneratorTest.java index 3bcb03e7043..e49875f195c 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/generator/RFC6455ExamplesGeneratorTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/generator/RFC6455ExamplesGeneratorTest.java @@ -40,8 +40,9 @@ public class RFC6455ExamplesGeneratorTest t1.setFin(false); t2.setFin(true); - t1.setData("Hel"); - t2.setData("lo"); + t2.setContinuation(true); + t1.setPayload("Hel"); + t2.setPayload("lo"); WebSocketPolicy policy = new WebSocketPolicy(WebSocketBehavior.SERVER); @@ -57,12 +58,7 @@ public class RFC6455ExamplesGeneratorTest g1.flip(); b2.flip(); g2.flip(); - - Assert.assertEquals(b1.get(),g1.get()); - - System.out.println(Integer.toHexString(b2.get())); - System.out.println(Integer.toHexString(g2.get())); - + ByteBufferAssert.assertEquals("t1 buffers are not equal", b1, g1); ByteBufferAssert.assertEquals("t2 buffers are not equal", b2, g2); @@ -149,7 +145,7 @@ public class RFC6455ExamplesGeneratorTest { (byte)0x81, (byte)0x85, 0x37, (byte)0xfa, 0x21, 0x3d, 0x7f, (byte)0x9f, 0x4d, 0x51, 0x58 }); TextFrame t1 = new TextFrame(); - t1.setData("Hello"); + t1.setPayload("Hello"); t1.setFin(true); t1.setMasked(true); t1.setMask(new byte[]{(byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff}); diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/parser/RFC6455ExamplesParserTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/parser/RFC6455ExamplesParserTest.java index f8fac823053..05fb9825733 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/parser/RFC6455ExamplesParserTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/parser/RFC6455ExamplesParserTest.java @@ -51,9 +51,9 @@ public class RFC6455ExamplesParserTest capture.assertHasFrame(TextFrame.class,2); TextFrame txt = (TextFrame)capture.getFrames().get(0); - Assert.assertThat("TextFrame[0].data",txt.getData().toString(),is("Hel")); + Assert.assertThat("TextFrame[0].data",txt.getPayloadAsText(),is("Hel")); txt = (TextFrame)capture.getFrames().get(1); - Assert.assertThat("TextFrame[1].data",txt.getData().toString(),is("lo")); + Assert.assertThat("TextFrame[1].data",txt.getPayloadAsText(),is("lo")); } @Test @@ -99,7 +99,7 @@ public class RFC6455ExamplesParserTest capture.assertHasFrame(TextFrame.class,1); TextFrame txt = (TextFrame)capture.getFrames().get(0); - Assert.assertThat("TextFrame.data",txt.getData().toString(),is("Hello")); + Assert.assertThat("TextFrame.data",txt.getPayloadAsText(),is("Hello")); } @Test @@ -129,12 +129,12 @@ public class RFC6455ExamplesParserTest capture.assertHasFrame(BinaryFrame.class,1); BinaryFrame bin = (BinaryFrame)capture.getFrames().get(0); - bin.getData().flip(); + bin.getPayload().flip(); Assert.assertThat("BinaryFrame.payloadLength",bin.getPayloadLength(),is(dataSize)); - ByteBufferAssert.assertSize("BinaryFrame.payload",dataSize,bin.getData()); + ByteBufferAssert.assertSize("BinaryFrame.payload",dataSize,bin.getPayload()); - ByteBuffer data = bin.getData(); + ByteBuffer data = bin.getPayload(); for (int i = dataSize; i > 0; i--) { Assert.assertThat("BinaryFrame.data[" + i + "]",data.get(),is((byte)0x44)); @@ -168,12 +168,12 @@ public class RFC6455ExamplesParserTest capture.assertHasFrame(BinaryFrame.class,1); BinaryFrame bin = (BinaryFrame)capture.getFrames().get(0); - bin.getData().flip(); + bin.getPayload().flip(); Assert.assertThat("BinaryFrame.payloadLength",bin.getPayloadLength(),is(dataSize)); - ByteBufferAssert.assertSize("BinaryFrame.payload",dataSize,bin.getData()); + ByteBufferAssert.assertSize("BinaryFrame.payload",dataSize,bin.getPayload()); - ByteBuffer data = bin.getData(); + ByteBuffer data = bin.getPayload(); for (int i = dataSize; i > 0; i--) { Assert.assertThat("BinaryFrame.data[" + i + "]",data.get(),is((byte)0x77)); @@ -223,6 +223,6 @@ public class RFC6455ExamplesParserTest capture.assertHasFrame(TextFrame.class,1); TextFrame txt = (TextFrame)capture.getFrames().get(0); - Assert.assertThat("TextFrame.data", txt.getData().toString(), is("Hello")); + Assert.assertThat("TextFrame.data", txt.getPayloadAsText(), is("Hello")); } } diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/parser/TextPayloadParserTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/parser/TextPayloadParserTest.java index 3cbe159efdb..772040dad62 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/parser/TextPayloadParserTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/parser/TextPayloadParserTest.java @@ -78,7 +78,7 @@ public class TextPayloadParserTest capture.assertNoErrors(); capture.assertHasFrame(TextFrame.class,1); TextFrame txt = (TextFrame)capture.getFrames().get(0); - Assert.assertThat("TextFrame.data",txt.getData().toString(),is(expectedText)); + Assert.assertThat("TextFrame.data",txt.getPayloadAsText(),is(expectedText)); } @Test @@ -113,7 +113,7 @@ public class TextPayloadParserTest capture.assertNoErrors(); capture.assertHasFrame(TextFrame.class,1); TextFrame txt = (TextFrame)capture.getFrames().get(0); - Assert.assertThat("TextFrame.data",txt.getData().toString(),is(expectedText)); + Assert.assertThat("TextFrame.data",txt.getPayloadAsText(),is(expectedText)); } @Test @@ -150,9 +150,9 @@ public class TextPayloadParserTest capture.assertNoErrors(); capture.assertHasFrame(TextFrame.class,2); TextFrame txt = (TextFrame)capture.getFrames().get(0); - Assert.assertThat("TextFrame[0].data",txt.getData().toString(),is(part1)); + Assert.assertThat("TextFrame[0].data",txt.getPayloadAsText(),is(part1)); txt = (TextFrame)capture.getFrames().get(1); - Assert.assertThat("TextFrame[1].data",txt.getData().toString(),is(part2)); + Assert.assertThat("TextFrame[1].data",txt.getPayloadAsText(),is(part2)); } @Test @@ -177,7 +177,7 @@ public class TextPayloadParserTest capture.assertNoErrors(); capture.assertHasFrame(TextFrame.class,1); TextFrame txt = (TextFrame)capture.getFrames().get(0); - Assert.assertThat("TextFrame.data",txt.getData().toString(),is(expectedText)); + Assert.assertThat("TextFrame.data",txt.getPayloadAsText(),is(expectedText)); } @Test @@ -203,6 +203,6 @@ public class TextPayloadParserTest capture.assertNoErrors(); capture.assertHasFrame(TextFrame.class,1); TextFrame txt = (TextFrame)capture.getFrames().get(0); - Assert.assertThat("TextFrame.data",txt.getData().toString(),is(expectedText)); + Assert.assertThat("TextFrame.data",txt.getPayloadAsText(),is(expectedText)); } }