forked from utPLSQL/utPLSQL-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractFileOutputTest.java
More file actions
42 lines (33 loc) · 956 Bytes
/
AbstractFileOutputTest.java
File metadata and controls
42 lines (33 loc) · 956 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package org.utplsql.cli;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import java.io.File;
import java.nio.file.Path;
import java.util.HashSet;
import java.util.Set;
public abstract class AbstractFileOutputTest {
private Set<Path> tempPaths;
protected void addTempPath(Path path) {
tempPaths.add(path);
}
protected boolean tempPathExists( Path path ) { return tempPaths.contains(path); }
@BeforeEach
public void setupTest() {
tempPaths = new HashSet<>();
}
@AfterEach
public void deleteTempFiles() {
tempPaths.forEach(p -> deleteDir(p.toFile()));
}
void deleteDir(File file) {
if (file.exists()) {
File[] contents = file.listFiles();
if (contents != null) {
for (File f : contents) {
deleteDir(f);
}
}
file.delete();
}
}
}