Skip to content

Commit

Permalink
Delete potentially locked file on VM exit for Windows dev mode test
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnetherton committed Jul 25, 2022
1 parent f7ff5c2 commit dc23ef7
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
import java.util.Comparator;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;

import io.quarkus.test.QuarkusDevModeTest;
import io.restassured.RestAssured;
import io.restassured.response.Response;
import org.apache.camel.quarkus.core.util.FileUtils;
import org.apache.camel.util.FileUtil;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.Asset;
import org.jboss.shrinkwrap.api.asset.StringAsset;
Expand Down Expand Up @@ -64,10 +66,16 @@ public static void setUp() {

@AfterAll
public static void cleanUp() throws IOException {
Consumer<? super File> deleteFile = File::delete;
if (FileUtil.isWindows()) {
// File may be locked by the Quarkus process, so clean up on VM exit
deleteFile = File::deleteOnExit;
}

Files.walk(BASE)
.sorted(Comparator.reverseOrder())
.map(Path::toFile)
.forEach(File::delete);
.forEach(deleteFile);
}

public static Asset applicationProperties() {
Expand Down

0 comments on commit dc23ef7

Please sign in to comment.