junit4 to junit5 (#5598)

Signed-off-by: Nischal Sharma <nischal@web3labs.com>
pull/5606/head
Nischal Sharma 1 year ago committed by GitHub
parent 2d63987566
commit 54500740b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      enclave/build.gradle
  2. 14
      enclave/src/test/java/org/hyperledger/besu/enclave/EnclaveFactoryTest.java

@ -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()))

Loading…
Cancel
Save