Skip to content

Commit 24dbee4

Browse files
Add CDS test case to Paketo system tests
Closes gh-41350
1 parent faa0b9c commit 24dbee4

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

spring-boot-system-tests/spring-boot-image-tests/src/systemTest/java/org/springframework/boot/image/paketo/PaketoBuilderTests.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,45 @@ void nativeApp() throws Exception {
336336
}
337337
}
338338

339+
@Test
340+
void classDataSharingApp() throws Exception {
341+
writeMainClass();
342+
String imageName = "paketo-integration/" + this.gradleBuild.getProjectDir().getName();
343+
ImageReference imageReference = ImageReference.of(ImageName.of(imageName));
344+
BuildResult result = buildImage(imageName);
345+
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
346+
assertThat(result.getOutput()).contains("Running creator");
347+
try (GenericContainer<?> container = new GenericContainer<>(imageName)) {
348+
container.withExposedPorts(8080);
349+
container.waitingFor(Wait.forHttp("/test")).start();
350+
ContainerConfig config = container.getContainerInfo().getConfig();
351+
assertLabelsMatchManifestAttributes(config);
352+
ImageAssertions.assertThat(config).buildMetadata((metadata) -> {
353+
metadata.buildpacks()
354+
.contains("paketo-buildpacks/ca-certificates", "paketo-buildpacks/bellsoft-liberica",
355+
"paketo-buildpacks/executable-jar", "paketo-buildpacks/dist-zip",
356+
"paketo-buildpacks/spring-boot");
357+
metadata.processOfType("web")
358+
.satisfiesExactly((command) -> assertThat(command).isEqualTo("java"),
359+
(arg) -> assertThat(arg).isEqualTo("-cp"),
360+
(arg) -> assertThat(arg).startsWith("runner.jar"),
361+
(arg) -> assertThat(arg).isEqualTo("example.ExampleApplication"));
362+
metadata.processOfType("spring-boot-app")
363+
.satisfiesExactly((command) -> assertThat(command).isEqualTo("java"),
364+
(arg) -> assertThat(arg).isEqualTo("-cp"),
365+
(arg) -> assertThat(arg).startsWith("runner.jar"),
366+
(arg) -> assertThat(arg).isEqualTo("example.ExampleApplication"));
367+
metadata.processOfType("executable-jar")
368+
.containsExactly("java", "org.springframework.boot.loader.launch.JarLauncher");
369+
});
370+
assertImageHasJvmSbomLayer(imageReference, config);
371+
assertImageHasDependenciesSbomLayer(imageReference, config, "executable-jar");
372+
}
373+
finally {
374+
removeImage(imageReference);
375+
}
376+
}
377+
339378
private BuildResult buildImage(String imageName, String... arguments) {
340379
String[] buildImageArgs = { "bootBuildImage", "--imageName=" + imageName, "--pullPolicy=IF_NOT_PRESENT" };
341380
String[] args = StringUtils.concatenateStringArrays(arguments, buildImageArgs);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
plugins {
2+
id 'org.springframework.boot' version '{bootVersion}'
3+
id 'io.spring.dependency-management' version '{dependencyManagementPluginVersion}'
4+
id 'java'
5+
}
6+
7+
repositories {
8+
exclusiveContent {
9+
forRepository {
10+
maven { url '{systemTestMavenRepository}' }
11+
}
12+
filter {
13+
includeGroup "org.springframework.boot"
14+
}
15+
}
16+
mavenCentral()
17+
maven { url 'https://repo.spring.io/milestone' }
18+
maven { url 'https://repo.spring.io/snapshot' }
19+
}
20+
21+
dependencies {
22+
implementation("org.springframework.boot:spring-boot-starter-web:{bootVersion}")
23+
}
24+
25+
bootJar {
26+
manifest {
27+
attributes(
28+
'Implementation-Version': '1.0.0',
29+
'Implementation-Title': "Paketo Test"
30+
)
31+
}
32+
}
33+
34+
bootBuildImage {
35+
environment = ['BP_JVM_CDS_ENABLED': 'true']
36+
}

0 commit comments

Comments
 (0)