Switching to direct ByteBuffers
This commit is contained in:
parent
5621f87c81
commit
bbcf0c77b8
|
@ -81,7 +81,7 @@ public class HttpResponseHeaderParser
|
|||
if (parseHeader(line))
|
||||
{
|
||||
// Finished parsing entire header
|
||||
ByteBuffer copy = ByteBuffer.allocate(buf.remaining());
|
||||
ByteBuffer copy = ByteBuffer.allocateDirect(buf.remaining());
|
||||
BufferUtil.put(buf,copy);
|
||||
BufferUtil.flipToFlush(copy,0);
|
||||
this.response.setRemainingBuffer(copy);
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.nio.ByteBuffer;
|
|||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.util.BufferUtil;
|
||||
import org.eclipse.jetty.websocket.api.Session;
|
||||
import org.eclipse.jetty.websocket.api.WebSocketAdapter;
|
||||
import org.eclipse.jetty.websocket.client.blockhead.BlockheadServer;
|
||||
|
@ -103,7 +104,7 @@ public class TomcatServerQuirksTest
|
|||
|
||||
// Have server write frame.
|
||||
int length = bufferSize / 2;
|
||||
ByteBuffer serverFrame = ByteBuffer.allocate(bufferSize);
|
||||
ByteBuffer serverFrame = ByteBuffer.allocateDirect(bufferSize);
|
||||
serverFrame.put((byte)(0x80 | 0x01)); // FIN + TEXT
|
||||
serverFrame.put((byte)0x7E); // No MASK and 2 bytes length
|
||||
serverFrame.put((byte)(length >> 8)); // first length byte
|
||||
|
@ -113,7 +114,7 @@ public class TomcatServerQuirksTest
|
|||
serverFrame.put((byte)'x');
|
||||
}
|
||||
serverFrame.flip();
|
||||
byte buf[] = serverFrame.array();
|
||||
byte buf[] = BufferUtil.toArray(serverFrame);
|
||||
socket.write(buf,0,buf.length);
|
||||
socket.flush();
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ public class HttpResponseHeaderParserTest
|
|||
expected.add("");
|
||||
|
||||
// Prepare Buffer
|
||||
ByteBuffer buf = ByteBuffer.allocate(512);
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(512);
|
||||
for (String line : expected)
|
||||
{
|
||||
appendUtf8(buf,line + "\r\n");
|
||||
|
@ -104,7 +104,7 @@ public class HttpResponseHeaderParserTest
|
|||
expected.add("");
|
||||
|
||||
// Prepare Buffer
|
||||
ByteBuffer buf = ByteBuffer.allocate(512);
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(512);
|
||||
for (String line : expected)
|
||||
{
|
||||
appendUtf8(buf,line + "\r\n");
|
||||
|
|
|
@ -83,7 +83,7 @@ public class DeflateCompressionMethod implements CompressionMethod
|
|||
public ByteBuffer process()
|
||||
{
|
||||
// prepare the output buffer
|
||||
ByteBuffer buf = ByteBuffer.allocate(bufferSize);
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(bufferSize);
|
||||
BufferUtil.clearToFill(buf);
|
||||
|
||||
while (!deflater.finished())
|
||||
|
|
|
@ -243,7 +243,7 @@ public class MuxParser
|
|||
private void parseDataFramePayload(ByteBuffer buffer)
|
||||
{
|
||||
int capacity = buffer.remaining();
|
||||
ByteBuffer payload = ByteBuffer.allocate(capacity);
|
||||
ByteBuffer payload = ByteBuffer.allocateDirect(capacity);
|
||||
payload.put(buffer);
|
||||
BufferUtil.flipToFlush(payload,0);
|
||||
muxframe.setPayload(payload);
|
||||
|
@ -336,7 +336,7 @@ public class MuxParser
|
|||
throw new MuxException(err);
|
||||
}
|
||||
|
||||
ByteBuffer ret = ByteBuffer.allocate((int)size);
|
||||
ByteBuffer ret = ByteBuffer.allocateDirect((int)size);
|
||||
BufferUtil.put(buffer,ret);
|
||||
BufferUtil.flipToFlush(ret,0);
|
||||
return ret;
|
||||
|
|
|
@ -45,7 +45,7 @@ public class MessageInputStream extends InputStream implements MessageAppender
|
|||
public MessageInputStream(AnnotatedEventDriver driver)
|
||||
{
|
||||
this.driver = driver;
|
||||
this.buf = ByteBuffer.allocate(BUFFER_SIZE);
|
||||
this.buf = ByteBuffer.allocateDirect(BUFFER_SIZE);
|
||||
BufferUtil.clearToFill(this.buf);
|
||||
size = 0;
|
||||
readPosition = this.buf.position();
|
||||
|
|
|
@ -37,12 +37,12 @@ public class ClosePayloadParserTest
|
|||
String expectedReason = "Game Over";
|
||||
|
||||
byte utf[] = expectedReason.getBytes(StringUtil.__UTF8_CHARSET);
|
||||
ByteBuffer payload = ByteBuffer.allocate(utf.length + 2);
|
||||
ByteBuffer payload = ByteBuffer.allocateDirect(utf.length + 2);
|
||||
payload.putChar((char)StatusCode.NORMAL);
|
||||
payload.put(utf,0,utf.length);
|
||||
payload.flip();
|
||||
|
||||
ByteBuffer buf = ByteBuffer.allocate(24);
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(24);
|
||||
buf.put((byte)(0x80 | OpCode.CLOSE)); // fin + close
|
||||
buf.put((byte)(0x80 | payload.remaining()));
|
||||
MaskedByteBuffer.putMask(buf);
|
||||
|
|
|
@ -139,7 +139,7 @@ public class GeneratorTest
|
|||
|
||||
// Buffer to capture generated bytes (we do this to validate that the masking
|
||||
// is working correctly
|
||||
ByteBuffer completeBuf = ByteBuffer.allocate(payload.length + expectedHeaderSize);
|
||||
ByteBuffer completeBuf = ByteBuffer.allocateDirect(payload.length + expectedHeaderSize);
|
||||
BufferUtil.clearToFill(completeBuf);
|
||||
|
||||
// Generate and capture generator output
|
||||
|
|
|
@ -191,7 +191,7 @@ public class ParserTest
|
|||
@Test
|
||||
public void testParseCase6_4_3()
|
||||
{
|
||||
ByteBuffer payload = ByteBuffer.allocate(64);
|
||||
ByteBuffer payload = ByteBuffer.allocateDirect(64);
|
||||
BufferUtil.clearToFill(payload);
|
||||
payload.put(TypeUtil.fromHexString("cebae1bdb9cf83cebcceb5")); // good
|
||||
payload.put(TypeUtil.fromHexString("f4908080")); // INVALID
|
||||
|
@ -205,9 +205,9 @@ public class ParserTest
|
|||
|
||||
ByteBuffer buf = new UnitGenerator().generate(text);
|
||||
|
||||
ByteBuffer part1 = ByteBuffer.allocate(17); // header + good
|
||||
ByteBuffer part2 = ByteBuffer.allocate(4); // invalid
|
||||
ByteBuffer part3 = ByteBuffer.allocate(10); // the rest (all good utf)
|
||||
ByteBuffer part1 = ByteBuffer.allocateDirect(17); // header + good
|
||||
ByteBuffer part2 = ByteBuffer.allocateDirect(4); // invalid
|
||||
ByteBuffer part3 = ByteBuffer.allocateDirect(10); // the rest (all good utf)
|
||||
|
||||
BufferUtil.put(buf,part1);
|
||||
BufferUtil.put(buf,part2);
|
||||
|
@ -235,7 +235,7 @@ public class ParserTest
|
|||
@Test
|
||||
public void testParseNothing()
|
||||
{
|
||||
ByteBuffer buf = ByteBuffer.allocate(16);
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(16);
|
||||
// Put nothing in the buffer.
|
||||
buf.flip();
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ public class PingPayloadParserTest
|
|||
@Test
|
||||
public void testBasicPingParsing()
|
||||
{
|
||||
ByteBuffer buf = ByteBuffer.allocate(16);
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(16);
|
||||
BufferUtil.clearToFill(buf);
|
||||
buf.put(new byte[]
|
||||
{ (byte)0x89, 0x05, 0x48, 0x65, 0x6c, 0x6c, 0x6f });
|
||||
|
|
|
@ -21,9 +21,6 @@ package org.eclipse.jetty.websocket.common;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.eclipse.jetty.websocket.common.Generator;
|
||||
import org.eclipse.jetty.websocket.common.OpCode;
|
||||
import org.eclipse.jetty.websocket.common.WebSocketFrame;
|
||||
import org.junit.Test;
|
||||
|
||||
public class RFC6455ExamplesGeneratorTest
|
||||
|
@ -41,12 +38,12 @@ public class RFC6455ExamplesGeneratorTest
|
|||
ByteBuffer actual1 = generator.generate(text1);
|
||||
ByteBuffer actual2 = generator.generate(text2);
|
||||
|
||||
ByteBuffer expected1 = ByteBuffer.allocate(5);
|
||||
ByteBuffer expected1 = ByteBuffer.allocateDirect(5);
|
||||
|
||||
expected1.put(new byte[]
|
||||
{ (byte)0x01, (byte)0x03, (byte)0x48, (byte)0x65, (byte)0x6c });
|
||||
|
||||
ByteBuffer expected2 = ByteBuffer.allocate(4);
|
||||
ByteBuffer expected2 = ByteBuffer.allocateDirect(4);
|
||||
|
||||
expected2.put(new byte[]
|
||||
{ (byte)0x80, (byte)0x02, (byte)0x6c, (byte)0x6f });
|
||||
|
@ -70,7 +67,7 @@ public class RFC6455ExamplesGeneratorTest
|
|||
|
||||
ByteBuffer actual = gen.generate(pong);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(11);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(11);
|
||||
// Raw bytes as found in RFC 6455, Section 5.7 - Examples
|
||||
// Unmasked Pong request
|
||||
expected.put(new byte[]
|
||||
|
@ -90,7 +87,7 @@ public class RFC6455ExamplesGeneratorTest
|
|||
Generator gen = new UnitGenerator();
|
||||
ByteBuffer actual = gen.generate(text);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(11);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(11);
|
||||
// Raw bytes as found in RFC 6455, Section 5.7 - Examples
|
||||
// A single-frame masked text message
|
||||
expected.put(new byte[]
|
||||
|
@ -114,7 +111,7 @@ public class RFC6455ExamplesGeneratorTest
|
|||
|
||||
ByteBuffer actual = gen.generate(binary);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(dataSize + FUDGE);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(dataSize + FUDGE);
|
||||
// Raw bytes as found in RFC 6455, Section 5.7 - Examples
|
||||
// 256 bytes binary message in a single unmasked frame
|
||||
expected.put(new byte[]
|
||||
|
@ -145,7 +142,7 @@ public class RFC6455ExamplesGeneratorTest
|
|||
|
||||
ByteBuffer actual = gen.generate(binary);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(dataSize + 10);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(dataSize + 10);
|
||||
// Raw bytes as found in RFC 6455, Section 5.7 - Examples
|
||||
// 64k bytes binary message in a single unmasked frame
|
||||
expected.put(new byte[]
|
||||
|
@ -171,7 +168,7 @@ public class RFC6455ExamplesGeneratorTest
|
|||
Generator gen = new UnitGenerator();
|
||||
ByteBuffer actual = gen.generate(ping);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(10);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(10);
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x89, (byte)0x05, (byte)0x48, (byte)0x65, (byte)0x6c, (byte)0x6c, (byte)0x6f });
|
||||
expected.flip(); // make readable
|
||||
|
@ -188,7 +185,7 @@ public class RFC6455ExamplesGeneratorTest
|
|||
|
||||
ByteBuffer actual = generator.generate(text);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(10);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(10);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x81, (byte)0x05, (byte)0x48, (byte)0x65, (byte)0x6c, (byte)0x6c, (byte)0x6f });
|
||||
|
|
|
@ -42,7 +42,7 @@ public class RFC6455ExamplesParserTest
|
|||
IncomingFramesCapture capture = new IncomingFramesCapture();
|
||||
parser.setIncomingFramesHandler(capture);
|
||||
|
||||
ByteBuffer buf = ByteBuffer.allocate(16);
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(16);
|
||||
BufferUtil.clearToFill(buf);
|
||||
|
||||
// Raw bytes as found in RFC 6455, Section 5.7 - Examples
|
||||
|
@ -75,7 +75,7 @@ public class RFC6455ExamplesParserTest
|
|||
@Test
|
||||
public void testSingleMaskedPongRequest()
|
||||
{
|
||||
ByteBuffer buf = ByteBuffer.allocate(16);
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(16);
|
||||
// Raw bytes as found in RFC 6455, Section 5.7 - Examples
|
||||
// Unmasked Pong request
|
||||
buf.put(new byte[]
|
||||
|
@ -98,7 +98,7 @@ public class RFC6455ExamplesParserTest
|
|||
@Test
|
||||
public void testSingleMaskedTextMessage()
|
||||
{
|
||||
ByteBuffer buf = ByteBuffer.allocate(16);
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(16);
|
||||
// Raw bytes as found in RFC 6455, Section 5.7 - Examples
|
||||
// A single-frame masked text message
|
||||
buf.put(new byte[]
|
||||
|
@ -123,7 +123,7 @@ public class RFC6455ExamplesParserTest
|
|||
{
|
||||
int dataSize = 256;
|
||||
|
||||
ByteBuffer buf = ByteBuffer.allocate(dataSize + 10);
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(dataSize + 10);
|
||||
// Raw bytes as found in RFC 6455, Section 5.7 - Examples
|
||||
// 256 bytes binary message in a single unmasked frame
|
||||
buf.put(new byte[]
|
||||
|
@ -162,7 +162,7 @@ public class RFC6455ExamplesParserTest
|
|||
{
|
||||
int dataSize = 1024 * 64;
|
||||
|
||||
ByteBuffer buf = ByteBuffer.allocate((dataSize + 10));
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect((dataSize + 10));
|
||||
// Raw bytes as found in RFC 6455, Section 5.7 - Examples
|
||||
// 64 Kbytes binary message in a single unmasked frame
|
||||
buf.put(new byte[]
|
||||
|
@ -198,7 +198,7 @@ public class RFC6455ExamplesParserTest
|
|||
@Test
|
||||
public void testSingleUnmaskedPingRequest()
|
||||
{
|
||||
ByteBuffer buf = ByteBuffer.allocate(16);
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(16);
|
||||
// Raw bytes as found in RFC 6455, Section 5.7 - Examples
|
||||
// Unmasked Ping request
|
||||
buf.put(new byte[]
|
||||
|
@ -221,7 +221,7 @@ public class RFC6455ExamplesParserTest
|
|||
@Test
|
||||
public void testSingleUnmaskedTextMessage()
|
||||
{
|
||||
ByteBuffer buf = ByteBuffer.allocate(16);
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(16);
|
||||
// Raw bytes as found in RFC 6455, Section 5.7 - Examples
|
||||
// A single-frame unmasked text message
|
||||
buf.put(new byte[]
|
||||
|
|
|
@ -44,7 +44,7 @@ public class TextPayloadParserTest
|
|||
|
||||
Assert.assertThat("Must be a medium length payload",utf.length,allOf(greaterThan(0x7E),lessThan(0xFFFF)));
|
||||
|
||||
ByteBuffer buf = ByteBuffer.allocate(utf.length + 8);
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(utf.length + 8);
|
||||
buf.put((byte)0x81);
|
||||
buf.put((byte)(0x80 | 0x7E)); // 0x7E == 126 (a 2 byte payload length)
|
||||
buf.putShort((short)utf.length);
|
||||
|
@ -79,7 +79,7 @@ public class TextPayloadParserTest
|
|||
|
||||
Assert.assertThat("Must be a long length payload",utf.length,greaterThan(0xFFFF));
|
||||
|
||||
ByteBuffer buf = ByteBuffer.allocate(utf.length + 32);
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(utf.length + 32);
|
||||
buf.put((byte)0x81);
|
||||
buf.put((byte)(0x80 | 0x7F)); // 0x7F == 127 (a 8 byte payload length)
|
||||
buf.putLong(utf.length);
|
||||
|
@ -115,7 +115,7 @@ public class TextPayloadParserTest
|
|||
|
||||
Assert.assertThat("Must be a medium length payload",utf.length,allOf(greaterThan(0x7E),lessThan(0xFFFF)));
|
||||
|
||||
ByteBuffer buf = ByteBuffer.allocate(utf.length + 10);
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(utf.length + 10);
|
||||
buf.put((byte)0x81);
|
||||
buf.put((byte)(0x80 | 0x7E)); // 0x7E == 126 (a 2 byte payload length)
|
||||
buf.putShort((short)utf.length);
|
||||
|
@ -144,7 +144,7 @@ public class TextPayloadParserTest
|
|||
byte b1[] = part1.getBytes(StringUtil.__UTF8_CHARSET);
|
||||
byte b2[] = part2.getBytes(StringUtil.__UTF8_CHARSET);
|
||||
|
||||
ByteBuffer buf = ByteBuffer.allocate(32);
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(32);
|
||||
|
||||
// part 1
|
||||
buf.put((byte)0x01); // no fin + text
|
||||
|
@ -180,7 +180,7 @@ public class TextPayloadParserTest
|
|||
String expectedText = "Hello World";
|
||||
byte utf[] = expectedText.getBytes(StringUtil.__UTF8_CHARSET);
|
||||
|
||||
ByteBuffer buf = ByteBuffer.allocate(24);
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(24);
|
||||
buf.put((byte)0x81);
|
||||
buf.put((byte)(0x80 | utf.length));
|
||||
MaskedByteBuffer.putMask(buf);
|
||||
|
@ -206,7 +206,7 @@ public class TextPayloadParserTest
|
|||
|
||||
byte utf[] = expectedText.getBytes(StringUtil.__UTF8);
|
||||
|
||||
ByteBuffer buf = ByteBuffer.allocate(24);
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(24);
|
||||
buf.put((byte)0x81);
|
||||
buf.put((byte)(0x80 | utf.length));
|
||||
MaskedByteBuffer.putMask(buf);
|
||||
|
|
|
@ -46,7 +46,7 @@ public class UnitGenerator extends Generator
|
|||
{
|
||||
buflen += f.getPayloadLength() + Generator.OVERHEAD;
|
||||
}
|
||||
ByteBuffer completeBuf = ByteBuffer.allocate(buflen);
|
||||
ByteBuffer completeBuf = ByteBuffer.allocateDirect(buflen);
|
||||
BufferUtil.clearToFill(completeBuf);
|
||||
|
||||
// Generate frames
|
||||
|
|
|
@ -58,7 +58,7 @@ public class WebSocketFrameTest
|
|||
{
|
||||
WebSocketFrame frame = new WebSocketFrame(OpCode.CLOSE).setFin(false);
|
||||
ByteBuffer actual = laxGenerator.generate(frame);
|
||||
ByteBuffer expected = ByteBuffer.allocate(2);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(2);
|
||||
expected.put((byte)0x08);
|
||||
expected.put((byte)0x00);
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class WebSocketFrameTest
|
|||
{
|
||||
WebSocketFrame frame = new WebSocketFrame(OpCode.PING).setFin(false);
|
||||
ByteBuffer actual = laxGenerator.generate(frame);
|
||||
ByteBuffer expected = ByteBuffer.allocate(2);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(2);
|
||||
expected.put((byte)0x09);
|
||||
expected.put((byte)0x00);
|
||||
|
||||
|
@ -82,7 +82,7 @@ public class WebSocketFrameTest
|
|||
{
|
||||
CloseInfo close = new CloseInfo(StatusCode.NORMAL);
|
||||
ByteBuffer actual = strictGenerator.generate(close.asFrame());
|
||||
ByteBuffer expected = ByteBuffer.allocate(4);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(4);
|
||||
expected.put((byte)0x88);
|
||||
expected.put((byte)0x02);
|
||||
expected.put((byte)0x03);
|
||||
|
@ -96,7 +96,7 @@ public class WebSocketFrameTest
|
|||
{
|
||||
WebSocketFrame frame = new WebSocketFrame(OpCode.PING);
|
||||
ByteBuffer actual = strictGenerator.generate(frame);
|
||||
ByteBuffer expected = ByteBuffer.allocate(2);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(2);
|
||||
expected.put((byte)0x89);
|
||||
expected.put((byte)0x00);
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ public class TestABCase1_1
|
|||
Generator generator = new UnitGenerator();
|
||||
ByteBuffer actual = generator.generate(textFrame);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(length + 5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x81 });
|
||||
|
@ -96,7 +96,7 @@ public class TestABCase1_1
|
|||
Generator generator = new UnitGenerator();
|
||||
ByteBuffer actual = generator.generate(textFrame);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(length + 5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x81 });
|
||||
|
@ -136,7 +136,7 @@ public class TestABCase1_1
|
|||
Generator generator = new UnitGenerator();
|
||||
ByteBuffer actual = generator.generate(textFrame);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(length + 5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x81 });
|
||||
|
@ -176,7 +176,7 @@ public class TestABCase1_1
|
|||
Generator generator = new UnitGenerator();
|
||||
ByteBuffer actual = generator.generate(textFrame);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(length + 5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x81 });
|
||||
|
@ -217,7 +217,7 @@ public class TestABCase1_1
|
|||
|
||||
ByteBuffer actual = generator.generate(textFrame);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(length + 5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x81 });
|
||||
|
@ -255,7 +255,7 @@ public class TestABCase1_1
|
|||
Generator generator = new UnitGenerator();
|
||||
ByteBuffer actual = generator.generate(textFrame);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(length + 11);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(length + 11);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x81 });
|
||||
|
@ -284,7 +284,7 @@ public class TestABCase1_1
|
|||
Generator generator = new UnitGenerator();
|
||||
ByteBuffer actual = generator.generate(textFrame);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x81, (byte)0x00 });
|
||||
|
@ -299,7 +299,7 @@ public class TestABCase1_1
|
|||
{
|
||||
int length = 125;
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(length + 5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x81 });
|
||||
|
@ -332,7 +332,7 @@ public class TestABCase1_1
|
|||
{
|
||||
int length = 126;
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(length + 5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x81 });
|
||||
|
@ -366,7 +366,7 @@ public class TestABCase1_1
|
|||
{
|
||||
int length = 127;
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(length + 5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x81 });
|
||||
|
@ -400,7 +400,7 @@ public class TestABCase1_1
|
|||
{
|
||||
int length = 128;
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(length + 5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x81 });
|
||||
|
@ -434,7 +434,7 @@ public class TestABCase1_1
|
|||
{
|
||||
int length = 65535;
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(length + 5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x81 });
|
||||
|
@ -470,7 +470,7 @@ public class TestABCase1_1
|
|||
{
|
||||
int length = 65536;
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(length + 11);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(length + 11);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x81 });
|
||||
|
@ -506,7 +506,7 @@ public class TestABCase1_1
|
|||
public void testParseEmptyTextCase1_1_1()
|
||||
{
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x81, (byte)0x00 });
|
||||
|
|
|
@ -49,7 +49,7 @@ public class TestABCase1_2
|
|||
{
|
||||
int length = 125;
|
||||
|
||||
ByteBuffer bb = ByteBuffer.allocate(length);
|
||||
ByteBuffer bb = ByteBuffer.allocateDirect(length);
|
||||
|
||||
for ( int i = 0 ; i < length ; ++i)
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ public class TestABCase1_2
|
|||
ByteBuffer actual = generator.generate(binaryFrame);
|
||||
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(length + 5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x82 });
|
||||
|
@ -88,7 +88,7 @@ public class TestABCase1_2
|
|||
{
|
||||
int length = 126;
|
||||
|
||||
ByteBuffer bb = ByteBuffer.allocate(length);
|
||||
ByteBuffer bb = ByteBuffer.allocateDirect(length);
|
||||
|
||||
for ( int i = 0 ; i < length ; ++i)
|
||||
{
|
||||
|
@ -102,7 +102,7 @@ public class TestABCase1_2
|
|||
Generator generator = new UnitGenerator();
|
||||
ByteBuffer actual = generator.generate(binaryFrame);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(length + 5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x82 });
|
||||
|
@ -130,7 +130,7 @@ public class TestABCase1_2
|
|||
{
|
||||
int length = 127;
|
||||
|
||||
ByteBuffer bb = ByteBuffer.allocate(length);
|
||||
ByteBuffer bb = ByteBuffer.allocateDirect(length);
|
||||
|
||||
for ( int i = 0 ; i < length ; ++i)
|
||||
{
|
||||
|
@ -145,7 +145,7 @@ public class TestABCase1_2
|
|||
Generator generator = new UnitGenerator();
|
||||
ByteBuffer actual = generator.generate(binaryFrame);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(length + 5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x82 });
|
||||
|
@ -173,7 +173,7 @@ public class TestABCase1_2
|
|||
{
|
||||
int length = 128;
|
||||
|
||||
ByteBuffer bb = ByteBuffer.allocate(length);
|
||||
ByteBuffer bb = ByteBuffer.allocateDirect(length);
|
||||
|
||||
for ( int i = 0 ; i < length ; ++i)
|
||||
{
|
||||
|
@ -187,7 +187,7 @@ public class TestABCase1_2
|
|||
Generator generator = new UnitGenerator();
|
||||
ByteBuffer actual = generator.generate(binaryFrame);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(length + 5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x82 });
|
||||
|
@ -216,7 +216,7 @@ public class TestABCase1_2
|
|||
{
|
||||
int length = 65535;
|
||||
|
||||
ByteBuffer bb = ByteBuffer.allocate(length);
|
||||
ByteBuffer bb = ByteBuffer.allocateDirect(length);
|
||||
|
||||
for ( int i = 0 ; i < length ; ++i)
|
||||
{
|
||||
|
@ -231,7 +231,7 @@ public class TestABCase1_2
|
|||
Generator generator = new UnitGenerator();
|
||||
ByteBuffer actual = generator.generate(binaryFrame);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(length + 5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x82 });
|
||||
|
@ -256,7 +256,7 @@ public class TestABCase1_2
|
|||
{
|
||||
int length = 65536;
|
||||
|
||||
ByteBuffer bb = ByteBuffer.allocate(length);
|
||||
ByteBuffer bb = ByteBuffer.allocateDirect(length);
|
||||
|
||||
for ( int i = 0 ; i < length ; ++i)
|
||||
{
|
||||
|
@ -271,7 +271,7 @@ public class TestABCase1_2
|
|||
Generator generator = new UnitGenerator();
|
||||
ByteBuffer actual = generator.generate(binaryFrame);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(length + 11);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(length + 11);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x82 });
|
||||
|
@ -300,7 +300,7 @@ public class TestABCase1_2
|
|||
Generator generator = new UnitGenerator();
|
||||
ByteBuffer actual = generator.generate(binaryFrame);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x82, (byte)0x00 });
|
||||
|
@ -315,7 +315,7 @@ public class TestABCase1_2
|
|||
{
|
||||
int length = 125;
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(length + 5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x82 });
|
||||
|
@ -348,7 +348,7 @@ public class TestABCase1_2
|
|||
{
|
||||
int length = 126;
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(length + 5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x82 });
|
||||
|
@ -382,7 +382,7 @@ public class TestABCase1_2
|
|||
{
|
||||
int length = 127;
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(length + 5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x82 });
|
||||
|
@ -416,7 +416,7 @@ public class TestABCase1_2
|
|||
{
|
||||
int length = 128;
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(length + 5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x82 });
|
||||
|
@ -450,7 +450,7 @@ public class TestABCase1_2
|
|||
{
|
||||
int length = 65535;
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(length + 5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(length + 5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x82 });
|
||||
|
@ -486,7 +486,7 @@ public class TestABCase1_2
|
|||
{
|
||||
int length = 65536;
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(length + 11);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(length + 11);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x82 });
|
||||
|
@ -521,7 +521,7 @@ public class TestABCase1_2
|
|||
public void testParseEmptyBinaryCase1_2_1()
|
||||
{
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x82, (byte)0x00 });
|
||||
|
|
|
@ -58,7 +58,7 @@ public class TestABCase2
|
|||
Generator generator = new UnitGenerator();
|
||||
ByteBuffer actual = generator.generate(pingFrame);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(bytes.length + 32);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(bytes.length + 32);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x89 });
|
||||
|
@ -83,7 +83,7 @@ public class TestABCase2
|
|||
Generator generator = new UnitGenerator();
|
||||
ByteBuffer actual = generator.generate(pingFrame);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(32);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(32);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x89 });
|
||||
|
@ -108,7 +108,7 @@ public class TestABCase2
|
|||
Generator generator = new UnitGenerator();
|
||||
ByteBuffer actual = generator.generate(pingFrame);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x89, (byte)0x00 });
|
||||
|
@ -129,7 +129,7 @@ public class TestABCase2
|
|||
Generator generator = new UnitGenerator();
|
||||
ByteBuffer actual = generator.generate(pingFrame);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(32);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(32);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x89 });
|
||||
|
@ -183,7 +183,7 @@ public class TestABCase2
|
|||
bytes[i] = Integer.valueOf(Integer.toOctalString(i)).byteValue();
|
||||
}
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(bytes.length + 32);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(bytes.length + 32);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x89 });
|
||||
|
@ -213,7 +213,7 @@ public class TestABCase2
|
|||
{
|
||||
byte[] bytes = new byte[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(32);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(32);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x89 });
|
||||
|
@ -241,7 +241,7 @@ public class TestABCase2
|
|||
@Test
|
||||
public void testParseEmptyPingCase2_1()
|
||||
{
|
||||
ByteBuffer expected = ByteBuffer.allocate(5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x89, (byte)0x00 });
|
||||
|
@ -267,7 +267,7 @@ public class TestABCase2
|
|||
String message = "Hello, world!";
|
||||
byte[] messageBytes = message.getBytes();
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(32);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(32);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x89 });
|
||||
|
@ -298,7 +298,7 @@ public class TestABCase2
|
|||
byte[] bytes = new byte[126];
|
||||
Arrays.fill(bytes,(byte)0x00);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(bytes.length + Generator.OVERHEAD);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(bytes.length + Generator.OVERHEAD);
|
||||
|
||||
byte b;
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public class TestABCase4
|
|||
@Test
|
||||
public void testParserControlOpCode11Case4_2_1()
|
||||
{
|
||||
ByteBuffer expected = ByteBuffer.allocate(32);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(32);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x8b, 0x00 });
|
||||
|
@ -73,7 +73,7 @@ public class TestABCase4
|
|||
@Test
|
||||
public void testParserControlOpCode12WithPayloadCase4_2_2()
|
||||
{
|
||||
ByteBuffer expected = ByteBuffer.allocate(32);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(32);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x8c, 0x01, 0x00 });
|
||||
|
@ -96,7 +96,7 @@ public class TestABCase4
|
|||
@Test
|
||||
public void testParserNonControlOpCode3Case4_1_1()
|
||||
{
|
||||
ByteBuffer expected = ByteBuffer.allocate(32);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(32);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x83, 0x00 });
|
||||
|
@ -118,7 +118,7 @@ public class TestABCase4
|
|||
@Test
|
||||
public void testParserNonControlOpCode4WithPayloadCase4_1_2()
|
||||
{
|
||||
ByteBuffer expected = ByteBuffer.allocate(32);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(32);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x84, 0x01, 0x00 });
|
||||
|
|
|
@ -53,7 +53,7 @@ public class TestABCase7_3
|
|||
Generator generator = new UnitGenerator();
|
||||
ByteBuffer actual = generator.generate(close.asFrame());
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x88, (byte)0x00 });
|
||||
|
@ -66,7 +66,7 @@ public class TestABCase7_3
|
|||
@Test
|
||||
public void testCase7_3_1ParseEmptyClose()
|
||||
{
|
||||
ByteBuffer expected = ByteBuffer.allocate(5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x88, (byte)0x00 });
|
||||
|
@ -100,7 +100,7 @@ public class TestABCase7_3
|
|||
@Test
|
||||
public void testCase7_3_2Parse1BytePayloadClose()
|
||||
{
|
||||
ByteBuffer expected = ByteBuffer.allocate(32);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(32);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x88, 0x01, 0x00 });
|
||||
|
@ -127,7 +127,7 @@ public class TestABCase7_3
|
|||
Generator generator = new UnitGenerator();
|
||||
ByteBuffer actual = generator.generate(close.asFrame());
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x88, (byte)0x02, 0x03, (byte)0xe8 });
|
||||
|
@ -140,7 +140,7 @@ public class TestABCase7_3
|
|||
@Test
|
||||
public void testCase7_3_3ParseCloseWithStatus()
|
||||
{
|
||||
ByteBuffer expected = ByteBuffer.allocate(5);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(5);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x88, (byte)0x02, 0x03, (byte)0xe8 });
|
||||
|
@ -172,7 +172,7 @@ public class TestABCase7_3
|
|||
Generator generator = new UnitGenerator();
|
||||
ByteBuffer actual = generator.generate(close.asFrame());
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(32);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(32);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x88 });
|
||||
|
@ -194,7 +194,7 @@ public class TestABCase7_3
|
|||
String message = "bad cough";
|
||||
byte[] messageBytes = message.getBytes();
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(32);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(32);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x88 });
|
||||
|
@ -232,7 +232,7 @@ public class TestABCase7_3
|
|||
|
||||
Generator generator = new UnitGenerator();
|
||||
ByteBuffer actual = generator.generate(close.asFrame());
|
||||
ByteBuffer expected = ByteBuffer.allocate(132);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(132);
|
||||
|
||||
byte messageBytes[] = message.toString().getBytes(StringUtil.__UTF8_CHARSET);
|
||||
|
||||
|
@ -262,7 +262,7 @@ public class TestABCase7_3
|
|||
|
||||
byte[] messageBytes = message.toString().getBytes(StringUtil.__UTF8_CHARSET);
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(132);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(132);
|
||||
|
||||
expected.put(new byte[]
|
||||
{ (byte)0x88 });
|
||||
|
@ -301,7 +301,7 @@ public class TestABCase7_3
|
|||
|
||||
WebSocketFrame closeFrame = new WebSocketFrame(OpCode.CLOSE);
|
||||
|
||||
ByteBuffer bb = ByteBuffer.allocate(WebSocketFrame.MAX_CONTROL_PAYLOAD + 1); // 126 which is too big for control
|
||||
ByteBuffer bb = ByteBuffer.allocateDirect(WebSocketFrame.MAX_CONTROL_PAYLOAD + 1); // 126 which is too big for control
|
||||
|
||||
bb.putChar((char)1000);
|
||||
bb.put(messageBytes);
|
||||
|
@ -320,7 +320,7 @@ public class TestABCase7_3
|
|||
byte[] messageBytes = new byte[124];
|
||||
Arrays.fill(messageBytes,(byte)'*');
|
||||
|
||||
ByteBuffer expected = ByteBuffer.allocate(256);
|
||||
ByteBuffer expected = ByteBuffer.allocateDirect(256);
|
||||
|
||||
byte b;
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public class DeflateCompressionMethodTest
|
|||
method.compress().end();
|
||||
|
||||
// decompress
|
||||
ByteBuffer decompressed = ByteBuffer.allocate(msg.length());
|
||||
ByteBuffer decompressed = ByteBuffer.allocateDirect(msg.length());
|
||||
LOG.debug("decompressed(a): {}",BufferUtil.toDetailString(decompressed));
|
||||
method.decompress().begin();
|
||||
method.decompress().input(compressed);
|
||||
|
@ -89,7 +89,7 @@ public class DeflateCompressionMethodTest
|
|||
CompressionMethod method = new DeflateCompressionMethod();
|
||||
|
||||
// Decompressed Data Holder
|
||||
ByteBuffer decompressed = ByteBuffer.allocate(32);
|
||||
ByteBuffer decompressed = ByteBuffer.allocateDirect(32);
|
||||
BufferUtil.flipToFill(decompressed);
|
||||
|
||||
// Perform Decompress on Buf 1
|
||||
|
|
|
@ -179,7 +179,7 @@ public class FrameCompressionExtensionTest
|
|||
compressor.finish();
|
||||
|
||||
// Perform compression
|
||||
ByteBuffer outbuf = ByteBuffer.allocate(64);
|
||||
ByteBuffer outbuf = ByteBuffer.allocateDirect(64);
|
||||
BufferUtil.clearToFill(outbuf);
|
||||
|
||||
while (!compressor.finished())
|
||||
|
|
|
@ -88,7 +88,7 @@ public class MuxGeneratorWrite139SizeTest
|
|||
public void testWrite139Size()
|
||||
{
|
||||
System.err.printf("Running %s.%s - value: %,d%n",this.getClass().getName(),testname.getMethodName(),value);
|
||||
ByteBuffer bbuf = ByteBuffer.allocate(10);
|
||||
ByteBuffer bbuf = ByteBuffer.allocateDirect(10);
|
||||
generator.write139Size(bbuf,value);
|
||||
BufferUtil.flipToFlush(bbuf,0);
|
||||
byte actual[] = BufferUtil.toArray(bbuf);
|
||||
|
|
|
@ -92,7 +92,7 @@ public class MuxGeneratorWriteChannelIdTest
|
|||
public void testReadChannelId()
|
||||
{
|
||||
System.err.printf("Running %s.%s - channelId: %,d%n",this.getClass().getName(),testname.getMethodName(),channelId);
|
||||
ByteBuffer bbuf = ByteBuffer.allocate(10);
|
||||
ByteBuffer bbuf = ByteBuffer.allocateDirect(10);
|
||||
generator.writeChannelId(bbuf,channelId);
|
||||
BufferUtil.flipToFlush(bbuf,0);
|
||||
byte actual[] = BufferUtil.toArray(bbuf);
|
||||
|
|
|
@ -101,7 +101,7 @@ public class Fuzzer
|
|||
{
|
||||
buflen += f.getPayloadLength() + Generator.OVERHEAD;
|
||||
}
|
||||
ByteBuffer buf = ByteBuffer.allocate(buflen);
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(buflen);
|
||||
BufferUtil.clearToFill(buf);
|
||||
|
||||
// Generate frames
|
||||
|
@ -271,7 +271,7 @@ public class Fuzzer
|
|||
{
|
||||
buflen += f.getPayloadLength() + Generator.OVERHEAD;
|
||||
}
|
||||
ByteBuffer buf = ByteBuffer.allocate(buflen);
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(buflen);
|
||||
BufferUtil.clearToFill(buf);
|
||||
|
||||
// Generate frames
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.eclipse.jetty.websocket.server.ab;
|
|||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.toolchain.test.AdvancedRunner;
|
||||
import org.eclipse.jetty.toolchain.test.annotation.Slow;
|
||||
|
@ -299,9 +298,7 @@ public class TestABCase6 extends AbstractABCase
|
|||
fuzzer.setSendMode(Fuzzer.SendMode.BULK);
|
||||
|
||||
fuzzer.send(new WebSocketFrame(OpCode.TEXT).setPayload(part1).setFin(false));
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
fuzzer.send(new WebSocketFrame(OpCode.CONTINUATION).setPayload(part2).setFin(false));
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
fuzzer.send(new WebSocketFrame(OpCode.CONTINUATION).setPayload(part3).setFin(true));
|
||||
|
||||
fuzzer.expect(expect);
|
||||
|
@ -338,9 +335,7 @@ public class TestABCase6 extends AbstractABCase
|
|||
fuzzer.connect();
|
||||
fuzzer.setSendMode(Fuzzer.SendMode.BULK);
|
||||
fuzzer.send(new WebSocketFrame(OpCode.TEXT).setPayload(part1).setFin(false));
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
fuzzer.send(new WebSocketFrame(OpCode.CONTINUATION).setPayload(part2).setFin(false));
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
fuzzer.send(new WebSocketFrame(OpCode.CONTINUATION).setPayload(part3).setFin(true));
|
||||
fuzzer.expect(expect);
|
||||
}
|
||||
|
@ -360,7 +355,7 @@ public class TestABCase6 extends AbstractABCase
|
|||
// Disable Long Stacks from Parser (we know this test will throw an exception)
|
||||
enableStacks(Parser.class,false);
|
||||
|
||||
ByteBuffer payload = ByteBuffer.allocate(64);
|
||||
ByteBuffer payload = ByteBuffer.allocateDirect(64);
|
||||
BufferUtil.clearToFill(payload);
|
||||
payload.put(TypeUtil.fromHexString("cebae1bdb9cf83cebcceb5")); // good
|
||||
payload.put(TypeUtil.fromHexString("f4908080")); // INVALID
|
||||
|
@ -394,12 +389,10 @@ public class TestABCase6 extends AbstractABCase
|
|||
part3.limit(splits[2]);
|
||||
|
||||
fuzzer.send(part1); // the header + good utf
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
fuzzer.send(part2); // the bad UTF
|
||||
|
||||
fuzzer.expect(expect);
|
||||
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
fuzzer.sendExpectingIOException(part3); // the rest (shouldn't work)
|
||||
}
|
||||
finally
|
||||
|
@ -436,9 +429,7 @@ public class TestABCase6 extends AbstractABCase
|
|||
ByteBuffer net = fuzzer.asNetworkBuffer(send);
|
||||
fuzzer.send(net,6);
|
||||
fuzzer.send(net,11);
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
fuzzer.send(net,1);
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
fuzzer.send(net,100); // the rest
|
||||
|
||||
fuzzer.expect(expect);
|
||||
|
|
|
@ -367,7 +367,7 @@ public class TestABCase7 extends AbstractABCase
|
|||
@Test
|
||||
public void testCase7_3_6() throws Exception
|
||||
{
|
||||
ByteBuffer payload = ByteBuffer.allocate(256);
|
||||
ByteBuffer payload = ByteBuffer.allocateDirect(256);
|
||||
BufferUtil.clearToFill(payload);
|
||||
payload.put((byte)0xE8);
|
||||
payload.put((byte)0x03);
|
||||
|
@ -408,7 +408,7 @@ public class TestABCase7 extends AbstractABCase
|
|||
@Test
|
||||
public void testCase7_5_1() throws Exception
|
||||
{
|
||||
ByteBuffer payload = ByteBuffer.allocate(256);
|
||||
ByteBuffer payload = ByteBuffer.allocateDirect(256);
|
||||
BufferUtil.clearToFill(payload);
|
||||
payload.put((byte)0x03); // normal close
|
||||
payload.put((byte)0xE8);
|
||||
|
|
|
@ -86,7 +86,7 @@ public class TestABCase7_BadStatusCodes extends AbstractABCase
|
|||
@Test
|
||||
public void testBadStatusCode() throws Exception
|
||||
{
|
||||
ByteBuffer payload = ByteBuffer.allocate(256);
|
||||
ByteBuffer payload = ByteBuffer.allocateDirect(256);
|
||||
BufferUtil.clearToFill(payload);
|
||||
payload.putChar((char)statusCode);
|
||||
BufferUtil.flipToFlush(payload,0);
|
||||
|
@ -118,7 +118,7 @@ public class TestABCase7_BadStatusCodes extends AbstractABCase
|
|||
@Test
|
||||
public void testBadStatusCodeWithReason() throws Exception
|
||||
{
|
||||
ByteBuffer payload = ByteBuffer.allocate(256);
|
||||
ByteBuffer payload = ByteBuffer.allocateDirect(256);
|
||||
BufferUtil.clearToFill(payload);
|
||||
payload.putChar((char)statusCode);
|
||||
payload.put(StringUtil.getBytes("Reason"));
|
||||
|
|
|
@ -81,7 +81,7 @@ public class TestABCase7_GoodStatusCodes extends AbstractABCase
|
|||
@Test
|
||||
public void testStatusCode() throws Exception
|
||||
{
|
||||
ByteBuffer payload = ByteBuffer.allocate(256);
|
||||
ByteBuffer payload = ByteBuffer.allocateDirect(256);
|
||||
BufferUtil.clearToFill(payload);
|
||||
payload.putChar((char)statusCode);
|
||||
BufferUtil.flipToFlush(payload,0);
|
||||
|
@ -113,7 +113,7 @@ public class TestABCase7_GoodStatusCodes extends AbstractABCase
|
|||
@Test
|
||||
public void testStatusCodeWithReason() throws Exception
|
||||
{
|
||||
ByteBuffer payload = ByteBuffer.allocate(256);
|
||||
ByteBuffer payload = ByteBuffer.allocateDirect(256);
|
||||
BufferUtil.clearToFill(payload);
|
||||
payload.putChar((char)statusCode);
|
||||
payload.put(StringUtil.getBytes("Reason"));
|
||||
|
|
|
@ -46,7 +46,7 @@ public class EchoBroadcastPingSocket extends EchoBroadcastSocket
|
|||
while (!latch.await(10,TimeUnit.SECONDS))
|
||||
{
|
||||
System.err.println("Ping");
|
||||
ByteBuffer data = ByteBuffer.allocate(3);
|
||||
ByteBuffer data = ByteBuffer.allocateDirect(3);
|
||||
data.put(new byte[]
|
||||
{ (byte)1, (byte)2, (byte)3 });
|
||||
data.flip();
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
package org.eclipse.jetty.websocket.server.helper;
|
||||
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -34,8 +36,6 @@ import org.eclipse.jetty.util.BufferUtil;
|
|||
import org.eclipse.jetty.util.TypeUtil;
|
||||
import org.junit.Assert;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
public class SafariD00
|
||||
{
|
||||
private URI uri;
|
||||
|
@ -52,7 +52,7 @@ public class SafariD00
|
|||
|
||||
/**
|
||||
* Open the Socket to the destination endpoint and
|
||||
*
|
||||
*
|
||||
* @return the open java Socket.
|
||||
* @throws IOException
|
||||
*/
|
||||
|
@ -74,7 +74,7 @@ public class SafariD00
|
|||
|
||||
/**
|
||||
* Issue an Http websocket (Draft-0) upgrade request using the Safari particulars.
|
||||
*
|
||||
*
|
||||
* @throws UnsupportedEncodingException
|
||||
*/
|
||||
public void issueHandshake() throws IOException
|
||||
|
@ -135,7 +135,7 @@ public class SafariD00
|
|||
len += (msg.length() + 2);
|
||||
}
|
||||
|
||||
ByteBuffer buf = ByteBuffer.allocate(len);
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(len);
|
||||
|
||||
for (String msg : msgs)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue