Add tests to try to track down some buffer issues
This commit is contained in:
parent
70f5a4e2ce
commit
60b06df84f
@ -1720,4 +1720,32 @@ public abstract class AbstractByteBufTest {
|
||||
|
||||
assertThat(lastIndex.get(), is(CAPACITY / 4));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInternalNioBuffer() {
|
||||
testInternalNioBuffer(128);
|
||||
testInternalNioBuffer(1024);
|
||||
testInternalNioBuffer(4 * 1024);
|
||||
testInternalNioBuffer(64 * 1024);
|
||||
testInternalNioBuffer(32 * 1024 * 1024);
|
||||
testInternalNioBuffer(64 * 1024 * 1024);
|
||||
}
|
||||
|
||||
private void testInternalNioBuffer(int a) {
|
||||
ByteBuf buffer = freeLater(newBuffer(2));
|
||||
ByteBuffer buf = buffer.internalNioBuffer(0, 1);
|
||||
assertEquals(1, buf.remaining());
|
||||
|
||||
for (int i = 0; i < a; i++) {
|
||||
buffer.writeByte(i);
|
||||
}
|
||||
|
||||
buf = buffer.internalNioBuffer(0, a);
|
||||
assertEquals(a, buf.remaining());
|
||||
|
||||
for (int i = 0; i < a; i++) {
|
||||
assertEquals((byte) i, buf.get());
|
||||
}
|
||||
assertFalse(buf.hasRemaining());
|
||||
}
|
||||
}
|
||||
|
@ -566,4 +566,10 @@ public abstract class AbstractCompositeByteBufTest extends AbstractByteBufTest {
|
||||
assertEquals(0, buf.numComponents());
|
||||
assertEquals(0, freeLater(buf.duplicate()).readableBytes());
|
||||
}
|
||||
|
||||
@Test(expected = UnsupportedOperationException.class)
|
||||
@Override
|
||||
public void testInternalNioBuffer() {
|
||||
super.testInternalNioBuffer();
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
package io.netty.buffer;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
@ -42,4 +43,13 @@ public class DuplicateByteBufTest extends AbstractByteBufTest {
|
||||
public void shouldNotAllowNullInConstructor() {
|
||||
new DuplicatedByteBuf(null);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
// Test which shows bug
|
||||
// https://github.com/netty/netty/issues/1802
|
||||
public void testInternalNioBuffer() {
|
||||
super.testInternalNioBuffer();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -46,4 +46,10 @@ public class SlicedByteBufTest extends AbstractByteBufTest {
|
||||
public void shouldNotAllowNullInConstructor() {
|
||||
new SlicedByteBuf(null, 0, 0);
|
||||
}
|
||||
|
||||
@Test(expected = IndexOutOfBoundsException.class)
|
||||
@Override
|
||||
public void testInternalNioBuffer() {
|
||||
super.testInternalNioBuffer();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user