From f8e72803a669bed782d8aca4310918b072c28d73 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Wed, 18 Jul 2012 12:22:16 -0700 Subject: [PATCH] Fixing expectations in unit tests --- .../eclipse/jetty/websocket/ab/TestABCase1_1.java | 14 -------------- .../eclipse/jetty/websocket/ab/TestABCase1_2.java | 13 ------------- .../eclipse/jetty/websocket/ab/TestABCase2.java | 9 --------- .../eclipse/jetty/websocket/ab/TestABCase7_3.java | 4 ---- .../protocol/RFC6455ExamplesGeneratorTest.java | 13 ------------- .../websocket/protocol/WebSocketFrameTest.java | 2 -- 6 files changed, 55 deletions(-) diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/TestABCase1_1.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/TestABCase1_1.java index 5a20abf89aa..9fa6278bda4 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/TestABCase1_1.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/TestABCase1_1.java @@ -69,11 +69,9 @@ public class TestABCase1_1 expected.put("*".getBytes()); } - actual.flip(); expected.flip(); ByteBufferAssert.assertEquals("buffers do not match",expected,actual); - } @Test @@ -111,11 +109,9 @@ public class TestABCase1_1 expected.put("*".getBytes()); } - actual.flip(); expected.flip(); ByteBufferAssert.assertEquals("buffers do not match",expected,actual); - } @Test @@ -153,11 +149,9 @@ public class TestABCase1_1 expected.put("*".getBytes()); } - actual.flip(); expected.flip(); ByteBufferAssert.assertEquals("buffers do not match",expected,actual); - } @Test @@ -195,11 +189,9 @@ public class TestABCase1_1 expected.put("*".getBytes()); } - actual.flip(); expected.flip(); ByteBufferAssert.assertEquals("buffers do not match",expected,actual); - } @Test @@ -236,11 +228,9 @@ public class TestABCase1_1 expected.put("*".getBytes()); } - actual.flip(); expected.flip(); ByteBufferAssert.assertEquals("buffers do not match",expected,actual); - } @Test @@ -276,11 +266,9 @@ public class TestABCase1_1 expected.put("*".getBytes()); } - actual.flip(); expected.flip(); ByteBufferAssert.assertEquals("buffers do not match",expected,actual); - } @Test @@ -296,11 +284,9 @@ public class TestABCase1_1 expected.put(new byte[] { (byte)0x81, (byte)0x00 }); - actual.flip(); expected.flip(); ByteBufferAssert.assertEquals("buffers do not match",expected,actual); - } @Test diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/TestABCase1_2.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/TestABCase1_2.java index ce2cf252370..6b106cd4c66 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/TestABCase1_2.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/TestABCase1_2.java @@ -73,11 +73,9 @@ public class TestABCase1_2 expected.put("*".getBytes()); } - BufferUtil.flipToFlush(actual,0); BufferUtil.flipToFlush(expected,0); ByteBufferAssert.assertEquals("buffers do not match",expected,actual); - } @Test @@ -117,11 +115,9 @@ public class TestABCase1_2 expected.put("*".getBytes()); } - BufferUtil.flipToFlush(actual,0); BufferUtil.flipToFlush(expected,0); ByteBufferAssert.assertEquals("buffers do not match",expected,actual); - } @Test @@ -162,11 +158,9 @@ public class TestABCase1_2 expected.put("*".getBytes()); } - BufferUtil.flipToFlush(actual,0); BufferUtil.flipToFlush(expected,0); ByteBufferAssert.assertEquals("buffers do not match",expected,actual); - } @Test @@ -206,7 +200,6 @@ public class TestABCase1_2 expected.put("*".getBytes()); } - BufferUtil.flipToFlush(actual,0); BufferUtil.flipToFlush(expected,0); ByteBufferAssert.assertEquals("buffers do not match",expected,actual); @@ -248,11 +241,9 @@ public class TestABCase1_2 expected.put("*".getBytes()); } - BufferUtil.flipToFlush(actual,0); BufferUtil.flipToFlush(expected,0); ByteBufferAssert.assertEquals("buffers do not match",expected,actual); - } @Test @@ -291,11 +282,9 @@ public class TestABCase1_2 expected.put("*".getBytes()); } - BufferUtil.flipToFlush(actual,0); BufferUtil.flipToFlush(expected,0); ByteBufferAssert.assertEquals("buffers do not match",expected,actual); - } @Test @@ -311,11 +300,9 @@ public class TestABCase1_2 expected.put(new byte[] { (byte)0x82, (byte)0x00 }); - BufferUtil.flipToFlush(actual,0); BufferUtil.flipToFlush(expected,0); ByteBufferAssert.assertEquals("buffers do not match",expected,actual); - } @Test diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/TestABCase2.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/TestABCase2.java index ad068f43394..b5242b650ed 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/TestABCase2.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/TestABCase2.java @@ -63,8 +63,6 @@ public class TestABCase2 expected.put(b); expected.put(bytes); - - actual.flip(); expected.flip(); ByteBufferAssert.assertEquals("buffers do not match",expected,actual); @@ -90,8 +88,6 @@ public class TestABCase2 expected.put(b); expected.put(bytes); - - actual.flip(); expected.flip(); ByteBufferAssert.assertEquals("buffers do not match",expected,actual); @@ -112,7 +108,6 @@ public class TestABCase2 expected.put(new byte[] { (byte)0x89, (byte)0x00 }); - actual.flip(); expected.flip(); ByteBufferAssert.assertEquals("buffers do not match",expected,actual); @@ -139,8 +134,6 @@ public class TestABCase2 expected.put(b); expected.put(messageBytes); - - actual.flip(); expected.flip(); ByteBufferAssert.assertEquals("buffers do not match",expected,actual); @@ -292,10 +285,8 @@ public class TestABCase2 WebSocketFrame pActual = capture.getFrames().get(0); Assert.assertThat("PingFrame.payloadLength",pActual.getPayloadLength(),is(message.length())); Assert.assertEquals("PingFrame.payload",message.length(),pActual.getPayloadLength()); - } - @Test public void testParseOversizedBinaryPingCase2_5() { diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/TestABCase7_3.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/TestABCase7_3.java index caa36352045..c8bf57ff41b 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/TestABCase7_3.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/ab/TestABCase7_3.java @@ -53,7 +53,6 @@ public class TestABCase7_3 expected.put(new byte[] { (byte)0x88, (byte)0x00 }); - actual.flip(); expected.flip(); ByteBufferAssert.assertEquals("buffers do not match",expected,actual); @@ -128,7 +127,6 @@ public class TestABCase7_3 expected.put(new byte[] { (byte)0x88, (byte)0x02, 0x03, (byte)0xe8 }); - actual.flip(); expected.flip(); ByteBufferAssert.assertEquals("buffers do not match",expected,actual); @@ -180,7 +178,6 @@ public class TestABCase7_3 expected.putShort((short)1000); expected.put(messageBytes); - actual.flip(); expected.flip(); ByteBufferAssert.assertEquals("buffers do not match",expected,actual); @@ -244,7 +241,6 @@ public class TestABCase7_3 expected.put(messageBytes); - actual.flip(); expected.flip(); ByteBufferAssert.assertEquals("buffers do not match",expected,actual); diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/protocol/RFC6455ExamplesGeneratorTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/protocol/RFC6455ExamplesGeneratorTest.java index acd5a82323d..d2b67f50c7d 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/protocol/RFC6455ExamplesGeneratorTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/protocol/RFC6455ExamplesGeneratorTest.java @@ -19,9 +19,6 @@ import java.nio.ByteBuffer; import java.util.Arrays; 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; public class RFC6455ExamplesGeneratorTest @@ -50,9 +47,7 @@ public class RFC6455ExamplesGeneratorTest { (byte)0x80, (byte)0x02, (byte)0x6c, (byte)0x6f }); expected1.flip(); - actual1.flip(); expected2.flip(); - actual2.flip(); ByteBufferAssert.assertEquals("t1 buffers are not equal",expected1,actual1); ByteBufferAssert.assertEquals("t2 buffers are not equal",expected2,actual2); @@ -69,7 +64,6 @@ public class RFC6455ExamplesGeneratorTest Generator gen = new UnitGenerator(); ByteBuffer actual = gen.generate(pong); - actual.flip(); // make readable ByteBuffer expected = ByteBuffer.allocate(11); // Raw bytes as found in RFC 6455, Section 5.7 - Examples @@ -89,11 +83,8 @@ public class RFC6455ExamplesGeneratorTest { 0x37, (byte)0xfa, 0x21, 0x3d }); Generator gen = new UnitGenerator(); - ; ByteBuffer actual = gen.generate(text); - actual.flip(); // make readable - ByteBuffer expected = ByteBuffer.allocate(11); // Raw bytes as found in RFC 6455, Section 5.7 - Examples // A single-frame masked text message @@ -130,7 +121,6 @@ public class RFC6455ExamplesGeneratorTest expected.put((byte)0x44); } - actual.flip(); expected.flip(); ByteBufferAssert.assertEquals("binary buffers are not equal",expected,actual); @@ -163,7 +153,6 @@ public class RFC6455ExamplesGeneratorTest expected.put((byte)0x44); } - actual.flip(); expected.flip(); ByteBufferAssert.assertEquals("binary buffers are not equal",expected,actual); @@ -176,7 +165,6 @@ public class RFC6455ExamplesGeneratorTest Generator gen = new UnitGenerator(); ByteBuffer actual = gen.generate(ping); - actual.flip(); // make readable ByteBuffer expected = ByteBuffer.allocate(10); 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 }); expected.flip(); - actual.flip(); ByteBufferAssert.assertEquals("t1 buffers are not equal",expected,actual); } diff --git a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/protocol/WebSocketFrameTest.java b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/protocol/WebSocketFrameTest.java index f4bcffb481b..19d46f45990 100644 --- a/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/protocol/WebSocketFrameTest.java +++ b/jetty-websocket/websocket-core/src/test/java/org/eclipse/jetty/websocket/protocol/WebSocketFrameTest.java @@ -42,8 +42,6 @@ public class WebSocketFrameTest private void assertEqual(String message, ByteBuffer expected, ByteBuffer actual) { - - BufferUtil.flipToFlush(actual,0); BufferUtil.flipToFlush(expected,0); ByteBufferAssert.assertEquals(message,expected,actual);