Skip to content

Commit

Permalink
junit4 to junit5 (#5598)
Browse files Browse the repository at this point in the history
Signed-off-by: Nischal Sharma <nischal@web3labs.com>
  • Loading branch information
NickSneo authored Jun 14, 2023
1 parent 2d63987 commit 5450074
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
1 change: 0 additions & 1 deletion enclave/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ dependencies {
// test dependencies.
testImplementation project(':testutil')

testImplementation 'junit:junit'
testImplementation 'org.assertj:assertj-core'
testImplementation 'org.junit.jupiter:junit-jupiter'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,32 @@
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);
}

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

0 comments on commit 5450074

Please sign in to comment.