|
Expand Up
|
@@ -21,10 +21,13 @@ |
|
|
import org.junit.jupiter.api.RepeatedTest; |
|
|
import org.junit.jupiter.api.RepetitionInfo; |
|
|
import org.junit.jupiter.api.Test; |
|
|
import org.junit.jupiter.api.function.Executable; |
|
|
import org.junit.jupiter.params.ParameterizedTest; |
|
|
import org.junit.jupiter.params.provider.ValueSource; |
|
|
|
|
|
import java.io.IOException; |
|
|
import java.lang.reflect.Array; |
|
|
import java.nio.channels.FileChannel; |
|
|
import java.util.ArrayDeque; |
|
|
import java.util.ArrayList; |
|
|
import java.util.Deque; |
|
Expand All
|
@@ -37,8 +40,10 @@ |
|
|
import static org.junit.jupiter.api.Assertions.assertEquals; |
|
|
import static org.junit.jupiter.api.Assertions.assertFalse; |
|
|
import static org.junit.jupiter.api.Assertions.assertNull; |
|
|
import static org.junit.jupiter.api.Assertions.assertThrows; |
|
|
import static org.junit.jupiter.api.Assertions.assertTrue; |
|
|
import static org.junit.jupiter.api.Assertions.fail; |
|
|
import io.netty.buffer.AbstractByteBufTest.TestGatheringByteChannel; |
|
|
|
|
|
public class AdaptiveByteBufAllocatorTest extends AbstractByteBufAllocatorTest<AdaptiveByteBufAllocator> { |
|
|
@Override |
|
Expand Down
Expand Up
|
@@ -146,6 +151,42 @@ void adaptiveChunkMustDeallocateOrReuseWthBufferRelease() throws Exception { |
|
|
} |
|
|
} |
|
|
|
|
|
@Test |
|
|
public void getBytesBoundaryCheckWithFileChannel() { |
|
|
AdaptiveByteBufAllocator allocator = newAllocator(false); |
|
|
final ByteBuf buf = allocator.directBuffer(7); |
|
|
try { |
|
|
assertThrows(IndexOutOfBoundsException.class, new Executable() { |
|
|
@Override |
|
|
public void execute() throws IOException { |
|
|
// capacity 7,4+8=12 <= maxFastCapacity 32 |
|
|
buf.getBytes(4, (FileChannel) null, 0L, 8); |
|
|
} |
|
|
}); |
|
|
} finally { |
|
|
buf.release(); |
|
|
} |
|
|
} |
|
|
|
|
|
@Test |
|
|
public void testGetBytesBoundaryCheckWithGatheringByteChannel() throws Exception { |
|
|
AdaptiveByteBufAllocator allocator = newAllocator(false); |
|
|
final TestGatheringByteChannel channel = new TestGatheringByteChannel(); |
|
|
final ByteBuf buf = allocator.directBuffer(7); |
|
|
try { |
|
|
assertThrows(IndexOutOfBoundsException.class, new Executable() { |
|
|
@Override |
|
|
public void execute() throws IOException { |
|
|
// capacity 7,4+8=12 <= maxFastCapacity 32 |
|
|
buf.getBytes(4, channel, 8); |
|
|
} |
|
|
}); |
|
|
} finally { |
|
|
channel.close(); |
|
|
buf.release(); |
|
|
} |
|
|
} |
|
|
|
|
|
@ParameterizedTest |
|
|
@ValueSource(booleans = { true, false }) |
|
|
void sliceOrDuplicateUnwrapLetNotEscapeRootParent(boolean slice) { |
|
Expand Down
|
|