junit4 to junit5 (#5598)

Signed-off-by: Nischal Sharma <nischal@web3labs.com>
This commit is contained in:
Nischal Sharma
2023-06-15 04:38:39 +05:30
committed by GitHub
parent 2d63987566
commit 54500740b6
2 changed files with 7 additions and 8 deletions

View File

@@ -14,7 +14,6 @@ dependencies {
// test dependencies.
testImplementation project(':testutil')
testImplementation 'junit:junit'
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.junit.jupiter:junit-jupiter'

View File

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