Skip to content

Commit 0eac0de

Browse files
committed
Improve type safety of method signature
1 parent db7df2e commit 0eac0de

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

test-framework/common/src/main/java/io/quarkus/test/common/PathTestHelper.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -168,25 +168,27 @@ public static Path getTestClassesLocation(Class<?> testClass) {
168168
* @return directory or JAR containing the application being tested by the test class
169169
*/
170170
public static Path getAppClassLocation(Class<?> testClass) {
171-
return getAppClassLocationForTestLocation(getTestClassesLocation(testClass).toString());
171+
return getAppClassLocationForTestLocation(getTestClassesLocation(testClass));
172172
}
173173

174174
/**
175175
* Resolves the directory or the JAR file containing the application being tested by a test from the given location.
176176
*
177-
* @param testClassLocation the test class location
177+
* @param testClassLocationPath the test class location
178178
* @return directory or JAR containing the application being tested by a test from the given location
179179
*/
180-
public static Path getAppClassLocationForTestLocation(String testClassLocation) {
181-
if (testClassLocation.endsWith(".jar")) {
182-
if (testClassLocation.endsWith("-tests.jar")) {
180+
public static Path getAppClassLocationForTestLocation(Path testClassLocationPath) {
181+
if (testClassLocationPath.endsWith(".jar")) {
182+
if (testClassLocationPath.endsWith("-tests.jar")) {
183+
String testClassLocation = testClassLocationPath.toString();
183184
return Paths.get(new StringBuilder()
184185
.append(testClassLocation, 0, testClassLocation.length() - "-tests.jar".length())
185186
.append(".jar")
186187
.toString());
187188
}
188-
return Path.of(testClassLocation);
189+
return testClassLocationPath;
189190
}
191+
String testClassLocation = testClassLocationPath.toString();
190192
Optional<Path> mainClassesDir = TEST_TO_MAIN_DIR_FRAGMENTS.entrySet().stream()
191193
.filter(e -> testClassLocation.contains(e.getKey()))
192194
.map(e -> {

test-framework/junit5-internal/src/main/java/io/quarkus/test/QuarkusProdModeTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ public void close() throws Throwable {
409409
// sources nor resources, we need to create an empty classes dir to satisfy the resolver
410410
// as this project will appear as the root application artifact during the bootstrap
411411
if (Files.isDirectory(testLocation)) {
412-
final Path projectClassesDir = PathTestHelper.getAppClassLocationForTestLocation(testLocation.toString());
412+
final Path projectClassesDir = PathTestHelper.getAppClassLocationForTestLocation(testLocation);
413413
if (!Files.exists(projectClassesDir)) {
414414
Files.createDirectories(projectClassesDir);
415415
}

test-framework/junit5/src/main/java/io/quarkus/test/junit/AbstractJvmQuarkusTestExtension.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ protected PrepareResult createAugmentor(ExtensionContext context, Class<? extend
134134
}
135135

136136
testClassLocation = getTestClassesLocation(requiredTestClass);
137-
appClassLocation = getAppClassLocationForTestLocation(testClassLocation.toString());
137+
appClassLocation = getAppClassLocationForTestLocation(testClassLocation);
138138
if (!appClassLocation.equals(testClassLocation)) {
139139
addToBuilderIfConditionMet.accept(testClassLocation);
140140
// if test classes is a dir, we should also check whether test resources dir exists as a separate dir (gradle)

test-framework/junit5/src/main/java/io/quarkus/test/junit/IntegrationTestUtil.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ static ArtifactLauncher.InitContext.DevServicesLaunchResult handleDevServices(Ex
176176
boolean isDockerAppLaunch) throws Exception {
177177
Class<?> requiredTestClass = context.getRequiredTestClass();
178178
Path testClassLocation = getTestClassesLocation(requiredTestClass);
179-
final Path appClassLocation = getAppClassLocationForTestLocation(testClassLocation.toString());
179+
final Path appClassLocation = getAppClassLocationForTestLocation(testClassLocation);
180180

181181
final PathList.Builder rootBuilder = PathList.builder();
182182

0 commit comments

Comments
 (0)