mirror of
https://github.com/vacp2p/linea-besu.git
synced 2026-01-09 15:37:54 -05:00
junit4 to junit5 (#5598)
Signed-off-by: Nischal Sharma <nischal@web3labs.com>
This commit is contained in:
@@ -14,7 +14,6 @@ dependencies {
|
||||
// test dependencies.
|
||||
testImplementation project(':testutil')
|
||||
|
||||
testImplementation 'junit:junit'
|
||||
testImplementation 'org.assertj:assertj-core'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
|
||||
|
||||
@@ -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()))
|
||||
|
||||
Reference in New Issue
Block a user