mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
[bug-69715] update tests
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1926446 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
47f2d72d35
commit
d8b3934646
@ -27,6 +27,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
@ -69,7 +70,7 @@ class DefaultTempFileCreationStrategyTest {
|
||||
try {
|
||||
assertTrue(Files.isDirectory(dir.toPath()), "File is not a directory: " + dir);
|
||||
DefaultTempFileCreationStrategy testStrategy = new DefaultTempFileCreationStrategy(dir);
|
||||
checkGetFile(testStrategy);
|
||||
checkGetFileAndPath(testStrategy, dir.toPath());
|
||||
} finally {
|
||||
// Clean up the directory after the test
|
||||
FileUtils.deleteDirectory(dir);
|
||||
@ -84,7 +85,7 @@ class DefaultTempFileCreationStrategyTest {
|
||||
assertTrue(dir.delete(), "directory not deleted: " + dir);
|
||||
try {
|
||||
DefaultTempFileCreationStrategy testStrategy = new DefaultTempFileCreationStrategy(dir);
|
||||
checkGetFile(testStrategy);
|
||||
checkGetFileAndPath(testStrategy, dir.toPath());
|
||||
} finally {
|
||||
// Clean up the directory after the test
|
||||
FileUtils.deleteDirectory(dir);
|
||||
@ -104,8 +105,18 @@ class DefaultTempFileCreationStrategyTest {
|
||||
}
|
||||
|
||||
private static void checkGetFile(DefaultTempFileCreationStrategy strategy) throws IOException {
|
||||
checkGetFileAndPath(strategy, null);
|
||||
}
|
||||
|
||||
private static void checkGetFileAndPath(DefaultTempFileCreationStrategy strategy,
|
||||
Path path) throws IOException {
|
||||
File file = strategy.createTempFile("POITest", ".tmp");
|
||||
try {
|
||||
if (path != null) {
|
||||
assertTrue(file.toPath().startsWith(path),
|
||||
"File path does not start with expected path: " + path);
|
||||
}
|
||||
|
||||
assertTrue(file.getParentFile().exists(),
|
||||
"Failed for " + file.getParentFile());
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user