Skip to content

Commit

Permalink
Ensure @QuarkusIntegrationTest works properly with any Filesystem path
Browse files Browse the repository at this point in the history
  • Loading branch information
geoand committed Jun 2, 2021
1 parent ebcc316 commit 644d16b
Showing 1 changed file with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
}
}

0 comments on commit 644d16b

Please sign in to comment.