Use actual Java version in build image integration tests

See gh-37453
2.7.x
Scott Frederick 1 year ago
parent 7b0885b8b2
commit c45ad6ce83

@ -75,7 +75,7 @@ class BootBuildImageIntegrationTests {
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(result.getOutput()).contains("docker.io/library/" + projectName); assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
assertThat(result.getOutput()).contains("---> Test Info buildpack building"); assertThat(result.getOutput()).contains("---> Test Info buildpack building");
assertThat(result.getOutput()).contains("env: BP_JVM_VERSION=8.*"); assertThat(result.getOutput()).contains("env: BP_JVM_VERSION=" + javaMajorVersion() + ".*");
assertThat(result.getOutput()).contains("Network status: HTTP/2 200"); assertThat(result.getOutput()).contains("Network status: HTTP/2 200");
assertThat(result.getOutput()).contains("---> Test Info buildpack done"); assertThat(result.getOutput()).contains("---> Test Info buildpack done");
removeImages(projectName); removeImages(projectName);
@ -91,7 +91,6 @@ class BootBuildImageIntegrationTests {
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
assertThat(result.getOutput()).contains("docker.io/library/" + projectName); assertThat(result.getOutput()).contains("docker.io/library/" + projectName);
assertThat(result.getOutput()).contains("---> Test Info buildpack building"); assertThat(result.getOutput()).contains("---> Test Info buildpack building");
assertThat(result.getOutput()).contains("env: BP_JVM_VERSION=8.*");
assertThat(result.getOutput()).contains("---> Test Info buildpack done"); assertThat(result.getOutput()).contains("---> Test Info buildpack done");
File buildLibs = new File(this.gradleBuild.getProjectDir(), "build/libs"); File buildLibs = new File(this.gradleBuild.getProjectDir(), "build/libs");
assertThat(buildLibs.listFiles()) assertThat(buildLibs.listFiles())
@ -479,4 +478,18 @@ class BootBuildImageIntegrationTests {
} }
} }
private String javaMajorVersion() {
String javaVersion = System.getProperty("java.version");
if (javaVersion.startsWith("1.")) {
return javaVersion.substring(2, 3);
}
else {
int firstDotIndex = javaVersion.indexOf(".");
if (firstDotIndex != -1) {
return javaVersion.substring(0, firstDotIndex);
}
}
return javaVersion;
}
} }

Loading…
Cancel
Save