12
12
import java .io .IOException ;
13
13
import java .nio .file .Files ;
14
14
import java .nio .file .Path ;
15
+ import java .util .concurrent .ConcurrentLinkedQueue ;
15
16
16
17
public class CodegenIgnoreProcessorTest {
17
18
@@ -25,6 +26,7 @@ public class CodegenIgnoreProcessorTest {
25
26
private String outputDir ;
26
27
private File target ;
27
28
private Path temp ;
29
+ private static final ConcurrentLinkedQueue <Path > tempQueue = new ConcurrentLinkedQueue <>();
28
30
29
31
private CodegenIgnoreProcessorTest (String filename , String ignoreDefinition , String description ) throws IOException {
30
32
this .filename = filename ;
@@ -51,6 +53,7 @@ private void prepareTestFiles() throws IOException {
51
53
// NOTE: Each test needs its own directory because .swagger-codegen-ignore needs to exist at the root.
52
54
temp = Files .createTempDirectory (getClass ().getSimpleName ());
53
55
this .outputDir = temp .toFile ().getAbsolutePath ();
56
+ tempQueue .add (temp );
54
57
55
58
target = new File (this .outputDir , this .filename );
56
59
@@ -73,9 +76,11 @@ private void prepareTestFiles() throws IOException {
73
76
74
77
@ AfterTest
75
78
public void afterTest () throws IOException {
76
- if (temp != null && temp .toFile ().exists () && temp .toFile ().isDirectory ()) {
77
- FileUtils .deleteDirectory (temp .toFile ());
78
- }
79
+ Path t ;
80
+ while ((t = tempQueue .poll ()) != null )
81
+ if (t != null && t .toFile ().exists () && t .toFile ().isDirectory ()) {
82
+ FileUtils .deleteDirectory (t .toFile ());
83
+ }
79
84
}
80
85
81
86
@ Test
0 commit comments