Skip to content

Commit 7968110

Browse files
committed
[Test] migrate-junit5-client-module
1 parent f148f63 commit 7968110

18 files changed

+972
-761
lines changed

bookkeeper-server/src/test/java/org/apache/bookkeeper/client/ConcurrentV2RecoveryTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
*/
2121
package org.apache.bookkeeper.client;
2222

23+
import static org.junit.jupiter.api.Assertions.assertEquals;
24+
2325
import java.util.ArrayList;
2426
import java.util.List;
2527
import java.util.concurrent.CompletableFuture;
@@ -33,8 +35,7 @@
3335
import org.apache.bookkeeper.conf.ClientConfiguration;
3436
import org.apache.bookkeeper.meta.HierarchicalLedgerManagerFactory;
3537
import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
36-
import org.junit.Assert;
37-
import org.junit.Test;
38+
import org.junit.jupiter.api.Test;
3839
import org.slf4j.Logger;
3940
import org.slf4j.LoggerFactory;
4041

@@ -51,7 +52,7 @@ public ConcurrentV2RecoveryTest() {
5152
}
5253

5354
@Test
54-
public void testConcurrentOpen() throws Exception {
55+
void concurrentOpen() throws Exception {
5556
ClientConfiguration conf = new ClientConfiguration();
5657
conf.setMetadataServiceUri(zkUtil.getMetadataServiceUri())
5758
.setNumChannelsPerBookie(16)
@@ -101,7 +102,7 @@ public void testConcurrentOpen() throws Exception {
101102
// also fine, recovery can currently fail because of metadata conflicts.
102103
// We should fix this at some point by making the metadata immutable,
103104
// and restarting the entire operation
104-
Assert.assertEquals(ee.getCause().getClass(), BKException.BKLedgerRecoveryException.class);
105+
assertEquals(BKException.BKLedgerRecoveryException.class, ee.getCause().getClass());
105106
}
106107
}
107108
}

bookkeeper-server/src/test/java/org/apache/bookkeeper/client/DeferredSyncTest.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@
1818
package org.apache.bookkeeper.client;
1919

2020
import static org.apache.bookkeeper.common.concurrent.FutureUtils.result;
21-
import static org.junit.Assert.assertEquals;
22-
import static org.junit.Assert.assertFalse;
23-
import static org.junit.Assert.assertTrue;
24-
import static org.junit.Assert.fail;
21+
import static org.junit.jupiter.api.Assertions.assertEquals;
22+
import static org.junit.jupiter.api.Assertions.assertFalse;
23+
import static org.junit.jupiter.api.Assertions.assertThrows;
24+
import static org.junit.jupiter.api.Assertions.assertTrue;
25+
import static org.junit.jupiter.api.Assertions.fail;
2526

2627
import io.netty.buffer.ByteBuf;
2728
import io.netty.buffer.Unpooled;
@@ -30,7 +31,7 @@
3031
import org.apache.bookkeeper.client.api.WriteFlag;
3132
import org.apache.bookkeeper.client.api.WriteHandle;
3233
import org.apache.bookkeeper.net.BookieId;
33-
import org.junit.Test;
34+
import org.junit.jupiter.api.Test;
3435

3536
/**
3637
* Client side tests on deferred sync write flag.
@@ -42,7 +43,7 @@ public class DeferredSyncTest extends MockBookKeeperTestCase {
4243
static final int NUM_ENTRIES = 100;
4344

4445
@Test
45-
public void testAddEntryLastAddConfirmedDoesNotAdvance() throws Exception {
46+
void addEntryLastAddConfirmedDoesNotAdvance() throws Exception {
4647
try (WriteHandle wh = result(newCreateLedgerOp()
4748
.withEnsembleSize(3)
4849
.withWriteQuorumSize(3)
@@ -61,7 +62,7 @@ public void testAddEntryLastAddConfirmedDoesNotAdvance() throws Exception {
6162
}
6263

6364
@Test
64-
public void testAddEntryLastAddConfirmedAdvanceWithForce() throws Exception {
65+
void addEntryLastAddConfirmedAdvanceWithForce() throws Exception {
6566
try (WriteHandle wh = result(newCreateLedgerOp()
6667
.withEnsembleSize(3)
6768
.withWriteQuorumSize(3)
@@ -82,7 +83,7 @@ public void testAddEntryLastAddConfirmedAdvanceWithForce() throws Exception {
8283
}
8384

8485
@Test
85-
public void testForceOnWriteAdvHandle() throws Exception {
86+
void forceOnWriteAdvHandle() throws Exception {
8687
try (WriteAdvHandle wh = result(newCreateLedgerOp()
8788
.withEnsembleSize(3)
8889
.withWriteQuorumSize(3)
@@ -112,7 +113,7 @@ public void testForceOnWriteAdvHandle() throws Exception {
112113
}
113114

114115
@Test
115-
public void testForceRequiresFullEnsemble() throws Exception {
116+
void forceRequiresFullEnsemble() throws Exception {
116117
try (WriteHandle wh = result(newCreateLedgerOp()
117118
.withEnsembleSize(3)
118119
.withWriteQuorumSize(2)
@@ -146,7 +147,7 @@ public void testForceRequiresFullEnsemble() throws Exception {
146147
}
147148

148149
@Test
149-
public void testForceWillAdvanceLacOnlyUpToLastAcknowledgedWrite() throws Exception {
150+
void forceWillAdvanceLacOnlyUpToLastAcknowledgedWrite() throws Exception {
150151
try (WriteHandle wh = result(newCreateLedgerOp()
151152
.withEnsembleSize(3)
152153
.withWriteQuorumSize(3)
@@ -187,7 +188,7 @@ public void testForceWillAdvanceLacOnlyUpToLastAcknowledgedWrite() throws Except
187188
}
188189

189190
@Test
190-
public void testForbiddenEnsembleChange() throws Exception {
191+
void forbiddenEnsembleChange() throws Exception {
191192
try (WriteHandle wh = result(newCreateLedgerOp()
192193
.withEnsembleSize(1)
193194
.withWriteQuorumSize(1)
@@ -218,8 +219,8 @@ public void testForbiddenEnsembleChange() throws Exception {
218219
}
219220
}
220221

221-
@Test(expected = BKException.BKLedgerClosedException.class)
222-
public void testCannotIssueForceOnClosedLedgerHandle() throws Exception {
222+
@Test
223+
void cannotIssueForceOnClosedLedgerHandle() throws Exception {
223224
WriteHandle wh = result(newCreateLedgerOp()
224225
.withEnsembleSize(1)
225226
.withWriteQuorumSize(1)
@@ -228,7 +229,8 @@ public void testCannotIssueForceOnClosedLedgerHandle() throws Exception {
228229
.withWriteFlags(WriteFlag.DEFERRED_SYNC)
229230
.execute());
230231
wh.close();
231-
result(wh.force());
232+
assertThrows(BKException.BKLedgerClosedException.class, () ->
233+
result(wh.force()));
232234
}
233235

234236
}

0 commit comments

Comments
 (0)