Ensure tests pass when sun.misc.Unsafe is not present
Motivation: We need to ensure we pass all tests when sun.misc.Unsafe is not present. Modifications: - Make *ByteBufAllocatorTest work whenever sun.misc.Unsafe is present or not Result: Tests pass even without sun.misc.Unsafe.
This commit is contained in:
parent
2d558b3c2b
commit
73af7c9215
@ -15,11 +15,18 @@
|
||||
*/
|
||||
package io.netty.buffer;
|
||||
|
||||
import io.netty.util.internal.PlatformDependent;
|
||||
|
||||
public abstract class AbstractByteBufAllocatorTest extends ByteBufAllocatorTest {
|
||||
|
||||
@Override
|
||||
protected abstract AbstractByteBufAllocator newAllocator(boolean preferDirect);
|
||||
|
||||
@Override
|
||||
protected boolean isDirectExpected(boolean preferDirect) {
|
||||
return preferDirect && PlatformDependent.hasUnsafe();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final int defaultMaxCapacity() {
|
||||
return AbstractByteBufAllocator.DEFAULT_MAX_CAPACITY;
|
||||
|
@ -37,7 +37,7 @@ public abstract class ByteBufAllocatorTest {
|
||||
ByteBufAllocator allocator = newAllocator(preferDirect);
|
||||
ByteBuf buffer = allocator.buffer(1);
|
||||
try {
|
||||
assertBuffer(buffer, preferDirect, 1, defaultMaxCapacity());
|
||||
assertBuffer(buffer, isDirectExpected(preferDirect), 1, defaultMaxCapacity());
|
||||
} finally {
|
||||
buffer.release();
|
||||
}
|
||||
@ -53,12 +53,14 @@ public abstract class ByteBufAllocatorTest {
|
||||
ByteBufAllocator allocator = newAllocator(preferDirect);
|
||||
ByteBuf buffer = allocator.buffer(1, maxCapacity);
|
||||
try {
|
||||
assertBuffer(buffer, preferDirect, 1, maxCapacity);
|
||||
assertBuffer(buffer, isDirectExpected(preferDirect), 1, maxCapacity);
|
||||
} finally {
|
||||
buffer.release();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract boolean isDirectExpected(boolean preferDirect);
|
||||
|
||||
@Test
|
||||
public void testHeapBuffer() {
|
||||
testHeapBuffer(true);
|
||||
|
Loading…
Reference in New Issue
Block a user