Skip to content

Commit

Permalink
Fix Gradle tests started with Java 23
Browse files Browse the repository at this point in the history
  • Loading branch information
snjeza committed Aug 12, 2024
1 parent ebd30cd commit 5ffb6ec
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
import java.util.Map.Entry;
import java.util.stream.Stream;

import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -218,7 +218,7 @@ private static File getGradleInitScriptTempFile(String scriptPath) {
* <ul>
* @param initScript the init script file.
* @param checksum the expected checksum of the file.
*
*
* @throws IOException
* @throws NoSuchAlgorithmException
*/
Expand Down Expand Up @@ -260,7 +260,7 @@ public static Map<String, String> parseProcessorOptions(List<Object> compilerArg
return Collections.emptyMap();
}
Map<String, String> options = new HashMap<>();

for(Object arg : compilerArgs) {
String argString = String.valueOf(arg);
if (argString.startsWith("-A")) {
Expand Down Expand Up @@ -338,11 +338,12 @@ public static File getJdkToLaunchDaemon(String highestJavaVersion) {
* The results are returned as map, where key is the major version and value is the file instance of
* the installation.
*/
private static Map<String, File> getAllVmInstalls() {
public static Map<String, File> getAllVmInstalls() {
List<IVMInstall> vmList = Stream.of(JavaRuntime.getVMInstallTypes())
.map(IVMInstallType::getVMInstalls)
.flatMap(Arrays::stream)
.toList();
// https://github.com/eclipse-jdtls/eclipse-jdt-core-incubator/issues/609
.filter(t -> (t.getName() != null && !t.getName().startsWith("TestVMInstall-")))
.map(IVMInstallType::getVMInstalls)
.flatMap(Arrays::stream).toList();
Map<String, File> vmInstalls = new HashMap<>();
for (IVMInstall vmInstall : vmList) {
if (vmInstall instanceof AbstractVMInstall vm) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ dependencies {
implementation("com.google.guava:guava:28.2-jre")

// Use JUnit Jupiter API for testing.
testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.0")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.3")

// Use JUnit Jupiter Engine for testing.
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.6.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.3")
}

application {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.util.Map;

import org.junit.Test;

Expand All @@ -28,7 +29,10 @@ public void testGetJdkToLaunchDaemon() {

@Test
public void testGetMajorJavaVersion() {
File javaHome = GradleUtils.getJdkToLaunchDaemon("10");
assertTrue("javaHome=" + javaHome.getAbsolutePath(), javaHome.getAbsolutePath().contains("fakejdk" + File.separator + "10"));
Map<String, File> vmInstalls = GradleUtils.getAllVmInstalls();
vmInstalls.forEach((k, v) -> {
File javaHome = GradleUtils.getJdkToLaunchDaemon(k);
assertTrue("javaHome=" + javaHome.getAbsolutePath(), javaHome.equals(v));
});
}
}

0 comments on commit 5ffb6ec

Please sign in to comment.