AotTests Class — spring-boot Architecture
Architecture documentation for the AotTests class in AotTests.java from the spring-boot codebase.
Entity Profile
Source Code
build-plugin/spring-boot-maven-plugin/src/intTest/java/org/springframework/boot/maven/AotTests.java lines 42–240
@ExtendWith(MavenBuildExtension.class)
class AotTests {
@TestTemplate
void whenAotRunsSourcesAreGenerated(MavenBuild mavenBuild) {
mavenBuild.project("aot").goals("package").execute((project) -> {
Path aotDirectory = project.toPath().resolve("target/spring-aot/main");
assertThat(collectRelativePaths(aotDirectory.resolve("sources")))
.contains(Path.of("org", "test", "SampleApplication__ApplicationContextInitializer.java"));
});
}
@TestTemplate
void whenAotRunsResourcesAreGeneratedAndCopiedToTargetClasses(MavenBuild mavenBuild) {
mavenBuild.project("aot-resource-generation").goals("package").execute((project) -> {
Path targetClasses = project.toPath().resolve("target/classes");
assertThat(collectRelativePaths(targetClasses)).contains(
Path.of("META-INF", "native-image", "org.springframework.boot.maven.it", "aot-resource-generation",
"reachability-metadata.json"),
Path.of("META-INF", "native-image", "org.springframework.boot.maven.it", "aot-resource-generation",
"native-image.properties"),
Path.of("generated-resource"), Path.of("nested/generated-resource"));
});
}
@TestTemplate
void whenAotRunsWithJdkProxyResourcesIncludeProxyConfig(MavenBuild mavenBuild) {
mavenBuild.project("aot-jdk-proxy").goals("package").execute((project) -> {
Path aotDirectory = project.toPath().resolve("target/spring-aot/main");
assertThat(collectRelativePaths(aotDirectory.resolve("resources"))).contains(
Path.of("META-INF", "native-image", "org.springframework.boot.maven.it", "aot-jdk-proxy",
"reachability-metadata.json"),
Path.of("META-INF", "native-image", "org.springframework.boot.maven.it", "aot-jdk-proxy",
"native-image.properties"));
});
}
@TestTemplate
void whenAotRunsWithClassProxyClassesAreGenerated(MavenBuild mavenBuild) {
mavenBuild.project("aot-class-proxy").goals("package").execute((project) -> {
Path aotDirectory = project.toPath().resolve("target/spring-aot/main");
assertThat(collectRelativePaths(aotDirectory.resolve("classes")))
.contains(Path.of("org", "test", "SampleRunner$$SpringCGLIB$$0.class"));
});
}
@TestTemplate
void whenAotRunsWithProfilesSourcesAreGenerated(MavenBuild mavenBuild) {
mavenBuild.project("aot-profile").goals("package").execute((project) -> {
Path aotDirectory = project.toPath().resolve("target/spring-aot/main");
assertThat(collectRelativePaths(aotDirectory.resolve("sources")))
.contains(Path.of("org", "test", "TestProfileConfiguration__BeanDefinitions.java"));
});
}
@TestTemplate
void whenAotRunsWithArgumentsSourcesAreGenerated(MavenBuild mavenBuild) {
mavenBuild.project("aot-arguments").goals("package").execute((project) -> {
Path aotDirectory = project.toPath().resolve("target/spring-aot/main");
assertThat(collectRelativePaths(aotDirectory.resolve("sources")))
.contains(Path.of("org", "test", "TestProfileConfiguration__BeanDefinitions.java"));
});
}
@TestTemplate
void whenAotRunsWithSystemPropertiesSourcesAreGenerated(MavenBuild mavenBuild) {
mavenBuild.project("aot-system-properties").goals("package").execute((project) -> {
Path aotDirectory = project.toPath().resolve("target/spring-aot/main");
assertThat(collectRelativePaths(aotDirectory.resolve("sources")))
.contains(Path.of("org", "test", "TestProfileConfiguration__BeanDefinitions.java"));
});
}
@TestTemplate
void whenAotRunsWithJvmArgumentsSourcesAreGenerated(MavenBuild mavenBuild) {
mavenBuild.project("aot-jvm-arguments").goals("package").execute((project) -> {
Path aotDirectory = project.toPath().resolve("target/spring-aot/main");
assertThat(collectRelativePaths(aotDirectory.resolve("sources")))
.contains(Path.of("org", "test", "TestProfileConfiguration__BeanDefinitions.java"));
});
}
@TestTemplate
void whenAotRunsWithReleaseSourcesAreGenerated(MavenBuild mavenBuild) {
mavenBuild.project("aot-release").goals("package").execute((project) -> {
Path aotDirectory = project.toPath().resolve("target/spring-aot/main");
assertThat(collectRelativePaths(aotDirectory.resolve("sources")))
.contains(Path.of("org", "test", "SampleApplication__ApplicationContextInitializer.java"));
});
}
@TestTemplate
@EnabledOnLocale(language = "en")
void whenAotRunsWithInvalidCompilerArgumentsCompileFails(MavenBuild mavenBuild) {
mavenBuild.project("aot-compiler-arguments")
.goals("package")
.executeAndFail(
(project) -> assertThat(buildLog(project)).contains("invalid flag: --invalid-compiler-arg"));
}
@TestTemplate
void whenAotRunsSourcesAreCompiledAndMovedToTargetClasses(MavenBuild mavenBuild) {
mavenBuild.project("aot").goals("package").execute((project) -> {
Path classesDirectory = project.toPath().resolve("target/classes");
assertThat(collectRelativePaths(classesDirectory))
.contains(Path.of("org", "test", "SampleApplication__ApplicationContextInitializer.class"));
});
}
@TestTemplate
void whenAotRunsWithModuleInfoSourcesAreCompiledAndMovedToTargetClass(MavenBuild mavenBuild) {
mavenBuild.project("aot-module-info").goals("package").execute((project) -> {
Path classesDirectory = project.toPath().resolve("target/classes");
assertThat(collectRelativePaths(classesDirectory))
.contains(Path.of("org", "test", "SampleApplication__ApplicationContextInitializer.class"));
});
}
@TestTemplate
void whenAotRunsResourcesAreCopiedToTargetClasses(MavenBuild mavenBuild) {
mavenBuild.project("aot-jdk-proxy").goals("package").execute((project) -> {
Path classesDirectory = project.toPath().resolve("target/classes/META-INF/native-image");
assertThat(collectRelativePaths(classesDirectory)).contains(
Path.of("org.springframework.boot.maven.it", "aot-jdk-proxy", "reachability-metadata.json"),
Path.of("org.springframework.boot.maven.it", "aot-jdk-proxy", "native-image.properties"));
});
}
@TestTemplate
void whenAotRunsWithClassProxyClassesAreCopiedToTargetClasses(MavenBuild mavenBuild) {
mavenBuild.project("aot-class-proxy").goals("package").execute((project) -> {
Path classesDirectory = project.toPath().resolve("target/classes/");
assertThat(collectRelativePaths(classesDirectory))
.contains(Path.of("org", "test", "SampleRunner$$SpringCGLIB$$0.class"));
});
}
@TestTemplate
void whenAotRunsWithDevtoolsInClasspathItIsExcluded(MavenBuild mavenBuild) {
mavenBuild.project("aot-exclude-devtools").goals("package").execute((project) -> {
Path aotDirectory = project.toPath().resolve("target/spring-aot/main");
assertThat(aotDirectory).exists();
Path sourcesDirectory = aotDirectory.resolve("sources");
assertThat(sourcesDirectory).exists();
assertThat(collectRelativePaths(sourcesDirectory)).isNotEmpty();
});
}
@TestTemplate
void whenAotTestRunsSourcesAndResourcesAreGenerated(MavenBuild mavenBuild) {
mavenBuild.project("aot-test").goals("test").execute((project) -> {
Path aotDirectory = project.toPath().resolve("target/spring-aot/test");
assertThat(collectRelativePaths(aotDirectory.resolve("sources"))).contains(Path.of("org", "test",
"SampleApplicationTests__TestContext001_ApplicationContextInitializer.java"));
Path testClassesDirectory = project.toPath().resolve("target/test-classes");
assertThat(collectRelativePaths(testClassesDirectory)).contains(Path.of("META-INF", "native-image",
"org.springframework.boot.maven.it", "aot-test", "reachability-metadata.json"));
assertThat(collectRelativePaths(testClassesDirectory)).contains(Path.of("org", "test",
"SampleApplicationTests__TestContext001_ApplicationContextInitializer.class"));
});
}
@TestTemplate
void whenTestAotRunsWithTestSkipItIsAlsoSkipped(MavenBuild mavenBuild) {
mavenBuild.project("aot-test-skip").goals("test").execute((project) -> {
Path aotDirectory = project.toPath().resolve("target/spring-aot/test");
assertThat(aotDirectory).doesNotExist();
Path testClassesDirectory = project.toPath().resolve("target/test-classes");
assertThat(testClassesDirectory.resolve("META-INF").resolve("native-image")).doesNotExist();
});
}
@TestTemplate
void whenTestAotRunsWithDevtoolsInClasspathItIsExcluded(MavenBuild mavenBuild) {
mavenBuild.project("aot-test-exclude-devtools").goals("process-test-classes").execute((project) -> {
Path aotDirectory = project.toPath().resolve("target/spring-aot/test");
assertThat(aotDirectory).exists();
Path sourcesDirectory = aotDirectory.resolve("sources");
assertThat(sourcesDirectory).exists();
assertThat(collectRelativePaths(sourcesDirectory)).isNotEmpty();
});
}
List<Path> collectRelativePaths(Path sourceDirectory) {
try (Stream<Path> pathStream = Files.walk(sourceDirectory)) {
return pathStream.filter(Files::isRegularFile)
.map((path) -> path.subpath(sourceDirectory.getNameCount(), path.getNameCount()))
.toList();
}
catch (IOException ex) {
throw new IllegalStateException(ex);
}
}
protected String buildLog(File project) {
return contentOf(new File(project, "target/build.log"));
}
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free