Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
clearing temp directories
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksabor committed Jul 12, 2019
1 parent 1964898 commit 50a5d83
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.concurrent.ConcurrentLinkedQueue;

public class CodegenIgnoreProcessorTest {

Expand All @@ -25,6 +26,7 @@ public class CodegenIgnoreProcessorTest {
private String outputDir;
private File target;
private Path temp;
private static final ConcurrentLinkedQueue<Path> tempQueue = new ConcurrentLinkedQueue<>();

private CodegenIgnoreProcessorTest(String filename, String ignoreDefinition, String description) throws IOException {
this.filename = filename;
Expand All @@ -51,6 +53,7 @@ private void prepareTestFiles() throws IOException {
// NOTE: Each test needs its own directory because .swagger-codegen-ignore needs to exist at the root.
temp = Files.createTempDirectory(getClass().getSimpleName());
this.outputDir = temp.toFile().getAbsolutePath();
tempQueue.add(temp);

target = new File(this.outputDir, this.filename);

Expand All @@ -73,9 +76,11 @@ private void prepareTestFiles() throws IOException {

@AfterTest
public void afterTest() throws IOException {
if(temp != null && temp.toFile().exists() && temp.toFile().isDirectory()) {
FileUtils.deleteDirectory(temp.toFile());
}
Path t;
while ((t = tempQueue.poll()) != null)
if(t != null && t.toFile().exists() && t.toFile().isDirectory()) {
FileUtils.deleteDirectory(t.toFile());
}
}

@Test
Expand Down

0 comments on commit 50a5d83

Please sign in to comment.