diff --git a/codec/src/test/java/io/netty/handler/codec/bytes/ByteArrayEncoderTest.java b/codec/src/test/java/io/netty/handler/codec/bytes/ByteArrayEncoderTest.java index 987f876899..bf76071e69 100644 --- a/codec/src/test/java/io/netty/handler/codec/bytes/ByteArrayEncoderTest.java +++ b/codec/src/test/java/io/netty/handler/codec/bytes/ByteArrayEncoderTest.java @@ -18,16 +18,16 @@ package io.netty.handler.codec.bytes; import io.netty.buffer.ByteBuf; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.util.internal.EmptyArrays; +import org.junit.After; import org.junit.Before; import org.junit.Test; import java.util.Random; import static io.netty.buffer.Unpooled.*; -import static org.hamcrest.core.Is.*; +import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; -@SuppressWarnings("ZeroLengthArrayAllocation") public class ByteArrayEncoderTest { private EmbeddedChannel ch; @@ -37,18 +37,25 @@ public class ByteArrayEncoderTest { ch = new EmbeddedChannel(new ByteArrayEncoder()); } + @After + public void tearDown() { + assertThat(ch.finish(), is(false)); + } + @Test public void testEncode() { byte[] b = new byte[2048]; new Random().nextBytes(b); ch.writeOutbound(b); - assertThat((ByteBuf) ch.readOutbound(), is(wrappedBuffer(b))); + ByteBuf encoded = ch.readOutbound(); + assertThat(encoded, is(wrappedBuffer(b))); + encoded.release(); } @Test public void testEncodeEmpty() { ch.writeOutbound(EmptyArrays.EMPTY_BYTES); - assertThat((ByteBuf) ch.readOutbound(), is(EMPTY_BUFFER)); + assertThat((ByteBuf) ch.readOutbound(), is(sameInstance(EMPTY_BUFFER))); } @Test