Fixing FrameBuilder (and test)

This commit is contained in:
Joakim Erdfelt 2012-07-06 13:25:55 -07:00
parent 97cf0e37a9
commit 8d0d3adcf9
2 changed files with 5 additions and 5 deletions

View File

@ -45,7 +45,8 @@ public class FrameBuilder
byte utf[] = StringUtil.getUtf8Bytes(reason);
buf.put(utf,0,utf.length);
}
return new FrameBuilder(new WebSocketFrame(OpCode.CLOSE)).payload(buf);
BufferUtil.flipToFlush(buf,0);
return new FrameBuilder(new WebSocketFrame(OpCode.CLOSE)).payload(BufferUtil.toArray(buf));
}
return new FrameBuilder(new WebSocketFrame(OpCode.CLOSE));
}

View File

@ -1,6 +1,5 @@
package org.eclipse.jetty.websocket.frames;
package org.eclipse.jetty.websocket.protocol;
import org.eclipse.jetty.websocket.protocol.FrameBuilder;
import org.junit.Assert;
import org.junit.Test;
@ -34,7 +33,7 @@ public class FrameBuilderTest
byte[] actual = FrameBuilder.close(1000).asByteArray();
byte[] expected = new byte[]
{ (byte)0x89, (byte)0x02, (byte)0x03, (byte)0xe8 };
{ (byte)0x88, (byte)0x02, (byte)0x03, (byte)0xe8 };
Assert.assertArrayEquals(expected,actual);
}
@ -42,7 +41,7 @@ public class FrameBuilderTest
@Test
public void testSimpleValidPingFrame()
{
byte[] actual = FrameBuilder.close(1000).asByteArray();
byte[] actual = FrameBuilder.ping().asByteArray();
byte[] expected = new byte[]
{ (byte)0x89, (byte)0x00 };