diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/AbstractPreexistingNodeTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/AbstractPreexistingNodeTest.java index 5c4b58ec019..a407b389e44 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/AbstractPreexistingNodeTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/AbstractPreexistingNodeTest.java @@ -43,15 +43,8 @@ import org.apache.commons.compress.utils.IOUtils; public class AbstractPreexistingNodeTest extends AcceptanceTestBase { - protected final String testName; - protected final String dataPath; protected Path hostDataPath; - public AbstractPreexistingNodeTest(final String testName, final String dataPath) { - this.testName = testName; - this.dataPath = dataPath; - } - protected static void extract(final Path path, final String destDirectory) throws IOException { try (final TarArchiveInputStream fin = new TarArchiveInputStream( diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/LoggingTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/LoggingTest.java index e0276842f06..1c1f0c33b68 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/LoggingTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/LoggingTest.java @@ -21,7 +21,7 @@ import java.io.IOException; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class LoggingTest extends AcceptanceTestBase { diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/backup/BackupRoundTripAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/backup/BackupRoundTripAcceptanceTest.java index 5136cc64ab3..aa58ffb2fdf 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/backup/BackupRoundTripAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/backup/BackupRoundTripAcceptanceTest.java @@ -29,7 +29,6 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.BesuNode; import org.hyperledger.besu.tests.acceptance.dsl.node.configuration.BesuNodeConfigurationBuilder; -import java.io.IOException; import java.math.BigInteger; import java.net.URL; import java.nio.file.Files; @@ -37,64 +36,42 @@ import java.nio.file.Paths; import java.util.List; import java.util.function.UnaryOperator; +import java.util.stream.Stream; import javax.annotation.Nonnull; import com.fasterxml.jackson.databind.node.ObjectNode; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) public class BackupRoundTripAcceptanceTest extends AbstractPreexistingNodeTest { - private final Path backupPath; - private final Path restorePath; - private final Path rebackupPath; - - @SuppressWarnings({"unused", "FieldCanBeLocal"}) - private final List testAccounts; - - @SuppressWarnings({"unused", "FieldCanBeLocal"}) - private final long expectedChainHeight; + private Path backupPath; + private Path restorePath; + private Path rebackupPath; + + public static Stream getParameters() { + // First 10 blocks of ropsten + return Stream.of( + Arguments.of( + "After versioning was enabled and using multiple RocksDB columns", + "version1", + 0xA, + singletonList( + new AccountData( + "0xd1aeb42885a43b72b518182ef893125814811048", + BigInteger.valueOf(0xA), + Wei.fromHexString("0x2B5E3AF16B1880000"))))); + } - public BackupRoundTripAcceptanceTest( - final String testName, - final String dataPath, - final long expectedChainHeight, - final List testAccounts) - throws IOException { - super(testName, dataPath); - this.expectedChainHeight = expectedChainHeight; - this.testAccounts = testAccounts; + public void setUp(final String testName, final String dataPath) throws Exception { backupPath = Files.createTempDirectory("backup"); backupPath.toFile().deleteOnExit(); restorePath = Files.createTempDirectory("restore"); restorePath.toFile().deleteOnExit(); rebackupPath = Files.createTempDirectory("rebackup"); rebackupPath.toFile().deleteOnExit(); - } - @Parameters(name = "{0}") - public static Object[][] getParameters() { - return new Object[][] { - // First 10 blocks of ropsten - new Object[] { - "After versioning was enabled and using multiple RocksDB columns", - "version1", - 0xA, - singletonList( - new AccountData( - "0xd1aeb42885a43b72b518182ef893125814811048", - BigInteger.valueOf(0xA), - Wei.fromHexString("0x2B5E3AF16B1880000"))) - } - }; - } - - @Before - public void setUp() throws Exception { final URL rootURL = DatabaseMigrationAcceptanceTest.class.getResource(dataPath); hostDataPath = copyDataDir(rootURL); final Path databaseArchive = @@ -105,8 +82,16 @@ public void setUp() throws Exception { extract(databaseArchive, hostDataPath.toAbsolutePath().toString()); } - @Test - public void backupRoundtripAndBack() throws IOException { + @ParameterizedTest(name = "{index}: {0}") + @MethodSource("getParameters") + public void backupRoundtripAndBack( + final String testName, + final String dataPath, + final long expectedChainHeight, + final List testAccounts) + throws Exception { + + setUp(testName, dataPath); // backup from existing files final BesuNode backupNode = diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bootstrap/ClusterAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bootstrap/ClusterAcceptanceTest.java index c4c9e42671c..e7ad04dc594 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bootstrap/ClusterAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bootstrap/ClusterAcceptanceTest.java @@ -17,15 +17,15 @@ import org.hyperledger.besu.tests.acceptance.dsl.AcceptanceTestBase; import org.hyperledger.besu.tests.acceptance.dsl.node.Node; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class ClusterAcceptanceTest extends AcceptanceTestBase { private Node minerNode; private Node fullNode; - @Before + @BeforeEach public void setUp() throws Exception { minerNode = besu.createMinerNode("node1"); fullNode = besu.createArchiveNode("node2"); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bootstrap/ClusterNoDiscoveryAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bootstrap/ClusterNoDiscoveryAcceptanceTest.java index 6c7c8127997..3a7da4f4768 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bootstrap/ClusterNoDiscoveryAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bootstrap/ClusterNoDiscoveryAcceptanceTest.java @@ -20,8 +20,8 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfiguration; import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfigurationBuilder; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class ClusterNoDiscoveryAcceptanceTest extends AcceptanceTestBase { @@ -29,7 +29,7 @@ public class ClusterNoDiscoveryAcceptanceTest extends AcceptanceTestBase { private Node noDiscoveryNode; private Cluster noDiscoveryCluster; - @Before + @BeforeEach public void setUp() throws Exception { final ClusterConfiguration clusterConfiguration = new ClusterConfigurationBuilder().awaitPeerDiscovery(false).build(); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bootstrap/ClusterThreadNodeRunnerAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bootstrap/ClusterThreadNodeRunnerAcceptanceTest.java index 805749a0bf8..8fbd0d3d625 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bootstrap/ClusterThreadNodeRunnerAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bootstrap/ClusterThreadNodeRunnerAcceptanceTest.java @@ -23,15 +23,15 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfiguration; import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfigurationBuilder; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class ClusterThreadNodeRunnerAcceptanceTest extends AcceptanceTestBase { private Node fullNode; private Cluster noDiscoveryCluster; - @Before + @BeforeEach public void setUp() throws Exception { final ClusterConfiguration clusterConfiguration = new ClusterConfigurationBuilder().awaitPeerDiscovery(false).build(); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bootstrap/P2pDisabledAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bootstrap/P2pDisabledAcceptanceTest.java index aa71839b181..67a9bf2754f 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bootstrap/P2pDisabledAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bootstrap/P2pDisabledAcceptanceTest.java @@ -20,14 +20,14 @@ import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfiguration; import org.hyperledger.besu.tests.acceptance.dsl.node.cluster.ClusterConfigurationBuilder; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class P2pDisabledAcceptanceTest extends AcceptanceTestBase { private Node node; private Cluster p2pDisabledCluster; - @Before + @BeforeEach public void setUp() throws Exception { final ClusterConfiguration clusterConfiguration = new ClusterConfigurationBuilder().awaitPeerDiscovery(false).build(); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bootstrap/StaticNodesAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bootstrap/StaticNodesAcceptanceTest.java index 1f28a4a9f3c..0ce5ea02b13 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bootstrap/StaticNodesAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/bootstrap/StaticNodesAcceptanceTest.java @@ -20,15 +20,15 @@ import java.util.Arrays; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class StaticNodesAcceptanceTest extends AcceptanceTestBase { private Node otherNode; private Node node; - @Before + @BeforeEach public void setUp() throws Exception { otherNode = besu.createNodeWithNoDiscovery("other-node"); cluster.start(otherNode); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/config/BootNodesGenesisSetupTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/config/BootNodesGenesisSetupTest.java index 1ad2587ded3..616afc19669 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/config/BootNodesGenesisSetupTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/config/BootNodesGenesisSetupTest.java @@ -29,9 +29,9 @@ import org.bouncycastle.asn1.sec.SECNamedCurves; import org.bouncycastle.asn1.x9.X9ECParameters; import org.bouncycastle.crypto.params.ECDomainParameters; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class BootNodesGenesisSetupTest extends AcceptanceTestBase { private static final String CURVE_NAME = "secp256k1"; @@ -42,13 +42,13 @@ public class BootNodesGenesisSetupTest extends AcceptanceTestBase { private Node nodeA; private Node nodeB; - @BeforeClass + @BeforeAll public static void environment() { final X9ECParameters params = SECNamedCurves.getByName(CURVE_NAME); curve = new ECDomainParameters(params.getCurve(), params.getG(), params.getN(), params.getH()); } - @Before + @BeforeEach public void setUp() throws Exception { int nodeAP2pBindingPort; int nodeBP2pBindingPort; diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/crypto/SECP256R1AcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/crypto/SECP256R1AcceptanceTest.java index 8b4ef9f864b..7164de0b7aa 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/crypto/SECP256R1AcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/crypto/SECP256R1AcceptanceTest.java @@ -32,8 +32,8 @@ import java.util.List; import org.apache.tuweni.bytes.Bytes32; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class SECP256R1AcceptanceTest extends AcceptanceTestBase { private Node minerNode; @@ -49,7 +49,7 @@ public class SECP256R1AcceptanceTest extends AcceptanceTestBase { private static final SECP256R1 SECP256R1_SIGNATURE_ALGORITHM = new SECP256R1(); - @Before + @BeforeEach public void setUp() throws Exception { KeyPair minerNodeKeyPair = createKeyPair(MINER_NODE_PRIVATE_KEY); KeyPair otherNodeKeyPair = createKeyPair(OTHER_NODE_PRIVATE_KEY); diff --git a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/database/DatabaseMigrationAcceptanceTest.java b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/database/DatabaseMigrationAcceptanceTest.java index 291506498ba..b2166a1cc58 100644 --- a/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/database/DatabaseMigrationAcceptanceTest.java +++ b/acceptance-tests/tests/src/test/java/org/hyperledger/besu/tests/acceptance/database/DatabaseMigrationAcceptanceTest.java @@ -28,49 +28,31 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; +import java.util.stream.Stream; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) public class DatabaseMigrationAcceptanceTest extends org.hyperledger.besu.tests.acceptance.AbstractPreexistingNodeTest { - private final long expectedChainHeight; private BesuNode node; - private final List testAccounts; - public DatabaseMigrationAcceptanceTest( - final String testName, - final String dataPath, - final long expectedChainHeight, - final List testAccounts) { - super(testName, dataPath); - this.expectedChainHeight = expectedChainHeight; - this.testAccounts = testAccounts; + public static Stream getParameters() { + // First 10 blocks of ropsten + return Stream.of( + Arguments.of( + "After versioning was enabled and using multiple RocksDB columns", + "version1", + 0xA, + singletonList( + new AccountData( + "0xd1aeb42885a43b72b518182ef893125814811048", + BigInteger.valueOf(0xA), + Wei.fromHexString("0x2B5E3AF16B1880000"))))); } - @Parameters(name = "{0}") - public static Object[][] getParameters() { - return new Object[][] { - // First 10 blocks of ropsten - new Object[] { - "After versioning was enabled and using multiple RocksDB columns", - "version1", - 0xA, - singletonList( - new AccountData( - "0xd1aeb42885a43b72b518182ef893125814811048", - BigInteger.valueOf(0xA), - Wei.fromHexString("0x2B5E3AF16B1880000"))) - } - }; - } - - @Before - public void setUp() throws Exception { + public void setUp(final String testName, final String dataPath) throws Exception { final URL rootURL = DatabaseMigrationAcceptanceTest.class.getResource(dataPath); hostDataPath = copyDataDir(rootURL); final Path databaseArchive = @@ -83,13 +65,27 @@ public void setUp() throws Exception { cluster.start(node); } - @Test - public void shouldReturnCorrectBlockHeight() { + @ParameterizedTest(name = "{index}: {0}") + @MethodSource("getParameters") + public void shouldReturnCorrectBlockHeight( + final String testName, + final String dataPath, + final long expectedChainHeight, + final List testAccounts) + throws Exception { + setUp(testName, dataPath); blockchain.currentHeight(expectedChainHeight).verify(node); } - @Test - public void shouldReturnCorrectAccountBalance() { + @ParameterizedTest(name = "{index}: {0}") + @MethodSource("getParameters") + public void shouldReturnCorrectAccountBalance( + final String testName, + final String dataPath, + final long expectedChainHeight, + final List testAccounts) + throws Exception { + setUp(testName, dataPath); testAccounts.forEach( accountData -> accounts