From 7fa66354d4c534fe350f92de2aa014d7758e2ca6 Mon Sep 17 00:00:00 2001 From: davidkngo <32287546+davidkngo@users.noreply.github.com> Date: Fri, 21 Jul 2023 16:29:20 +0700 Subject: [PATCH] Revert "services - migrate to junit 5 (#5613)" This reverts commit 1af6b5bdfe08cf7fa94f9430806e5830a606685d. --- enclave/build.gradle | 4 + gradle/check-licenses.gradle | 3 +- metrics/core/build.gradle | 2 + plugins/rocksdb/build.gradle | 1 - ...nDBRocksDBColumnarKeyValueStorageTest.java | 6 +- .../RocksDBColumnarKeyValueStorageTest.java | 19 +-- .../segmented/RocksDBKeyValueStorageTest.java | 16 +-- ...nDBRocksDBColumnarKeyValueStorageTest.java | 2 +- services/kvstore/build.gradle | 4 +- .../LimitedInMemoryKeyValueStorageTest.java | 2 +- services/pipeline/build.gradle | 4 +- .../pipeline/AsyncOperationProcessorTest.java | 2 +- .../pipeline/BatchingReadPipeTest.java | 2 +- .../services/pipeline/CompleterStageTest.java | 2 +- .../pipeline/FlatMapProcessorTest.java | 2 +- .../pipeline/IteratorSourceStageTest.java | 2 +- .../services/pipeline/MapProcessorTest.java | 2 +- .../besu/services/pipeline/PipeTest.java | 2 +- .../pipeline/PipelineBuilderTest.java | 6 +- .../pipeline/ProcessingStageTest.java | 17 ++- .../pipeline/SharedWritePipeTest.java | 2 +- services/tasks/build.gradle | 3 + .../services/tasks/AbstractTaskQueueTest.java | 2 +- .../tasks/CachingTaskCollectionTest.java | 6 +- .../InMemoryTasksPriorityQueuesTest.java | 2 +- testutil/build.gradle | 2 +- .../kvstore/AbstractKeyValueStorageTest.java | 131 ++++++------------ 27 files changed, 105 insertions(+), 143 deletions(-) diff --git a/enclave/build.gradle b/enclave/build.gradle index 302b2f246a4..235962cda72 100644 --- a/enclave/build.gradle +++ b/enclave/build.gradle @@ -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' @@ -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' } diff --git a/gradle/check-licenses.gradle b/gradle/check-licenses.gradle index 3939c191166..9bea3e148c5 100644 --- a/gradle/check-licenses.gradle +++ b/gradle/check-licenses.gradle @@ -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', diff --git a/metrics/core/build.gradle b/metrics/core/build.gradle index 295cdada976..310a1588e8d 100644 --- a/metrics/core/build.gradle +++ b/metrics/core/build.gradle @@ -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' diff --git a/plugins/rocksdb/build.gradle b/plugins/rocksdb/build.gradle index fa4b0e9f0e0..dc5438f86c9 100644 --- a/plugins/rocksdb/build.gradle +++ b/plugins/rocksdb/build.gradle @@ -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' } diff --git a/plugins/rocksdb/src/test/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/OptimisticTransactionDBRocksDBColumnarKeyValueStorageTest.java b/plugins/rocksdb/src/test/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/OptimisticTransactionDBRocksDBColumnarKeyValueStorageTest.java index 2c9fc86df13..2a2ec01ca4a 100644 --- a/plugins/rocksdb/src/test/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/OptimisticTransactionDBRocksDBColumnarKeyValueStorageTest.java +++ b/plugins/rocksdb/src/test/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/OptimisticTransactionDBRocksDBColumnarKeyValueStorageTest.java @@ -25,8 +25,6 @@ import java.util.Arrays; import java.util.List; -import org.apache.tuweni.bytes.Bytes; - public class OptimisticTransactionDBRocksDBColumnarKeyValueStorageTest extends RocksDBColumnarKeyValueStorageTest { @@ -34,9 +32,7 @@ public class OptimisticTransactionDBRocksDBColumnarKeyValueStorageTest protected SegmentedKeyValueStorage 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(), diff --git a/plugins/rocksdb/src/test/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBColumnarKeyValueStorageTest.java b/plugins/rocksdb/src/test/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBColumnarKeyValueStorageTest.java index 98eaf034960..d58da12ce2f 100644 --- a/plugins/rocksdb/src/test/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBColumnarKeyValueStorageTest.java +++ b/plugins/rocksdb/src/test/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBColumnarKeyValueStorageTest.java @@ -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 { @@ -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 store = createSegmentedStore( @@ -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 store = createSegmentedStore( @@ -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 store = createSegmentedStore( diff --git a/plugins/rocksdb/src/test/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBKeyValueStorageTest.java b/plugins/rocksdb/src/test/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBKeyValueStorageTest.java index 78968873ecf..d9e7aec9def 100644 --- a/plugins/rocksdb/src/test/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBKeyValueStorageTest.java +++ b/plugins/rocksdb/src/test/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/RocksDBKeyValueStorageTest.java @@ -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 labelledMetricOperationTimerMock; @Mock private LabelledMetric labelledMetricCounterMock; @Mock private OperationTimer operationTimerMock; - @TempDir static Path folder; + @Rule public final TemporaryFolder folder = new TemporaryFolder(); @Override protected KeyValueStorage createStore() throws Exception { @@ -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(); } } diff --git a/plugins/rocksdb/src/test/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/TransactionDBRocksDBColumnarKeyValueStorageTest.java b/plugins/rocksdb/src/test/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/TransactionDBRocksDBColumnarKeyValueStorageTest.java index d7d4e12da7d..3542855c171 100644 --- a/plugins/rocksdb/src/test/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/TransactionDBRocksDBColumnarKeyValueStorageTest.java +++ b/plugins/rocksdb/src/test/java/org/hyperledger/besu/plugin/services/storage/rocksdb/segmented/TransactionDBRocksDBColumnarKeyValueStorageTest.java @@ -32,7 +32,7 @@ public class TransactionDBRocksDBColumnarKeyValueStorageTest protected SegmentedKeyValueStorage 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(), diff --git a/services/kvstore/build.gradle b/services/kvstore/build.gradle index 0415f6702b8..99c26a5ecfe 100644 --- a/services/kvstore/build.gradle +++ b/services/kvstore/build.gradle @@ -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' } diff --git a/services/kvstore/src/test/java/org/hyperledger/besu/services/kvstore/LimitedInMemoryKeyValueStorageTest.java b/services/kvstore/src/test/java/org/hyperledger/besu/services/kvstore/LimitedInMemoryKeyValueStorageTest.java index affcec07151..a416c865425 100644 --- a/services/kvstore/src/test/java/org/hyperledger/besu/services/kvstore/LimitedInMemoryKeyValueStorageTest.java +++ b/services/kvstore/src/test/java/org/hyperledger/besu/services/kvstore/LimitedInMemoryKeyValueStorageTest.java @@ -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 { diff --git a/services/pipeline/build.gradle b/services/pipeline/build.gradle index b86edbf344b..0df845f76db 100644 --- a/services/pipeline/build.gradle +++ b/services/pipeline/build.gradle @@ -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' } diff --git a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/AsyncOperationProcessorTest.java b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/AsyncOperationProcessorTest.java index 1b9f8202435..c15c615e9a5 100644 --- a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/AsyncOperationProcessorTest.java +++ b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/AsyncOperationProcessorTest.java @@ -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 { diff --git a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/BatchingReadPipeTest.java b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/BatchingReadPipeTest.java index fb90128fbb3..e2f7195f670 100644 --- a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/BatchingReadPipeTest.java +++ b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/BatchingReadPipeTest.java @@ -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 { diff --git a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/CompleterStageTest.java b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/CompleterStageTest.java index ef3e29afebe..90c1b3c1e8e 100644 --- a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/CompleterStageTest.java +++ b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/CompleterStageTest.java @@ -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 { diff --git a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/FlatMapProcessorTest.java b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/FlatMapProcessorTest.java index 1012d3b0123..a6a68aa797d 100644 --- a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/FlatMapProcessorTest.java +++ b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/FlatMapProcessorTest.java @@ -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 { diff --git a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/IteratorSourceStageTest.java b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/IteratorSourceStageTest.java index 02052615b75..6c7f077dcb3 100644 --- a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/IteratorSourceStageTest.java +++ b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/IteratorSourceStageTest.java @@ -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 { diff --git a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/MapProcessorTest.java b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/MapProcessorTest.java index 0d7a913c3e3..8e5ff6bbde6 100644 --- a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/MapProcessorTest.java +++ b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/MapProcessorTest.java @@ -23,7 +23,7 @@ import java.util.function.Function; -import org.junit.jupiter.api.Test; +import org.junit.Test; public class MapProcessorTest { diff --git a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/PipeTest.java b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/PipeTest.java index c838bc887a3..7ce16dfbef3 100644 --- a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/PipeTest.java +++ b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/PipeTest.java @@ -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); diff --git a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/PipelineBuilderTest.java b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/PipelineBuilderTest.java index 1ec64ab65fc..9b33ba24708 100644 --- a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/PipelineBuilderTest.java +++ b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/PipelineBuilderTest.java @@ -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 { @@ -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)) { diff --git a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/ProcessingStageTest.java b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/ProcessingStageTest.java index efbe16da668..ad02ca03c74 100644 --- a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/ProcessingStageTest.java +++ b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/ProcessingStageTest.java @@ -16,7 +16,7 @@ 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; @@ -24,13 +24,13 @@ 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 inputPipe = @@ -40,11 +40,10 @@ public class ProcessingStageTest { @Mock private Processor singleStep; private ProcessingStage 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; diff --git a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/SharedWritePipeTest.java b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/SharedWritePipeTest.java index 5d99c1c0376..77d0a0e731c 100644 --- a/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/SharedWritePipeTest.java +++ b/services/pipeline/src/test/java/org/hyperledger/besu/services/pipeline/SharedWritePipeTest.java @@ -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 { diff --git a/services/tasks/build.gradle b/services/tasks/build.gradle index 66784412dc8..f398248c730 100644 --- a/services/tasks/build.gradle +++ b/services/tasks/build.gradle @@ -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' } diff --git a/services/tasks/src/test/java/org/hyperledger/besu/services/tasks/AbstractTaskQueueTest.java b/services/tasks/src/test/java/org/hyperledger/besu/services/tasks/AbstractTaskQueueTest.java index d4c6e30fc62..ec7f02d802e 100644 --- a/services/tasks/src/test/java/org/hyperledger/besu/services/tasks/AbstractTaskQueueTest.java +++ b/services/tasks/src/test/java/org/hyperledger/besu/services/tasks/AbstractTaskQueueTest.java @@ -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> { diff --git a/services/tasks/src/test/java/org/hyperledger/besu/services/tasks/CachingTaskCollectionTest.java b/services/tasks/src/test/java/org/hyperledger/besu/services/tasks/CachingTaskCollectionTest.java index c88e994cebb..12fe88acc73 100644 --- a/services/tasks/src/test/java/org/hyperledger/besu/services/tasks/CachingTaskCollectionTest.java +++ b/services/tasks/src/test/java/org/hyperledger/besu/services/tasks/CachingTaskCollectionTest.java @@ -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 wrappedTaskCollection; - @BeforeEach + @Before public void setup() { wrappedTaskCollection = new InMemoryTaskQueue<>(); } diff --git a/services/tasks/src/test/java/org/hyperledger/besu/services/tasks/InMemoryTasksPriorityQueuesTest.java b/services/tasks/src/test/java/org/hyperledger/besu/services/tasks/InMemoryTasksPriorityQueuesTest.java index 4817160d308..6219b77098e 100644 --- a/services/tasks/src/test/java/org/hyperledger/besu/services/tasks/InMemoryTasksPriorityQueuesTest.java +++ b/services/tasks/src/test/java/org/hyperledger/besu/services/tasks/InMemoryTasksPriorityQueuesTest.java @@ -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 { diff --git a/testutil/build.gradle b/testutil/build.gradle index f235bb054f0..193569c72c1 100644 --- a/testutil/build.gradle +++ b/testutil/build.gradle @@ -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' diff --git a/testutil/src/main/java/org/hyperledger/besu/kvstore/AbstractKeyValueStorageTest.java b/testutil/src/main/java/org/hyperledger/besu/kvstore/AbstractKeyValueStorageTest.java index 60a66336765..c24198c0268 100644 --- a/testutil/src/main/java/org/hyperledger/besu/kvstore/AbstractKeyValueStorageTest.java +++ b/testutil/src/main/java/org/hyperledger/besu/kvstore/AbstractKeyValueStorageTest.java @@ -21,7 +21,6 @@ import org.hyperledger.besu.plugin.services.storage.KeyValueStorage; import org.hyperledger.besu.plugin.services.storage.KeyValueStorageTransaction; -import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -33,12 +32,11 @@ import org.apache.commons.lang3.tuple.Pair; import org.apache.tuweni.bytes.Bytes; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.Disabled; -import org.junit.jupiter.api.Test; +import org.junit.Ignore; +import org.junit.Test; /** The Abstract key value storage test. */ -@Disabled +@Ignore public abstract class AbstractKeyValueStorageTest { /** @@ -354,16 +352,12 @@ public void transactionRollbackEmpty() throws Exception { * * @throws Exception the exception */ - @Test + @Test(expected = IllegalStateException.class) public void transactionPutAfterCommit() throws Exception { - Assertions.assertThatThrownBy( - () -> { - final KeyValueStorage store = createStore(); - final KeyValueStorageTransaction tx = store.startTransaction(); - tx.commit(); - tx.put(bytesOf(1), bytesOf(1)); - }) - .isInstanceOf(IllegalStateException.class); + final KeyValueStorage store = createStore(); + final KeyValueStorageTransaction tx = store.startTransaction(); + tx.commit(); + tx.put(bytesOf(1), bytesOf(1)); } /** @@ -371,16 +365,12 @@ public void transactionPutAfterCommit() throws Exception { * * @throws Exception the exception */ - @Test + @Test(expected = IllegalStateException.class) public void transactionRemoveAfterCommit() throws Exception { - Assertions.assertThatThrownBy( - () -> { - final KeyValueStorage store = createStore(); - final KeyValueStorageTransaction tx = store.startTransaction(); - tx.commit(); - tx.remove(bytesOf(1)); - }) - .isInstanceOf(IllegalStateException.class); + final KeyValueStorage store = createStore(); + final KeyValueStorageTransaction tx = store.startTransaction(); + tx.commit(); + tx.remove(bytesOf(1)); } /** @@ -388,16 +378,12 @@ public void transactionRemoveAfterCommit() throws Exception { * * @throws Exception the exception */ - @Test + @Test(expected = IllegalStateException.class) public void transactionPutAfterRollback() throws Exception { - Assertions.assertThatThrownBy( - () -> { - final KeyValueStorage store = createStore(); - final KeyValueStorageTransaction tx = store.startTransaction(); - tx.rollback(); - tx.put(bytesOf(1), bytesOf(1)); - }) - .isInstanceOf(IllegalStateException.class); + final KeyValueStorage store = createStore(); + final KeyValueStorageTransaction tx = store.startTransaction(); + tx.rollback(); + tx.put(bytesOf(1), bytesOf(1)); } /** @@ -405,16 +391,12 @@ public void transactionPutAfterRollback() throws Exception { * * @throws Exception the exception */ - @Test + @Test(expected = IllegalStateException.class) public void transactionRemoveAfterRollback() throws Exception { - Assertions.assertThatThrownBy( - () -> { - final KeyValueStorage store = createStore(); - final KeyValueStorageTransaction tx = store.startTransaction(); - tx.rollback(); - tx.remove(bytesOf(1)); - }) - .isInstanceOf(IllegalStateException.class); + final KeyValueStorage store = createStore(); + final KeyValueStorageTransaction tx = store.startTransaction(); + tx.rollback(); + tx.remove(bytesOf(1)); } /** @@ -422,16 +404,12 @@ public void transactionRemoveAfterRollback() throws Exception { * * @throws Exception the exception */ - @Test + @Test(expected = IllegalStateException.class) public void transactionCommitAfterRollback() throws Exception { - Assertions.assertThatThrownBy( - () -> { - final KeyValueStorage store = createStore(); - final KeyValueStorageTransaction tx = store.startTransaction(); - tx.rollback(); - tx.commit(); - }) - .isInstanceOf(IllegalStateException.class); + final KeyValueStorage store = createStore(); + final KeyValueStorageTransaction tx = store.startTransaction(); + tx.rollback(); + tx.commit(); } /** @@ -439,16 +417,12 @@ public void transactionCommitAfterRollback() throws Exception { * * @throws Exception the exception */ - @Test + @Test(expected = IllegalStateException.class) public void transactionCommitTwice() throws Exception { - Assertions.assertThatThrownBy( - () -> { - final KeyValueStorage store = createStore(); - final KeyValueStorageTransaction tx = store.startTransaction(); - tx.commit(); - tx.commit(); - }) - .isInstanceOf(IllegalStateException.class); + final KeyValueStorage store = createStore(); + final KeyValueStorageTransaction tx = store.startTransaction(); + tx.commit(); + tx.commit(); } /** @@ -456,16 +430,12 @@ public void transactionCommitTwice() throws Exception { * * @throws Exception the exception */ - @Test + @Test(expected = IllegalStateException.class) public void transactionRollbackAfterCommit() throws Exception { - Assertions.assertThatThrownBy( - () -> { - final KeyValueStorage store = createStore(); - final KeyValueStorageTransaction tx = store.startTransaction(); - tx.commit(); - tx.rollback(); - }) - .isInstanceOf(IllegalStateException.class); + final KeyValueStorage store = createStore(); + final KeyValueStorageTransaction tx = store.startTransaction(); + tx.commit(); + tx.rollback(); } /** @@ -473,16 +443,12 @@ public void transactionRollbackAfterCommit() throws Exception { * * @throws Exception the exception */ - @Test + @Test(expected = IllegalStateException.class) public void transactionRollbackTwice() throws Exception { - Assertions.assertThatThrownBy( - () -> { - final KeyValueStorage store = createStore(); - final KeyValueStorageTransaction tx = store.startTransaction(); - tx.rollback(); - tx.rollback(); - }) - .isInstanceOf(IllegalStateException.class); + final KeyValueStorage store = createStore(); + final KeyValueStorageTransaction tx = store.startTransaction(); + tx.rollback(); + tx.rollback(); } /** @@ -581,15 +547,4 @@ protected byte[] bytesFromHexString(final String hex) { protected byte[] bytesOf(final int... bytes) { return Bytes.of(bytes).toArrayUnsafe(); } - - /** - * Create a sub folder from the given path, that will not conflict with other folders. - * - * @param folder the folder in which to create the sub folder - * @return the path representing the sub folder - * @throws Exception if the folder cannot be created - */ - protected Path getTempSubFolder(final Path folder) throws Exception { - return java.nio.file.Files.createTempDirectory(folder, null); - } }