mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-03 04:06:23 -04:00
Move test data removal logic to instance method
This commit is contained in:
parent
e12d61d026
commit
b02c5bf2be
1 changed files with 7 additions and 5 deletions
|
@ -140,9 +140,9 @@ public class NetworkStressTest {
|
||||||
// Wait for concurrent tasks to finish.
|
// Wait for concurrent tasks to finish.
|
||||||
shutdownLatch.await();
|
shutdownLatch.await();
|
||||||
|
|
||||||
// Cleanup directory if not given explicitly.
|
// Cleanup temporary directory.
|
||||||
if (tempDir != null && System.getenv(TEST_DIR_ENVVAR) == null) {
|
if (tempDir != null) {
|
||||||
deleteRecursively(tempDir);
|
deleteTempDirectory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,9 +173,11 @@ public class NetworkStressTest {
|
||||||
return stressTestDirPath;
|
return stressTestDirPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void deleteRecursively(@NotNull final Path path) throws IOException {
|
private void deleteTempDirectory() throws IOException {
|
||||||
// Based on <https://stackoverflow.com/a/27917071/6239236> by Tomasz Dzięcielewski.
|
// Based on <https://stackoverflow.com/a/27917071/6239236> by Tomasz Dzięcielewski.
|
||||||
Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
|
if (System.getenv(TEST_DIR_ENVVAR) != null)
|
||||||
|
return; // do not remove if given explicitly
|
||||||
|
Files.walkFileTree(tempDir, new SimpleFileVisitor<Path>() {
|
||||||
@Override
|
@Override
|
||||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||||
Files.delete(file);
|
Files.delete(file);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue