Skip to content

Commit

Permalink
fix ci.
Browse files Browse the repository at this point in the history
  • Loading branch information
horizonzy committed Jul 13, 2024
1 parent 1359c82 commit 2934bc6
Showing 1 changed file with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.doNothing;
import static org.powermock.api.mockito.PowerMockito.mockStatic;
import static org.powermock.api.mockito.PowerMockito.verifyStatic;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
Expand All @@ -40,15 +38,12 @@
import org.apache.bookkeeper.common.allocator.PoolingPolicy;
import org.apache.bookkeeper.common.util.ShutdownUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.mockito.MockedStatic;
import org.mockito.Mockito;

/**
* Tests for {@link ByteBufAllocatorBuilderImpl}.
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest(ShutdownUtil.class)
public class ByteBufAllocatorBuilderTest {

private static final OutOfMemoryError outOfDirectMemException;
Expand Down Expand Up @@ -106,10 +101,8 @@ public void testOomExit() {
.outOfMemoryPolicy(OutOfMemoryPolicy.ThrowException)
.exitOnOutOfMemory(true)
.build();

mockStatic(ShutdownUtil.class);
doNothing().when(ShutdownUtil.class);
ShutdownUtil.triggerImmediateForcefulShutdown();

MockedStatic<ShutdownUtil> mockedStatic = mockStatic(ShutdownUtil.class);

try {
alloc.buffer();
Expand All @@ -118,9 +111,8 @@ public void testOomExit() {
// Expected
assertEquals(outOfDirectMemException, e);
}

verifyStatic(ShutdownUtil.class);
ShutdownUtil.triggerImmediateForcefulShutdown();

mockedStatic.verify(() -> ShutdownUtil.triggerImmediateForcefulShutdown(), Mockito.times(1));
}

@Test
Expand Down

0 comments on commit 2934bc6

Please sign in to comment.