diff --git a/test-framework/junit5/src/main/java/io/quarkus/test/junit/IntegrationTestUtil.java b/test-framework/junit5/src/main/java/io/quarkus/test/junit/IntegrationTestUtil.java index a3900bcf5cdf7e..5e9ea186c764a4 100644 --- a/test-framework/junit5/src/main/java/io/quarkus/test/junit/IntegrationTestUtil.java +++ b/test-framework/junit5/src/main/java/io/quarkus/test/junit/IntegrationTestUtil.java @@ -8,6 +8,8 @@ import java.io.IOException; import java.io.UncheckedIOException; import java.lang.reflect.Field; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.nio.file.Files; import java.nio.file.Path; @@ -23,6 +25,7 @@ import javax.enterprise.inject.Alternative; import javax.inject.Inject; +import com.sun.jndi.toolkit.url.Uri; import org.jboss.jandex.Index; import org.junit.jupiter.api.extension.ExtensionContext; import org.junit.platform.commons.JUnitException; @@ -280,18 +283,28 @@ private static File determineBuildOutputDirectory(final URL url) { } if (url.getProtocol().equals("file") && url.getPath().endsWith("test-classes/")) { //we have the maven test classes dir - File testClasses = new File(url.getPath()); - return testClasses.getParentFile(); + return toPath(url).getParent().toFile(); } else if (url.getProtocol().equals("file") && url.getPath().endsWith("test/")) { //we have the gradle test classes dir, build/classes/java/test - File testClasses = new File(url.getPath()); - return testClasses.getParentFile().getParentFile().getParentFile(); + return toPath(url).getParent().getParent().getParent().toFile(); } else if (url.getProtocol().equals("file") && url.getPath().contains("/target/surefire/")) { //this will make mvn failsafe:integration-test work String path = url.getPath(); int index = path.lastIndexOf("/target/"); - return new File(path.substring(0, index) + "/target/"); + try { + return Paths.get(new URI("file:" + (path.substring(0, index) + "/target/"))).toFile(); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } } return null; } + + private static Path toPath(URL url) { + try { + return Paths.get(url.toURI()); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + } }