Skip to content

Commit 5455034

Browse files
committed
fixup! fixup! fixup! [refactor] Migrate from JUnit 4 to JUnit 5
1 parent a596375 commit 5455034

2 files changed

Lines changed: 31 additions & 34 deletions

File tree

java/src/test/java/org/rocksdb/MergeVariantsTest.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,21 @@
1111

1212
import java.nio.ByteBuffer;
1313
import java.nio.charset.StandardCharsets;
14-
import java.util.Arrays;
15-
import java.util.List;
1614
import org.junit.jupiter.api.extension.RegisterExtension;
17-
import org.junit.jupiter.api.Test;
1815
import org.junit.jupiter.params.ParameterizedTest;
1916
import org.junit.jupiter.params.provider.MethodSource;
20-
import org.junit.jupiter.params.provider.Arguments;
2117
import java.util.stream.Stream;
2218
import org.junit.jupiter.api.io.TempDir;
2319
import java.io.File;
20+
2421
public class MergeVariantsTest {
22+
2523
@FunctionalInterface
2624
interface FunctionMerge<PDatabase, PLeft, PRight> {
27-
public void apply(PDatabase db, PLeft two, PRight three) throws RocksDBException;
25+
void apply(PDatabase db, PLeft two, PRight three) throws RocksDBException;
2826
}
2927

30-
static Stream<MergeVariantsTest.FunctionMerge<RocksDB, byte[], byte[]>> data() {
28+
static Stream<MergeVariantsTest.FunctionMerge<RocksDB, byte[], byte[]>> parameters() {
3129
return Stream.of(RocksDB::merge,
3230
(db, left, right)
3331
-> db.merge(new WriteOptions(), left, right),
@@ -64,7 +62,7 @@ static Stream<MergeVariantsTest.FunctionMerge<RocksDB, byte[], byte[]>> data() {
6462
});
6563
}
6664

67-
@RegisterExtension
65+
@RegisterExtension
6866
public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
6967
new RocksNativeLibraryResource();
7068

@@ -73,7 +71,7 @@ static Stream<MergeVariantsTest.FunctionMerge<RocksDB, byte[], byte[]>> data() {
7371

7472
@ParameterizedTest
7573
@MethodSource("parameters")
76-
public void uint64AddOperatorOption(final MergeVariantsTest.FunctionMerge<RocksDB, byte[], byte[]> mergeFunction) throws InterruptedException, RocksDBException {
74+
public void uint64AddOperatorOption(final MergeVariantsTest.FunctionMerge<RocksDB, byte[], byte[]> mergeFunction) throws RocksDBException {
7775
try (final UInt64AddOperator uint64AddOperator = new UInt64AddOperator();
7876
final Options opt =
7977
new Options().setCreateIfMissing(true).setMergeOperator(uint64AddOperator);

java/src/test/java/org/rocksdb/PutMultiplePartsTest.java

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,26 @@
1010

1111
import java.nio.charset.StandardCharsets;
1212
import java.util.ArrayList;
13-
import java.util.Arrays;
1413
import java.util.List;
15-
import org.junit.jupiter.api.Test;
1614
import org.junit.jupiter.params.ParameterizedTest;
1715
import org.junit.jupiter.params.provider.MethodSource;
18-
import org.junit.jupiter.params.provider.Arguments;
19-
import java.util.stream.Stream;
16+
17+
import java.util.stream.IntStream;
2018
import org.junit.jupiter.api.io.TempDir;
2119
import java.io.File;
20+
2221
public class PutMultiplePartsTest {
23-
static Stream<Integer> data() {
24-
return Stream.of(2, 3, 250, 20000);
22+
23+
static IntStream parameters() {
24+
return IntStream.of(2, 3, 250, 20000);
2525
}
2626

2727
@TempDir
2828
File dbFolder;
2929

30-
private final int numParts;
31-
32-
public PutMultiplePartsTest(final Integer numParts) {
33-
this.numParts = numParts;
34-
}
35-
36-
@Test
37-
public void putUntracked() throws RocksDBException {
30+
@ParameterizedTest
31+
@MethodSource("parameters")
32+
public void putUntracked(final int numParts) throws RocksDBException {
3833
try (final Options options = new Options().setCreateIfMissing(true);
3934
final TransactionDBOptions txnDbOptions = new TransactionDBOptions();
4035
final TransactionDB txnDB =
@@ -48,11 +43,12 @@ public void putUntracked() throws RocksDBException {
4843
txnDB.syncWal();
4944
}
5045

51-
validateResults();
46+
validateResults(numParts);
5247
}
5348

54-
@Test
55-
public void put() throws RocksDBException {
49+
@ParameterizedTest
50+
@MethodSource("parameters")
51+
public void put(final int numParts) throws RocksDBException {
5652
try (final Options options = new Options().setCreateIfMissing(true);
5753
final TransactionDBOptions txnDbOptions = new TransactionDBOptions();
5854
final TransactionDB txnDB =
@@ -66,11 +62,12 @@ public void put() throws RocksDBException {
6662
txnDB.syncWal();
6763
}
6864

69-
validateResults();
65+
validateResults(numParts);
7066
}
7167

72-
@Test
73-
public void putUntrackedCF() throws RocksDBException {
68+
@ParameterizedTest
69+
@MethodSource("parameters")
70+
public void putUntrackedCF(final int numParts) throws RocksDBException {
7471
try (final Options options = new Options().setCreateIfMissing(true);
7572
final TransactionDBOptions txnDbOptions = new TransactionDBOptions();
7673
final TransactionDB txnDB =
@@ -86,10 +83,12 @@ public void putUntrackedCF() throws RocksDBException {
8683
txnDB.syncWal();
8784
}
8885

89-
validateResultsCF();
86+
validateResultsCF(numParts);
9087
}
91-
@Test
92-
public void putCF() throws RocksDBException {
88+
89+
@ParameterizedTest
90+
@MethodSource("parameters")
91+
public void putCF(final int numParts) throws RocksDBException {
9392
try (final Options options = new Options().setCreateIfMissing(true);
9493
final TransactionDBOptions txnDbOptions = new TransactionDBOptions();
9594
final TransactionDB txnDB =
@@ -105,10 +104,10 @@ public void putCF() throws RocksDBException {
105104
txnDB.syncWal();
106105
}
107106

108-
validateResultsCF();
107+
validateResultsCF(numParts);
109108
}
110109

111-
private void validateResults() throws RocksDBException {
110+
private void validateResults(final int numParts) throws RocksDBException {
112111
try (final RocksDB db = RocksDB.open(new Options(), dbFolder.getAbsolutePath())) {
113112
final List<byte[]> keys = generateItemsAsList("key", ":", numParts);
114113
final byte[][] values = generateItems("value", "", numParts);
@@ -126,7 +125,7 @@ private void validateResults() throws RocksDBException {
126125
}
127126
}
128127

129-
private void validateResultsCF() throws RocksDBException {
128+
private void validateResultsCF(final int numParts) throws RocksDBException {
130129
final List<ColumnFamilyDescriptor> columnFamilyDescriptors = new ArrayList<>();
131130
columnFamilyDescriptors.add(new ColumnFamilyDescriptor("cfTest".getBytes()));
132131
columnFamilyDescriptors.add(new ColumnFamilyDescriptor("default".getBytes()));

0 commit comments

Comments
 (0)