Fixing expectations in unit tests
This commit is contained in:
parent
1c51e82b87
commit
f8e72803a6
|
@ -69,11 +69,9 @@ public class TestABCase1_1
|
||||||
expected.put("*".getBytes());
|
expected.put("*".getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
actual.flip();
|
|
||||||
expected.flip();
|
expected.flip();
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -111,11 +109,9 @@ public class TestABCase1_1
|
||||||
expected.put("*".getBytes());
|
expected.put("*".getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
actual.flip();
|
|
||||||
expected.flip();
|
expected.flip();
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -153,11 +149,9 @@ public class TestABCase1_1
|
||||||
expected.put("*".getBytes());
|
expected.put("*".getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
actual.flip();
|
|
||||||
expected.flip();
|
expected.flip();
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -195,11 +189,9 @@ public class TestABCase1_1
|
||||||
expected.put("*".getBytes());
|
expected.put("*".getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
actual.flip();
|
|
||||||
expected.flip();
|
expected.flip();
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -236,11 +228,9 @@ public class TestABCase1_1
|
||||||
expected.put("*".getBytes());
|
expected.put("*".getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
actual.flip();
|
|
||||||
expected.flip();
|
expected.flip();
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -276,11 +266,9 @@ public class TestABCase1_1
|
||||||
expected.put("*".getBytes());
|
expected.put("*".getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
actual.flip();
|
|
||||||
expected.flip();
|
expected.flip();
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -296,11 +284,9 @@ public class TestABCase1_1
|
||||||
expected.put(new byte[]
|
expected.put(new byte[]
|
||||||
{ (byte)0x81, (byte)0x00 });
|
{ (byte)0x81, (byte)0x00 });
|
||||||
|
|
||||||
actual.flip();
|
|
||||||
expected.flip();
|
expected.flip();
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -73,11 +73,9 @@ public class TestABCase1_2
|
||||||
expected.put("*".getBytes());
|
expected.put("*".getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferUtil.flipToFlush(actual,0);
|
|
||||||
BufferUtil.flipToFlush(expected,0);
|
BufferUtil.flipToFlush(expected,0);
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -117,11 +115,9 @@ public class TestABCase1_2
|
||||||
expected.put("*".getBytes());
|
expected.put("*".getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferUtil.flipToFlush(actual,0);
|
|
||||||
BufferUtil.flipToFlush(expected,0);
|
BufferUtil.flipToFlush(expected,0);
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -162,11 +158,9 @@ public class TestABCase1_2
|
||||||
expected.put("*".getBytes());
|
expected.put("*".getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferUtil.flipToFlush(actual,0);
|
|
||||||
BufferUtil.flipToFlush(expected,0);
|
BufferUtil.flipToFlush(expected,0);
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -206,7 +200,6 @@ public class TestABCase1_2
|
||||||
expected.put("*".getBytes());
|
expected.put("*".getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferUtil.flipToFlush(actual,0);
|
|
||||||
BufferUtil.flipToFlush(expected,0);
|
BufferUtil.flipToFlush(expected,0);
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
||||||
|
@ -248,11 +241,9 @@ public class TestABCase1_2
|
||||||
expected.put("*".getBytes());
|
expected.put("*".getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferUtil.flipToFlush(actual,0);
|
|
||||||
BufferUtil.flipToFlush(expected,0);
|
BufferUtil.flipToFlush(expected,0);
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -291,11 +282,9 @@ public class TestABCase1_2
|
||||||
expected.put("*".getBytes());
|
expected.put("*".getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferUtil.flipToFlush(actual,0);
|
|
||||||
BufferUtil.flipToFlush(expected,0);
|
BufferUtil.flipToFlush(expected,0);
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -311,11 +300,9 @@ public class TestABCase1_2
|
||||||
expected.put(new byte[]
|
expected.put(new byte[]
|
||||||
{ (byte)0x82, (byte)0x00 });
|
{ (byte)0x82, (byte)0x00 });
|
||||||
|
|
||||||
BufferUtil.flipToFlush(actual,0);
|
|
||||||
BufferUtil.flipToFlush(expected,0);
|
BufferUtil.flipToFlush(expected,0);
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -63,8 +63,6 @@ public class TestABCase2
|
||||||
expected.put(b);
|
expected.put(b);
|
||||||
expected.put(bytes);
|
expected.put(bytes);
|
||||||
|
|
||||||
|
|
||||||
actual.flip();
|
|
||||||
expected.flip();
|
expected.flip();
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
||||||
|
@ -90,8 +88,6 @@ public class TestABCase2
|
||||||
expected.put(b);
|
expected.put(b);
|
||||||
expected.put(bytes);
|
expected.put(bytes);
|
||||||
|
|
||||||
|
|
||||||
actual.flip();
|
|
||||||
expected.flip();
|
expected.flip();
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
||||||
|
@ -112,7 +108,6 @@ public class TestABCase2
|
||||||
expected.put(new byte[]
|
expected.put(new byte[]
|
||||||
{ (byte)0x89, (byte)0x00 });
|
{ (byte)0x89, (byte)0x00 });
|
||||||
|
|
||||||
actual.flip();
|
|
||||||
expected.flip();
|
expected.flip();
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
||||||
|
@ -139,8 +134,6 @@ public class TestABCase2
|
||||||
expected.put(b);
|
expected.put(b);
|
||||||
expected.put(messageBytes);
|
expected.put(messageBytes);
|
||||||
|
|
||||||
|
|
||||||
actual.flip();
|
|
||||||
expected.flip();
|
expected.flip();
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
||||||
|
@ -292,10 +285,8 @@ public class TestABCase2
|
||||||
WebSocketFrame pActual = capture.getFrames().get(0);
|
WebSocketFrame pActual = capture.getFrames().get(0);
|
||||||
Assert.assertThat("PingFrame.payloadLength",pActual.getPayloadLength(),is(message.length()));
|
Assert.assertThat("PingFrame.payloadLength",pActual.getPayloadLength(),is(message.length()));
|
||||||
Assert.assertEquals("PingFrame.payload",message.length(),pActual.getPayloadLength());
|
Assert.assertEquals("PingFrame.payload",message.length(),pActual.getPayloadLength());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParseOversizedBinaryPingCase2_5()
|
public void testParseOversizedBinaryPingCase2_5()
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,7 +53,6 @@ public class TestABCase7_3
|
||||||
expected.put(new byte[]
|
expected.put(new byte[]
|
||||||
{ (byte)0x88, (byte)0x00 });
|
{ (byte)0x88, (byte)0x00 });
|
||||||
|
|
||||||
actual.flip();
|
|
||||||
expected.flip();
|
expected.flip();
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
||||||
|
@ -128,7 +127,6 @@ public class TestABCase7_3
|
||||||
expected.put(new byte[]
|
expected.put(new byte[]
|
||||||
{ (byte)0x88, (byte)0x02, 0x03, (byte)0xe8 });
|
{ (byte)0x88, (byte)0x02, 0x03, (byte)0xe8 });
|
||||||
|
|
||||||
actual.flip();
|
|
||||||
expected.flip();
|
expected.flip();
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
||||||
|
@ -180,7 +178,6 @@ public class TestABCase7_3
|
||||||
expected.putShort((short)1000);
|
expected.putShort((short)1000);
|
||||||
expected.put(messageBytes);
|
expected.put(messageBytes);
|
||||||
|
|
||||||
actual.flip();
|
|
||||||
expected.flip();
|
expected.flip();
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
||||||
|
@ -244,7 +241,6 @@ public class TestABCase7_3
|
||||||
|
|
||||||
expected.put(messageBytes);
|
expected.put(messageBytes);
|
||||||
|
|
||||||
actual.flip();
|
|
||||||
expected.flip();
|
expected.flip();
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
ByteBufferAssert.assertEquals("buffers do not match",expected,actual);
|
||||||
|
|
|
@ -19,9 +19,6 @@ import java.nio.ByteBuffer;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.eclipse.jetty.websocket.ByteBufferAssert;
|
import org.eclipse.jetty.websocket.ByteBufferAssert;
|
||||||
import org.eclipse.jetty.websocket.protocol.Generator;
|
|
||||||
import org.eclipse.jetty.websocket.protocol.OpCode;
|
|
||||||
import org.eclipse.jetty.websocket.protocol.WebSocketFrame;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class RFC6455ExamplesGeneratorTest
|
public class RFC6455ExamplesGeneratorTest
|
||||||
|
@ -50,9 +47,7 @@ public class RFC6455ExamplesGeneratorTest
|
||||||
{ (byte)0x80, (byte)0x02, (byte)0x6c, (byte)0x6f });
|
{ (byte)0x80, (byte)0x02, (byte)0x6c, (byte)0x6f });
|
||||||
|
|
||||||
expected1.flip();
|
expected1.flip();
|
||||||
actual1.flip();
|
|
||||||
expected2.flip();
|
expected2.flip();
|
||||||
actual2.flip();
|
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("t1 buffers are not equal",expected1,actual1);
|
ByteBufferAssert.assertEquals("t1 buffers are not equal",expected1,actual1);
|
||||||
ByteBufferAssert.assertEquals("t2 buffers are not equal",expected2,actual2);
|
ByteBufferAssert.assertEquals("t2 buffers are not equal",expected2,actual2);
|
||||||
|
@ -69,7 +64,6 @@ public class RFC6455ExamplesGeneratorTest
|
||||||
Generator gen = new UnitGenerator();
|
Generator gen = new UnitGenerator();
|
||||||
|
|
||||||
ByteBuffer actual = gen.generate(pong);
|
ByteBuffer actual = gen.generate(pong);
|
||||||
actual.flip(); // make readable
|
|
||||||
|
|
||||||
ByteBuffer expected = ByteBuffer.allocate(11);
|
ByteBuffer expected = ByteBuffer.allocate(11);
|
||||||
// Raw bytes as found in RFC 6455, Section 5.7 - Examples
|
// Raw bytes as found in RFC 6455, Section 5.7 - Examples
|
||||||
|
@ -89,11 +83,8 @@ public class RFC6455ExamplesGeneratorTest
|
||||||
{ 0x37, (byte)0xfa, 0x21, 0x3d });
|
{ 0x37, (byte)0xfa, 0x21, 0x3d });
|
||||||
|
|
||||||
Generator gen = new UnitGenerator();
|
Generator gen = new UnitGenerator();
|
||||||
;
|
|
||||||
ByteBuffer actual = gen.generate(text);
|
ByteBuffer actual = gen.generate(text);
|
||||||
|
|
||||||
actual.flip(); // make readable
|
|
||||||
|
|
||||||
ByteBuffer expected = ByteBuffer.allocate(11);
|
ByteBuffer expected = ByteBuffer.allocate(11);
|
||||||
// Raw bytes as found in RFC 6455, Section 5.7 - Examples
|
// Raw bytes as found in RFC 6455, Section 5.7 - Examples
|
||||||
// A single-frame masked text message
|
// A single-frame masked text message
|
||||||
|
@ -130,7 +121,6 @@ public class RFC6455ExamplesGeneratorTest
|
||||||
expected.put((byte)0x44);
|
expected.put((byte)0x44);
|
||||||
}
|
}
|
||||||
|
|
||||||
actual.flip();
|
|
||||||
expected.flip();
|
expected.flip();
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("binary buffers are not equal",expected,actual);
|
ByteBufferAssert.assertEquals("binary buffers are not equal",expected,actual);
|
||||||
|
@ -163,7 +153,6 @@ public class RFC6455ExamplesGeneratorTest
|
||||||
expected.put((byte)0x44);
|
expected.put((byte)0x44);
|
||||||
}
|
}
|
||||||
|
|
||||||
actual.flip();
|
|
||||||
expected.flip();
|
expected.flip();
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("binary buffers are not equal",expected,actual);
|
ByteBufferAssert.assertEquals("binary buffers are not equal",expected,actual);
|
||||||
|
@ -176,7 +165,6 @@ public class RFC6455ExamplesGeneratorTest
|
||||||
|
|
||||||
Generator gen = new UnitGenerator();
|
Generator gen = new UnitGenerator();
|
||||||
ByteBuffer actual = gen.generate(ping);
|
ByteBuffer actual = gen.generate(ping);
|
||||||
actual.flip(); // make readable
|
|
||||||
|
|
||||||
ByteBuffer expected = ByteBuffer.allocate(10);
|
ByteBuffer expected = ByteBuffer.allocate(10);
|
||||||
expected.put(new byte[]
|
expected.put(new byte[]
|
||||||
|
@ -201,7 +189,6 @@ public class RFC6455ExamplesGeneratorTest
|
||||||
{ (byte)0x81, (byte)0x05, (byte)0x48, (byte)0x65, (byte)0x6c, (byte)0x6c, (byte)0x6f });
|
{ (byte)0x81, (byte)0x05, (byte)0x48, (byte)0x65, (byte)0x6c, (byte)0x6c, (byte)0x6f });
|
||||||
|
|
||||||
expected.flip();
|
expected.flip();
|
||||||
actual.flip();
|
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals("t1 buffers are not equal",expected,actual);
|
ByteBufferAssert.assertEquals("t1 buffers are not equal",expected,actual);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,6 @@ public class WebSocketFrameTest
|
||||||
|
|
||||||
private void assertEqual(String message, ByteBuffer expected, ByteBuffer actual)
|
private void assertEqual(String message, ByteBuffer expected, ByteBuffer actual)
|
||||||
{
|
{
|
||||||
|
|
||||||
BufferUtil.flipToFlush(actual,0);
|
|
||||||
BufferUtil.flipToFlush(expected,0);
|
BufferUtil.flipToFlush(expected,0);
|
||||||
|
|
||||||
ByteBufferAssert.assertEquals(message,expected,actual);
|
ByteBufferAssert.assertEquals(message,expected,actual);
|
||||||
|
|
Loading…
Reference in New Issue