From 54500740b6717b5d9b7e8971818af2c802299214 Mon Sep 17 00:00:00 2001 From: Nischal Sharma Date: Thu, 15 Jun 2023 04:38:39 +0530 Subject: [PATCH] junit4 to junit5 (#5598) Signed-off-by: Nischal Sharma --- enclave/build.gradle | 1 - .../besu/enclave/EnclaveFactoryTest.java | 14 +++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/enclave/build.gradle b/enclave/build.gradle index ff3343462c..235962cda7 100644 --- a/enclave/build.gradle +++ b/enclave/build.gradle @@ -14,7 +14,6 @@ dependencies { // test dependencies. testImplementation project(':testutil') - testImplementation 'junit:junit' testImplementation 'org.assertj:assertj-core' testImplementation 'org.junit.jupiter:junit-jupiter' diff --git a/enclave/src/test/java/org/hyperledger/besu/enclave/EnclaveFactoryTest.java b/enclave/src/test/java/org/hyperledger/besu/enclave/EnclaveFactoryTest.java index 1d37e21cd5..7223971719 100644 --- a/enclave/src/test/java/org/hyperledger/besu/enclave/EnclaveFactoryTest.java +++ b/enclave/src/test/java/org/hyperledger/besu/enclave/EnclaveFactoryTest.java @@ -23,24 +23,24 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; public class EnclaveFactoryTest { - @ClassRule public static final TemporaryFolder temporaryFolder = new TemporaryFolder(); + @TempDir File tempDir; private static final String EMPTY_FILE_ERROR_MSG = "Keystore password file is empty: %s"; @Test public void passwordCanBeReadFromFile() throws IOException { - final File passwordFile = temporaryFolder.newFile(); + File passwordFile = new File(tempDir, "password.txt"); Files.writeString(passwordFile.toPath(), "test" + System.lineSeparator() + "test2"); assertThat(EnclaveFactory.readSecretFromFile(passwordFile.toPath())).isEqualTo("test"); } @Test public void emptyFileThrowsException() throws IOException { - final File passwordFile = temporaryFolder.newFile(); + File passwordFile = new File(tempDir, "password.txt"); + Files.createFile(passwordFile.toPath()); // Create an empty file assertThatExceptionOfType(InvalidConfigurationException.class) .isThrownBy(() -> EnclaveFactory.readSecretFromFile(passwordFile.toPath())) .withMessage(EMPTY_FILE_ERROR_MSG, passwordFile); @@ -48,7 +48,7 @@ public class EnclaveFactoryTest { @Test public void fileWithOnlyEoLThrowsException() throws IOException { - final File passwordFile = temporaryFolder.newFile(); + File passwordFile = new File(tempDir, "password.txt"); Files.writeString(passwordFile.toPath(), System.lineSeparator()); assertThatExceptionOfType(InvalidConfigurationException.class) .isThrownBy(() -> EnclaveFactory.readSecretFromFile(passwordFile.toPath()))