diff --git a/buffer/src/test/java/io/netty/buffer/AbstractCompositeChannelBufferTest.java b/buffer/src/test/java/io/netty/buffer/AbstractCompositeChannelBufferTest.java index 2d68c5cd1d..97bc1f8b8b 100644 --- a/buffer/src/test/java/io/netty/buffer/AbstractCompositeChannelBufferTest.java +++ b/buffer/src/test/java/io/netty/buffer/AbstractCompositeChannelBufferTest.java @@ -16,6 +16,7 @@ package io.netty.buffer; import static io.netty.buffer.Unpooled.*; +import java.io.IOException; import static org.junit.Assert.*; import java.nio.ByteBuffer; @@ -89,6 +90,25 @@ public abstract class AbstractCompositeChannelBufferTest extends protected boolean discardReadBytesDoesNotMoveWritableBytes() { return false; } + + /** + * Tests the "getBufferFor" method + */ + @Test + public void testGetBufferFor() throws IOException { + CompositeByteBuf buf = (CompositeByteBuf) Unpooled.wrappedBuffer(new byte[] { 1, 2, 3, 4, 5 }, new byte[] {4, 5, 6, 7, 8, 9, 26}); + + //Ensure that a random place will be fine + assertEquals(buf.getBufferFor(2).capacity(), 5); + + //Loop through each byte + + byte index = 0; + + while (index < buf.capacity()) { + assertNotNull(buf.getBufferFor(index++)); + } + } @Test public void testDiscardReadBytes3() {