summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/keuin/kbackupfabric/backup/incremental/manager/IncrementalBackupStorageManagerTest.java18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/test/java/com/keuin/kbackupfabric/backup/incremental/manager/IncrementalBackupStorageManagerTest.java b/src/test/java/com/keuin/kbackupfabric/backup/incremental/manager/IncrementalBackupStorageManagerTest.java
index 2a9420a..7b2d7f0 100644
--- a/src/test/java/com/keuin/kbackupfabric/backup/incremental/manager/IncrementalBackupStorageManagerTest.java
+++ b/src/test/java/com/keuin/kbackupfabric/backup/incremental/manager/IncrementalBackupStorageManagerTest.java
@@ -18,6 +18,7 @@ import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.*;
+import java.util.stream.Stream;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -71,13 +72,16 @@ public class IncrementalBackupStorageManagerTest {
throw new IllegalArgumentException("negative count");
int[] c = new int[]{0};
Random rnd = new Random();
- Files.walk(new File(srcRoot).toPath(), 1).map(p -> rnd.nextBoolean() ? p : null)
- .filter(Objects::nonNull).forEach(p -> {
- if (c[0]++ != count) {
- if (!p.toFile().delete() && p.toFile().isFile())
- throw new RuntimeException("Failed to delete file " + p);
- }
- });
+ try (Stream<Path> walk = Files.walk(new File(srcRoot).toPath(), 1)) {
+ walk.map(p -> rnd.nextBoolean() ? p : null)
+ .filter(Objects::nonNull)
+ .forEach(p -> {
+ if (c[0]++ != count) {
+ if (!p.toFile().delete() && p.toFile().isFile())
+ throw new RuntimeException("Failed to delete file " + p);
+ }
+ });
+ }
}
private static String getRandomString(int length) {