summaryrefslogtreecommitdiff
path: root/src/test/java/com/keuin/kbackupfabric/operation
diff options
context:
space:
mode:
authorKeuin <[email protected]>2023-01-13 03:10:48 +0800
committerKeuin <[email protected]>2023-01-13 03:10:48 +0800
commit97e028f605d1aa060e4a4640a3dd683e51eaef3a (patch)
tree8b69515fcabfe5fae503dc09987c5c3d9866836a /src/test/java/com/keuin/kbackupfabric/operation
parentd7b2dd139f7e17d149a50a2ee777d28dac64b9eb (diff)
Move temporary files to standard path in IncBackupBackwardCompatibilityTest.
Diffstat (limited to 'src/test/java/com/keuin/kbackupfabric/operation')
-rw-r--r--src/test/java/com/keuin/kbackupfabric/operation/backup/method/ConfiguredIncrementalBackupMethodTest.java34
1 files changed, 3 insertions, 31 deletions
diff --git a/src/test/java/com/keuin/kbackupfabric/operation/backup/method/ConfiguredIncrementalBackupMethodTest.java b/src/test/java/com/keuin/kbackupfabric/operation/backup/method/ConfiguredIncrementalBackupMethodTest.java
index 0741004..1fb3414 100644
--- a/src/test/java/com/keuin/kbackupfabric/operation/backup/method/ConfiguredIncrementalBackupMethodTest.java
+++ b/src/test/java/com/keuin/kbackupfabric/operation/backup/method/ConfiguredIncrementalBackupMethodTest.java
@@ -1,5 +1,6 @@
package com.keuin.kbackupfabric.operation.backup.method;
+import com.keuin.kbackupfabric.TestUtils;
import com.keuin.kbackupfabric.backup.name.IncrementalBackupFileNameEncoder;
import com.keuin.kbackupfabric.metadata.BackupMetadata;
import com.keuin.kbackupfabric.operation.backup.feedback.IncrementalBackupFeedback;
@@ -23,8 +24,6 @@ import static org.apache.commons.io.FileUtils.forceDelete;
import static org.junit.Assert.*;
public class ConfiguredIncrementalBackupMethodTest {
-
- public static final String SUBDIRECTORY = "kb_temp";
private String testTempPath;
private final String sourceDirectoryName = "source";
private final String destDirectoryName = "destination";
@@ -41,40 +40,13 @@ public class ConfiguredIncrementalBackupMethodTest {
@Before
public void setUp() throws IOException {
// select temporary directory
- String path = System.getenv("KB_TEMP_DIR");
- if (path != null && !path.isEmpty() && new File(path).isDirectory()) {
- testTempPath = Paths.get(path, SUBDIRECTORY).toString();
- } else {
- testTempPath = findTempPath();
- }
+ testTempPath = TestUtils.getTempDirectory("kb_temp");
logger.info(String.format("Using temp path: %s", testTempPath));
}
- private static String findTempPath() throws IOException {
- String path;
- if (System.getProperty("os.name").startsWith("Windows")) {
- // Windows
- path = System.getProperty("java.io.tmpdir");
- } else {
- // Unix
- path = System.getenv("XDG_RUNTIME_DIR");
- if (!new File(path).isDirectory()) {
- path = "/tmp";
- }
- }
- if (!new File(path).isDirectory()) {
- throw new IOException("Cannot find suitable temporary path");
- }
- path = Paths.get(path, SUBDIRECTORY).toString();
- return path;
- }
-
@After
public void tearDown() throws IOException {
- if (testTempPath.endsWith(SUBDIRECTORY)) {
- // recursive delete with safeguard
- FileUtils.deleteDirectory(new File(testTempPath));
- }
+ FileUtils.deleteDirectory(new File(testTempPath));
}
@Test