mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-20 07:46:05 -04:00
Add skeleton for network stress unit test
This commit is contained in:
parent
e910233b4c
commit
fdc0eafc67
@ -0,0 +1,55 @@
|
||||
package io.bitsquare.p2p.network;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
|
||||
public class NetworkStressTest {
|
||||
private Path tempDir;
|
||||
|
||||
@Before
|
||||
public void setup() throws IOException {
|
||||
tempDir = createTempDirectory();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws IOException {
|
||||
if (tempDir != null) {
|
||||
deleteRecursively(tempDir);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
private Path createTempDirectory() throws IOException {
|
||||
return Files.createTempDirectory("bsq" + this.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
private static void deleteRecursively(@NotNull final Path path) throws IOException {
|
||||
// Based on <https://stackoverflow.com/a/27917071/6239236> by Tomasz Dzięcielewski.
|
||||
Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
Files.delete(path);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
|
||||
Files.delete(dir);
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user