-
Notifications
You must be signed in to change notification settings - Fork 894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: migrate client module api tests to junit 5 #4377
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,8 @@ | |
import org.apache.bookkeeper.versioning.Versioned; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.mockito.invocation.InvocationOnMock; | ||
import org.mockito.stubbing.Answer; | ||
import org.mockito.stubbing.Stubber; | ||
|
@@ -141,6 +143,7 @@ public MockEntry(byte[] payload, long lastAddConfirmed) { | |
|
||
} | ||
|
||
@BeforeEach | ||
@Before | ||
public void setup() throws Exception { | ||
maxNumberOfAvailableBookies = Integer.MAX_VALUE; | ||
|
@@ -264,6 +267,7 @@ private DigestManager getDigestType(long ledgerId) throws GeneralSecurityExcepti | |
UnpooledByteBufAllocator.DEFAULT, false); | ||
} | ||
|
||
@AfterEach | ||
@After | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about add some todo here: |
||
public void tearDown() { | ||
scheduler.shutdown(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,14 +38,12 @@ | |
import org.apache.bookkeeper.net.BookieId; | ||
import org.apache.bookkeeper.proto.BookieProtocol; | ||
import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Parameterized; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
/** | ||
* Tests for BookKeeper open ledger operations. | ||
*/ | ||
@RunWith(Parameterized.class) | ||
public class BookKeeperBuildersOpenLedgerTest extends MockBookKeeperTestCase { | ||
|
||
private static final int ensembleSize = 3; | ||
|
@@ -58,20 +56,20 @@ public class BookKeeperBuildersOpenLedgerTest extends MockBookKeeperTestCase { | |
|
||
private boolean withRecovery; | ||
|
||
public BookKeeperBuildersOpenLedgerTest(boolean withRecovery) { | ||
public void initBookKeeperBuildersOpenLedgerTest(boolean withRecovery) { | ||
this.withRecovery = withRecovery; | ||
} | ||
|
||
@Parameterized.Parameters(name = "withRecovery:({0})") | ||
public static Collection<Object[]> data() { | ||
return Arrays.asList(new Object[][]{ | ||
{true}, | ||
{false} | ||
}); | ||
} | ||
|
||
@Test | ||
public void testOpenLedger() throws Exception { | ||
@MethodSource("data") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In junit5, it's better to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @lhotari Thanks,It's a better choice. |
||
@ParameterizedTest(name = "withRecovery:({0})") | ||
public void testOpenLedger(boolean withRecovery) throws Exception { | ||
LedgerMetadata ledgerMetadata = generateLedgerMetadata(ensembleSize, | ||
writeQuorumSize, ackQuorumSize, password, customMetadata); | ||
registerMockLedgerMetadata(ledgerId, ledgerMetadata); | ||
|
@@ -91,8 +89,9 @@ public void testOpenLedger() throws Exception { | |
.execute()); | ||
} | ||
|
||
@Test | ||
public void testOpenLedgerWithTimeoutEx() throws Exception { | ||
@MethodSource("data") | ||
@ParameterizedTest(name = "withRecovery:({0})") | ||
public void testOpenLedgerWithTimeoutEx(boolean withRecovery) throws Exception { | ||
mockReadEntryTimeout(); | ||
LedgerMetadata ledgerMetadata = generateLedgerMetadata(ensembleSize, | ||
writeQuorumSize, ackQuorumSize, password, customMetadata); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about add some todo here:
// TODO: delete @Before when only run with junit5