From dc23ef7996ebd5243be54db9bcea430176a6f6bf Mon Sep 17 00:00:00 2001 From: James Netherton Date: Mon, 25 Jul 2022 08:43:02 +0100 Subject: [PATCH] Delete potentially locked file on VM exit for Windows dev mode test --- ...ncludePatternWithAbsoluteFilePrefixDevModeTest.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/integration-tests/main-devmode/src/test/java/org/apache/camel/quarkus/main/CamelMainRoutesIncludePatternWithAbsoluteFilePrefixDevModeTest.java b/integration-tests/main-devmode/src/test/java/org/apache/camel/quarkus/main/CamelMainRoutesIncludePatternWithAbsoluteFilePrefixDevModeTest.java index 4a0377219157..23b43e9a0b83 100644 --- a/integration-tests/main-devmode/src/test/java/org/apache/camel/quarkus/main/CamelMainRoutesIncludePatternWithAbsoluteFilePrefixDevModeTest.java +++ b/integration-tests/main-devmode/src/test/java/org/apache/camel/quarkus/main/CamelMainRoutesIncludePatternWithAbsoluteFilePrefixDevModeTest.java @@ -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; @@ -64,10 +66,16 @@ public static void setUp() { @AfterAll public static void cleanUp() throws IOException { + Consumer 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() {