Skip to content

Commit

Permalink
Revert "services - migrate to junit 5 (hyperledger#5613)"
Browse files Browse the repository at this point in the history
This reverts commit 1af6b5b.
  • Loading branch information
davidkngo authored Jul 21, 2023
1 parent 85822bd commit 7fa6635
Show file tree
Hide file tree
Showing 27 changed files with 105 additions and 143 deletions.
4 changes: 4 additions & 0 deletions enclave/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ dependencies {
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.junit.jupiter:junit-jupiter'

testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'

// integration test dependencies.
integrationTestImplementation project(':testutil')
integrationTestImplementation 'org.assertj:assertj-core'
Expand All @@ -25,4 +27,6 @@ dependencies {
integrationTestImplementation 'org.junit.jupiter:junit-jupiter-api'
integrationTestImplementation 'org.mockito:mockito-core'
integrationTestImplementation 'org.testcontainers:testcontainers'

integrationTestRuntimeOnly 'org.junit.jupiter:junit-jupiter'
}
3 changes: 1 addition & 2 deletions gradle/check-licenses.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ downloadLicenses {
],
(epl2) : [
'Eclipse Public License - v 2.0',
'Eclipse Public License version 2.0',
'Eclipse Public License v2.0'
'Eclipse Public License version 2.0'
],
(mit) : [
'MIT',
Expand Down
2 changes: 2 additions & 0 deletions metrics/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ dependencies {
testImplementation 'org.mockito:mockito-core'
testImplementation 'org.mockito:mockito-junit-jupiter'

testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'

testSupportImplementation 'org.mockito:mockito-core'

annotationProcessor 'com.google.dagger:dagger-compiler'
Expand Down
1 change: 0 additions & 1 deletion plugins/rocksdb/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ dependencies {
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.mockito:mockito-core'
testImplementation 'org.mockito:mockito-junit-jupiter'

testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,14 @@
import java.util.Arrays;
import java.util.List;

import org.apache.tuweni.bytes.Bytes;

public class OptimisticTransactionDBRocksDBColumnarKeyValueStorageTest
extends RocksDBColumnarKeyValueStorageTest {

@Override
protected SegmentedKeyValueStorage<RocksDbSegmentIdentifier> createSegmentedStore()
throws Exception {
return new OptimisticRocksDBColumnarKeyValueStorage(
new RocksDBConfigurationBuilder()
.databaseDir(folder.resolve(Bytes.random(9).toString()))
.build(),
new RocksDBConfigurationBuilder().databaseDir(folder.newFolder().toPath()).build(),
Arrays.asList(TestSegment.FOO, TestSegment.BAR),
List.of(),
new NoOpMetricsSystem(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@
import java.util.function.Consumer;

import org.apache.commons.lang3.tuple.Pair;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;

public abstract class RocksDBColumnarKeyValueStorageTest extends AbstractKeyValueStorageTest {

@TempDir public Path folder;
@Rule public final TemporaryFolder folder = new TemporaryFolder();

@Test
public void assertClear() throws Exception {
Expand Down Expand Up @@ -177,8 +178,8 @@ public void canGetThroughSegmentIteration() throws Exception {
}

@Test
public void dbShouldIgnoreExperimentalSegmentsIfNotExisted(@TempDir final Path testPath)
throws Exception {
public void dbShouldIgnoreExperimentalSegmentsIfNotExisted() throws Exception {
final Path testPath = folder.newFolder().toPath();
// Create new db should ignore experimental column family
SegmentedKeyValueStorage<RocksDbSegmentIdentifier> store =
createSegmentedStore(
Expand All @@ -194,8 +195,8 @@ public void dbShouldIgnoreExperimentalSegmentsIfNotExisted(@TempDir final Path t
}

@Test
public void dbShouldNotIgnoreExperimentalSegmentsIfExisted(@TempDir final Path testPath)
throws Exception {
public void dbShouldNotIgnoreExperimentalSegmentsIfExisted() throws Exception {
final Path testPath = folder.newFolder().toPath();
// Create new db with experimental column family
SegmentedKeyValueStorage<RocksDbSegmentIdentifier> store =
createSegmentedStore(
Expand Down Expand Up @@ -224,8 +225,8 @@ public void dbShouldNotIgnoreExperimentalSegmentsIfExisted(@TempDir final Path t
}

@Test
public void dbWillBeBackwardIncompatibleAfterExperimentalSegmentsAreAdded(
@TempDir final Path testPath) throws Exception {
public void dbWillBeBackwardIncompatibleAfterExperimentalSegmentsAreAdded() throws Exception {
final Path testPath = folder.newFolder().toPath();
// Create new db should ignore experimental column family
SegmentedKeyValueStorage<RocksDbSegmentIdentifier> store =
createSegmentedStore(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,24 @@
import org.hyperledger.besu.plugin.services.storage.rocksdb.configuration.RocksDBConfigurationBuilder;
import org.hyperledger.besu.plugin.services.storage.rocksdb.unsegmented.RocksDBKeyValueStorage;

import java.nio.file.Path;
import java.util.function.LongSupplier;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.io.TempDir;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.MockitoJUnitRunner;

@ExtendWith(MockitoExtension.class)
@RunWith(MockitoJUnitRunner.class)
public class RocksDBKeyValueStorageTest extends AbstractKeyValueStorageTest {

@Mock private ObservableMetricsSystem metricsSystemMock;
@Mock private LabelledMetric<OperationTimer> labelledMetricOperationTimerMock;
@Mock private LabelledMetric<Counter> labelledMetricCounterMock;
@Mock private OperationTimer operationTimerMock;
@TempDir static Path folder;
@Rule public final TemporaryFolder folder = new TemporaryFolder();

@Override
protected KeyValueStorage createStore() throws Exception {
Expand Down Expand Up @@ -131,6 +131,6 @@ public void createStoreMustCreateMetrics() throws Exception {
}

private RocksDBConfiguration config() throws Exception {
return new RocksDBConfigurationBuilder().databaseDir(getTempSubFolder(folder)).build();
return new RocksDBConfigurationBuilder().databaseDir(folder.newFolder().toPath()).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class TransactionDBRocksDBColumnarKeyValueStorageTest
protected SegmentedKeyValueStorage<RocksDbSegmentIdentifier> createSegmentedStore()
throws Exception {
return new TransactionDBRocksDBColumnarKeyValueStorage(
new RocksDBConfigurationBuilder().databaseDir(getTempSubFolder(folder)).build(),
new RocksDBConfigurationBuilder().databaseDir(folder.newFolder().toPath()).build(),
Arrays.asList(TestSegment.FOO, TestSegment.BAR),
List.of(),
new NoOpMetricsSystem(),
Expand Down
4 changes: 3 additions & 1 deletion services/kvstore/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ dependencies {
implementation 'com.google.guava:guava'

testImplementation project(':testutil')
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'junit:junit'
testImplementation 'org.assertj:assertj-core'

testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.hyperledger.besu.plugin.services.storage.KeyValueStorage;
import org.hyperledger.besu.plugin.services.storage.KeyValueStorageTransaction;

import org.junit.jupiter.api.Test;
import org.junit.Test;

public class LimitedInMemoryKeyValueStorageTest extends AbstractKeyValueStorageTest {

Expand Down
4 changes: 3 additions & 1 deletion services/pipeline/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ dependencies {
implementation 'io.opentelemetry:opentelemetry-api'
implementation 'com.google.guava:guava'

testImplementation 'junit:junit'
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.awaitility:awaitility'
testImplementation 'org.junit.jupiter:junit-jupiter'
testImplementation 'org.mockito:mockito-core'
testImplementation 'org.mockito:mockito-junit-jupiter'

testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;

import org.junit.jupiter.api.Test;
import org.junit.Test;

public class AsyncOperationProcessorTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.ArrayList;
import java.util.List;

import org.junit.jupiter.api.Test;
import org.junit.Test;

public class BatchingReadPipeTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.util.ArrayList;
import java.util.List;

import org.junit.jupiter.api.Test;
import org.junit.Test;

public class CompleterStageTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.function.Function;
import java.util.stream.Stream;

import org.junit.jupiter.api.Test;
import org.junit.Test;

public class FlatMapProcessorTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import static org.hyperledger.besu.metrics.noop.NoOpMetricsSystem.NO_OP_COUNTER;

import com.google.common.collect.Iterators;
import org.junit.jupiter.api.Test;
import org.junit.Test;

public class IteratorSourceStageTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import java.util.function.Function;

import org.junit.jupiter.api.Test;
import org.junit.Test;

public class MapProcessorTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.ArrayList;
import java.util.List;

import org.junit.jupiter.api.Test;
import org.junit.Test;

public class PipeTest {
private final Counter inputCounter = mock(Counter.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
import java.util.stream.Stream;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.After;
import org.junit.Test;

public class PipelineBuilderTest {

Expand All @@ -66,7 +66,7 @@ public class PipelineBuilderTest {

private final ExecutorService executorService = Executors.newCachedThreadPool(THREAD_FACTORY);

@AfterEach
@After
public void afterClass() throws Exception {
executorService.shutdownNow();
if (!executorService.awaitTermination(10, SECONDS)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.hyperledger.besu.metrics.noop.NoOpMetricsSystem.NO_OP_COUNTER;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;

import java.util.Locale;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.MockitoJUnitRunner;

@ExtendWith(MockitoExtension.class)
@RunWith(MockitoJUnitRunner.class)
public class ProcessingStageTest {

private final Pipe<String> inputPipe =
Expand All @@ -40,11 +40,10 @@ public class ProcessingStageTest {
@Mock private Processor<String, String> singleStep;
private ProcessingStage<String, String> stage;

@BeforeEach
@Before
public void setUp() {
stage = new ProcessingStage<>("name", inputPipe, outputPipe, singleStep);
lenient()
.doAnswer(
doAnswer(
invocation -> {
outputPipe.put(inputPipe.get().toLowerCase(Locale.UK));
return 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;

import org.junit.jupiter.api.Test;
import org.junit.Test;

public class SharedWritePipeTest {

Expand Down
3 changes: 3 additions & 0 deletions services/tasks/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ dependencies {
implementation 'io.vertx:vertx-core'
implementation 'org.apache.tuweni:tuweni-bytes'

testImplementation 'junit:junit'
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.junit.jupiter:junit-jupiter'

testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.function.Function;

import org.apache.tuweni.bytes.Bytes;
import org.junit.jupiter.api.Test;
import org.junit.Test;

abstract class AbstractTaskQueueTest<T extends TaskCollection<Bytes>> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
import java.util.stream.Collectors;

import org.apache.tuweni.bytes.Bytes;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.Before;
import org.junit.Test;

public class CachingTaskCollectionTest {
private TaskCollection<Bytes> wrappedTaskCollection;

@BeforeEach
@Before
public void setup() {
wrappedTaskCollection = new InMemoryTaskQueue<>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.List;
import java.util.Objects;

import org.junit.jupiter.api.Test;
import org.junit.Test;

public class InMemoryTasksPriorityQueuesTest {

Expand Down
2 changes: 1 addition & 1 deletion testutil/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ dependencies {
implementation 'com.google.guava:guava'
implementation 'com.squareup.okhttp3:okhttp'
implementation 'io.vertx:vertx-core'
implementation 'org.junit.jupiter:junit-jupiter'
implementation 'junit:junit'
implementation 'org.apache.tuweni:tuweni-bytes'
implementation 'org.apache.tuweni:tuweni-io'
implementation 'org.apache.tuweni:tuweni-toml'
Expand Down
Loading

0 comments on commit 7fa6635

Please sign in to comment.