diff --git a/codec-memcache/src/test/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheDecoderTest.java b/codec-memcache/src/test/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheDecoderTest.java index 0dad98967a..72216689b8 100644 --- a/codec-memcache/src/test/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheDecoderTest.java +++ b/codec-memcache/src/test/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheDecoderTest.java @@ -76,7 +76,7 @@ public class BinaryMemcacheDecoderTest { @After public void teardown() throws Exception { - channel.finish(); + channel.finishAndReleaseAll(); } /** @@ -150,6 +150,7 @@ public class BinaryMemcacheDecoderTest { while (incoming.isReadable()) { channel.writeInbound(incoming.readBytes(5)); } + incoming.release(); BinaryMemcacheRequest request = channel.readInbound(); @@ -261,8 +262,13 @@ public class BinaryMemcacheDecoderTest { BinaryMemcacheRequest request = new DefaultBinaryMemcacheRequest(key, extras); assertTrue(channel.writeOutbound(request)); - assertTrue(channel.writeInbound(channel.outboundMessages().toArray())); - + for (;;) { + ByteBuf buffer = channel.readOutbound(); + if (buffer == null) { + break; + } + channel.writeInbound(buffer); + } BinaryMemcacheRequest read = channel.readInbound(); read.release(); // tearDown will call "channel.finish()" diff --git a/codec-memcache/src/test/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheEncoderTest.java b/codec-memcache/src/test/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheEncoderTest.java index 52d1ec1dec..04b2781ccd 100644 --- a/codec-memcache/src/test/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheEncoderTest.java +++ b/codec-memcache/src/test/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheEncoderTest.java @@ -46,7 +46,7 @@ public class BinaryMemcacheEncoderTest { @After public void teardown() throws Exception { - channel.finish(); + channel.finishAndReleaseAll(); } @Test @@ -92,8 +92,8 @@ public class BinaryMemcacheEncoderTest { ByteBuf written = channel.readOutbound(); assertThat(written.readableBytes(), is(DEFAULT_HEADER_SIZE + extrasLength)); - written.readBytes(DEFAULT_HEADER_SIZE); - assertThat(written.readBytes(extrasLength).toString(CharsetUtil.UTF_8), equalTo(extrasContent)); + written.skipBytes(DEFAULT_HEADER_SIZE); + assertThat(written.readSlice(extrasLength).toString(CharsetUtil.UTF_8), equalTo(extrasContent)); written.release(); } @@ -109,8 +109,8 @@ public class BinaryMemcacheEncoderTest { ByteBuf written = channel.readOutbound(); assertThat(written.readableBytes(), is(DEFAULT_HEADER_SIZE + keyLength)); - written.readBytes(DEFAULT_HEADER_SIZE); - assertThat(written.readBytes(keyLength).toString(CharsetUtil.UTF_8), equalTo("netty")); + written.skipBytes(DEFAULT_HEADER_SIZE); + assertThat(written.readSlice(keyLength).toString(CharsetUtil.UTF_8), equalTo("netty")); written.release(); } @@ -139,7 +139,7 @@ public class BinaryMemcacheEncoderTest { written = channel.readOutbound(); assertThat(written.readableBytes(), is(content1.content().readableBytes())); assertThat( - written.readBytes(content1.content().readableBytes()).toString(CharsetUtil.UTF_8), + written.readSlice(content1.content().readableBytes()).toString(CharsetUtil.UTF_8), is("Netty") ); written.release(); @@ -147,7 +147,7 @@ public class BinaryMemcacheEncoderTest { written = channel.readOutbound(); assertThat(written.readableBytes(), is(content2.content().readableBytes())); assertThat( - written.readBytes(content2.content().readableBytes()).toString(CharsetUtil.UTF_8), + written.readSlice(content2.content().readableBytes()).toString(CharsetUtil.UTF_8), is(" Rocks!") ); written.release(); diff --git a/codec-memcache/src/test/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheObjectAggregatorTest.java b/codec-memcache/src/test/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheObjectAggregatorTest.java index 01de9f01e9..a32790a762 100644 --- a/codec-memcache/src/test/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheObjectAggregatorTest.java +++ b/codec-memcache/src/test/java/io/netty/handler/codec/memcache/binary/BinaryMemcacheObjectAggregatorTest.java @@ -76,7 +76,7 @@ public class BinaryMemcacheObjectAggregatorTest { assertThat(channel.readInbound(), nullValue()); - channel.finish(); + assertFalse(channel.finish()); } @Test diff --git a/codec-stomp/src/test/java/io/netty/handler/codec/stomp/StompSubframeEncoderTest.java b/codec-stomp/src/test/java/io/netty/handler/codec/stomp/StompSubframeEncoderTest.java index 1407e8c0c9..939f8b45ff 100644 --- a/codec-stomp/src/test/java/io/netty/handler/codec/stomp/StompSubframeEncoderTest.java +++ b/codec-stomp/src/test/java/io/netty/handler/codec/stomp/StompSubframeEncoderTest.java @@ -51,12 +51,16 @@ public class StompSubframeEncoderTest { ByteBuf byteBuf = channel.readOutbound(); assertNotNull(byteBuf); aggregatedBuffer.writeBytes(byteBuf); + byteBuf.release(); byteBuf = channel.readOutbound(); assertNotNull(byteBuf); aggregatedBuffer.writeBytes(byteBuf); + byteBuf.release(); + aggregatedBuffer.resetReaderIndex(); String content = aggregatedBuffer.toString(CharsetUtil.UTF_8); assertEquals(StompTestConstants.CONNECT_FRAME, content); + aggregatedBuffer.release(); } }