diff --git a/test-framework/common/src/main/java/io/quarkus/test/common/PathTestHelper.java b/test-framework/common/src/main/java/io/quarkus/test/common/PathTestHelper.java index 17d6c874fe54d..a45fa856ce743 100644 --- a/test-framework/common/src/main/java/io/quarkus/test/common/PathTestHelper.java +++ b/test-framework/common/src/main/java/io/quarkus/test/common/PathTestHelper.java @@ -168,25 +168,27 @@ public static Path getTestClassesLocation(Class testClass) { * @return directory or JAR containing the application being tested by the test class */ public static Path getAppClassLocation(Class testClass) { - return getAppClassLocationForTestLocation(getTestClassesLocation(testClass).toString()); + return getAppClassLocationForTestLocation(getTestClassesLocation(testClass)); } /** * Resolves the directory or the JAR file containing the application being tested by a test from the given location. * - * @param testClassLocation the test class location + * @param testClassLocationPath the test class location * @return directory or JAR containing the application being tested by a test from the given location */ - public static Path getAppClassLocationForTestLocation(String testClassLocation) { - if (testClassLocation.endsWith(".jar")) { - if (testClassLocation.endsWith("-tests.jar")) { + public static Path getAppClassLocationForTestLocation(Path testClassLocationPath) { + if (testClassLocationPath.endsWith(".jar")) { + if (testClassLocationPath.endsWith("-tests.jar")) { + String testClassLocation = testClassLocationPath.toString(); return Paths.get(new StringBuilder() .append(testClassLocation, 0, testClassLocation.length() - "-tests.jar".length()) .append(".jar") .toString()); } - return Path.of(testClassLocation); + return testClassLocationPath; } + String testClassLocation = testClassLocationPath.toString(); Optional mainClassesDir = TEST_TO_MAIN_DIR_FRAGMENTS.entrySet().stream() .filter(e -> testClassLocation.contains(e.getKey())) .map(e -> { diff --git a/test-framework/junit5-internal/src/main/java/io/quarkus/test/QuarkusProdModeTest.java b/test-framework/junit5-internal/src/main/java/io/quarkus/test/QuarkusProdModeTest.java index 0f012ffcde3a4..8112d0aeca0bb 100644 --- a/test-framework/junit5-internal/src/main/java/io/quarkus/test/QuarkusProdModeTest.java +++ b/test-framework/junit5-internal/src/main/java/io/quarkus/test/QuarkusProdModeTest.java @@ -409,7 +409,7 @@ public void close() throws Throwable { // sources nor resources, we need to create an empty classes dir to satisfy the resolver // as this project will appear as the root application artifact during the bootstrap if (Files.isDirectory(testLocation)) { - final Path projectClassesDir = PathTestHelper.getAppClassLocationForTestLocation(testLocation.toString()); + final Path projectClassesDir = PathTestHelper.getAppClassLocationForTestLocation(testLocation); if (!Files.exists(projectClassesDir)) { Files.createDirectories(projectClassesDir); } diff --git a/test-framework/junit5/src/main/java/io/quarkus/test/junit/AbstractJvmQuarkusTestExtension.java b/test-framework/junit5/src/main/java/io/quarkus/test/junit/AbstractJvmQuarkusTestExtension.java index 5b73fbfaaaf2c..29a6eab03c2ac 100644 --- a/test-framework/junit5/src/main/java/io/quarkus/test/junit/AbstractJvmQuarkusTestExtension.java +++ b/test-framework/junit5/src/main/java/io/quarkus/test/junit/AbstractJvmQuarkusTestExtension.java @@ -134,7 +134,7 @@ protected PrepareResult createAugmentor(ExtensionContext context, Class requiredTestClass = context.getRequiredTestClass(); Path testClassLocation = getTestClassesLocation(requiredTestClass); - final Path appClassLocation = getAppClassLocationForTestLocation(testClassLocation.toString()); + final Path appClassLocation = getAppClassLocationForTestLocation(testClassLocation); final PathList.Builder rootBuilder = PathList.builder();