From e39a9a4a3543911cb00c54260d8ddc4f3cfbe796 Mon Sep 17 00:00:00 2001 From: Sally MacFarlane Date: Tue, 12 Dec 2023 10:39:55 +1000 Subject: [PATCH] [MINOR] migrate remaining Crypto tests to junit 5 (#6280) * update crypto tests to junit5 * fixed temp file * removed vintage junit dep Signed-off-by: Sally MacFarlane --------- Signed-off-by: Sally MacFarlane Signed-off-by: jflo --- crypto/services/build.gradle | 3 --- .../cryptoservices/KeyPairSecurityModuleTest.java | 14 +++++--------- .../besu/cryptoservices/NodeKeyTest.java | 6 +++--- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/crypto/services/build.gradle b/crypto/services/build.gradle index f6e082836c0..53b46d57473 100644 --- a/crypto/services/build.gradle +++ b/crypto/services/build.gradle @@ -32,11 +32,8 @@ dependencies { api project(':crypto:algorithms') api project(':plugin-api') - testImplementation 'junit:junit' testImplementation 'org.assertj:assertj-core' testImplementation 'org.junit.jupiter:junit-jupiter' - - testRuntimeOnly 'org.junit.vintage:junit-vintage-engine' } artifacts { testSupportArtifacts testSupportJar } diff --git a/crypto/services/src/test/java/org/hyperledger/besu/cryptoservices/KeyPairSecurityModuleTest.java b/crypto/services/src/test/java/org/hyperledger/besu/cryptoservices/KeyPairSecurityModuleTest.java index 68d369ae538..fac403e041d 100644 --- a/crypto/services/src/test/java/org/hyperledger/besu/cryptoservices/KeyPairSecurityModuleTest.java +++ b/crypto/services/src/test/java/org/hyperledger/besu/cryptoservices/KeyPairSecurityModuleTest.java @@ -20,26 +20,22 @@ import org.hyperledger.besu.crypto.SECPPublicKey; import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; -import java.io.File; import java.io.IOException; +import java.nio.file.Path; import java.security.spec.ECPoint; import org.apache.tuweni.bytes.Bytes; import org.assertj.core.api.Assertions; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; public class KeyPairSecurityModuleTest { - @Rule public final TemporaryFolder temp = new TemporaryFolder(); + @TempDir public Path keyFile; @Test public void validatePublicKeyFromECPointCanBeConstructed() throws IOException { - final File keyDirectory = temp.newFolder(); - final File keyFile = new File(keyDirectory, "key"); - - final KeyPair keyPair = KeyPairUtil.loadKeyPair(keyFile); + final KeyPair keyPair = KeyPairUtil.loadKeyPair(keyFile.resolve("key")); final KeyPairSecurityModule keyPairSecurityModule = new KeyPairSecurityModule(keyPair); final ECPoint ecPoint = keyPairSecurityModule.getPublicKey().getW(); diff --git a/crypto/services/src/test/java/org/hyperledger/besu/cryptoservices/NodeKeyTest.java b/crypto/services/src/test/java/org/hyperledger/besu/cryptoservices/NodeKeyTest.java index 07008f06cbc..261271aee9b 100644 --- a/crypto/services/src/test/java/org/hyperledger/besu/cryptoservices/NodeKeyTest.java +++ b/crypto/services/src/test/java/org/hyperledger/besu/cryptoservices/NodeKeyTest.java @@ -21,12 +21,12 @@ import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; import org.assertj.core.api.Assertions; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; public class NodeKeyTest { - @Before + @BeforeEach public void resetInstance() { SignatureAlgorithmFactory.resetInstance(); }