diff --git a/spring-test/src/main/java/org/springframework/test/context/aot/TestAotMappings.java b/spring-test/src/main/java/org/springframework/test/context/aot/AotTestContextInitializers.java
similarity index 87%
rename from spring-test/src/main/java/org/springframework/test/context/aot/TestAotMappings.java
rename to spring-test/src/main/java/org/springframework/test/context/aot/AotTestContextInitializers.java
index 8b563112eeb2..e82b05075c34 100644
--- a/spring-test/src/main/java/org/springframework/test/context/aot/TestAotMappings.java
+++ b/spring-test/src/main/java/org/springframework/test/context/aot/AotTestContextInitializers.java
@@ -28,8 +28,8 @@
import org.springframework.util.ReflectionUtils;
/**
- * {@code TestAotMappings} provides mappings from test classes to AOT-optimized
- * context initializers.
+ * {@code AotTestContextInitializers} provides mappings from test classes to
+ * AOT-optimized context initializers.
*
*
If a test class is not {@linkplain #isSupportedTestClass(Class) supported} in
* AOT mode, {@link #getContextInitializer(Class)} will return {@code null}.
@@ -42,27 +42,27 @@
* @author Stephane Nicoll
* @since 6.0
*/
-public class TestAotMappings {
+public class AotTestContextInitializers {
// TODO Add support in ClassNameGenerator for supplying a predefined class name.
// There is a similar issue in Spring Boot where code relies on a generated name.
- // Ideally we would generate a class named: org.springframework.test.context.aot.GeneratedTestAotMappings
- static final String GENERATED_MAPPINGS_CLASS_NAME = TestAotMappings.class.getName() + "__Generated";
+ // Ideally we would generate a class named: org.springframework.test.context.aot.GeneratedAotTestContextInitializers
+ static final String GENERATED_MAPPINGS_CLASS_NAME = AotTestContextInitializers.class.getName() + "__Generated";
static final String GENERATED_MAPPINGS_METHOD_NAME = "getContextInitializers";
private final Map>> contextInitializers;
- public TestAotMappings() {
+ public AotTestContextInitializers() {
this(GENERATED_MAPPINGS_CLASS_NAME);
}
- TestAotMappings(String initializerClassName) {
+ AotTestContextInitializers(String initializerClassName) {
this(loadContextInitializersMap(initializerClassName));
}
- TestAotMappings(Map>> contextInitializers) {
+ AotTestContextInitializers(Map>> contextInitializers) {
this.contextInitializers = contextInitializers;
}
diff --git a/spring-test/src/main/java/org/springframework/test/context/aot/TestAotMappingsCodeGenerator.java b/spring-test/src/main/java/org/springframework/test/context/aot/AotTestContextInitializersCodeGenerator.java
similarity index 87%
rename from spring-test/src/main/java/org/springframework/test/context/aot/TestAotMappingsCodeGenerator.java
rename to spring-test/src/main/java/org/springframework/test/context/aot/AotTestContextInitializersCodeGenerator.java
index 62b6bf65a5ed..c7732cf26151 100644
--- a/spring-test/src/main/java/org/springframework/test/context/aot/TestAotMappingsCodeGenerator.java
+++ b/spring-test/src/main/java/org/springframework/test/context/aot/AotTestContextInitializersCodeGenerator.java
@@ -41,14 +41,14 @@
import org.springframework.util.MultiValueMap;
/**
- * Internal code generator for mappings used by {@link TestAotMappings}.
+ * Internal code generator for mappings used by {@link AotTestContextInitializers}.
*
* @author Sam Brannen
* @since 6.0
*/
-class TestAotMappingsCodeGenerator {
+class AotTestContextInitializersCodeGenerator {
- private static final Log logger = LogFactory.getLog(TestAotMappingsCodeGenerator.class);
+ private static final Log logger = LogFactory.getLog(AotTestContextInitializersCodeGenerator.class);
private static final ParameterizedTypeName CONTEXT_INITIALIZER = ParameterizedTypeName.get(
ClassName.get(ApplicationContextInitializer.class),
@@ -67,7 +67,7 @@ class TestAotMappingsCodeGenerator {
private final GeneratedClass generatedClass;
- TestAotMappingsCodeGenerator(MultiValueMap> initializerClassMappings,
+ AotTestContextInitializersCodeGenerator(MultiValueMap> initializerClassMappings,
GeneratedClasses generatedClasses) {
this.initializerClassMappings = initializerClassMappings;
@@ -82,13 +82,13 @@ GeneratedClass getGeneratedClass() {
private void generateType(TypeSpec.Builder type) {
logger.debug(LogMessage.format("Generating AOT test mappings in %s",
this.generatedClass.getName().reflectionName()));
- type.addJavadoc("Generated mappings for {@link $T}.", TestAotMappings.class);
+ type.addJavadoc("Generated mappings for {@link $T}.", AotTestContextInitializers.class);
type.addModifiers(Modifier.PUBLIC);
type.addMethod(generateMappingMethod());
}
private MethodSpec generateMappingMethod() {
- MethodSpec.Builder method = MethodSpec.methodBuilder(TestAotMappings.GENERATED_MAPPINGS_METHOD_NAME);
+ MethodSpec.Builder method = MethodSpec.methodBuilder(AotTestContextInitializers.GENERATED_MAPPINGS_METHOD_NAME);
method.addModifiers(Modifier.PUBLIC, Modifier.STATIC);
method.returns(CONTEXT_SUPPLIER_MAP);
method.addCode(generateMappingCode());
diff --git a/spring-test/src/main/java/org/springframework/test/context/aot/TestContextAotGenerator.java b/spring-test/src/main/java/org/springframework/test/context/aot/TestContextAotGenerator.java
index 185cd908a916..c717774f18d7 100644
--- a/spring-test/src/main/java/org/springframework/test/context/aot/TestContextAotGenerator.java
+++ b/spring-test/src/main/java/org/springframework/test/context/aot/TestContextAotGenerator.java
@@ -240,13 +240,13 @@ private String nextTestContextId() {
}
private void generateTestAotMappings(MultiValueMap> initializerClassMappings) {
- ClassNameGenerator classNameGenerator = new ClassNameGenerator(TestAotMappings.class);
+ ClassNameGenerator classNameGenerator = new ClassNameGenerator(AotTestContextInitializers.class);
DefaultGenerationContext generationContext =
new DefaultGenerationContext(classNameGenerator, this.generatedFiles, this.runtimeHints);
GeneratedClasses generatedClasses = generationContext.getGeneratedClasses();
- TestAotMappingsCodeGenerator codeGenerator =
- new TestAotMappingsCodeGenerator(initializerClassMappings, generatedClasses);
+ AotTestContextInitializersCodeGenerator codeGenerator =
+ new AotTestContextInitializersCodeGenerator(initializerClassMappings, generatedClasses);
generationContext.writeGeneratedContent();
String className = codeGenerator.getGeneratedClass().getName().reflectionName();
registerPublicMethods(className);
diff --git a/spring-test/src/main/java/org/springframework/test/context/cache/DefaultCacheAwareContextLoaderDelegate.java b/spring-test/src/main/java/org/springframework/test/context/cache/DefaultCacheAwareContextLoaderDelegate.java
index 41b0c0188002..f7a3eab00e2a 100644
--- a/spring-test/src/main/java/org/springframework/test/context/cache/DefaultCacheAwareContextLoaderDelegate.java
+++ b/spring-test/src/main/java/org/springframework/test/context/cache/DefaultCacheAwareContextLoaderDelegate.java
@@ -32,7 +32,7 @@
import org.springframework.test.context.MergedContextConfiguration;
import org.springframework.test.context.SmartContextLoader;
import org.springframework.test.context.aot.AotContextLoader;
-import org.springframework.test.context.aot.TestAotMappings;
+import org.springframework.test.context.aot.AotTestContextInitializers;
import org.springframework.test.context.aot.TestContextAotException;
import org.springframework.util.Assert;
@@ -57,7 +57,7 @@ public class DefaultCacheAwareContextLoaderDelegate implements CacheAwareContext
static final ContextCache defaultContextCache = new DefaultContextCache();
@Nullable
- private final TestAotMappings testAotMappings = getTestAotMappings();
+ private final AotTestContextInitializers aotTestContextInitializers = getAotTestContextInitializers();
private final ContextCache contextCache;
@@ -168,7 +168,7 @@ protected ApplicationContext loadContextInternal(MergedContextConfiguration merg
protected ApplicationContext loadContextInAotMode(MergedContextConfiguration mergedConfig) throws Exception {
Class> testClass = mergedConfig.getTestClass();
ApplicationContextInitializer contextInitializer =
- this.testAotMappings.getContextInitializer(testClass);
+ this.aotTestContextInitializers.getContextInitializer(testClass);
Assert.state(contextInitializer != null,
() -> "Failed to load AOT ApplicationContextInitializer for test class [%s]"
.formatted(testClass.getName()));
@@ -200,17 +200,18 @@ private ContextLoader getContextLoader(MergedContextConfiguration mergedConfig)
* Determine if we are running in AOT mode for the supplied test class.
*/
private boolean runningInAotMode(Class> testClass) {
- return (this.testAotMappings != null && this.testAotMappings.isSupportedTestClass(testClass));
+ return (this.aotTestContextInitializers != null &&
+ this.aotTestContextInitializers.isSupportedTestClass(testClass));
}
@Nullable
- private static TestAotMappings getTestAotMappings() {
+ private static AotTestContextInitializers getAotTestContextInitializers() {
if (AotDetector.useGeneratedArtifacts()) {
try {
- return new TestAotMappings();
+ return new AotTestContextInitializers();
}
catch (Exception ex) {
- throw new IllegalStateException("Failed to instantiate TestAotMappings", ex);
+ throw new IllegalStateException("Failed to instantiate AotTestContextInitializers", ex);
}
}
return null;
diff --git a/spring-test/src/main/java/org/springframework/test/context/support/DependencyInjectionTestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/support/DependencyInjectionTestExecutionListener.java
index ca133ccbf263..ec7b78390655 100644
--- a/spring-test/src/main/java/org/springframework/test/context/support/DependencyInjectionTestExecutionListener.java
+++ b/spring-test/src/main/java/org/springframework/test/context/support/DependencyInjectionTestExecutionListener.java
@@ -28,7 +28,7 @@
import org.springframework.core.Conventions;
import org.springframework.lang.Nullable;
import org.springframework.test.context.TestContext;
-import org.springframework.test.context.aot.TestAotMappings;
+import org.springframework.test.context.aot.AotTestContextInitializers;
/**
* {@code TestExecutionListener} which provides support for dependency
@@ -61,7 +61,7 @@ public class DependencyInjectionTestExecutionListener extends AbstractTestExecut
private static final Log logger = LogFactory.getLog(DependencyInjectionTestExecutionListener.class);
@Nullable
- private final TestAotMappings testAotMappings = getTestAotMappings();
+ private final AotTestContextInitializers aotTestContextInitializers = getAotTestContextInitializers();
/**
@@ -162,17 +162,18 @@ private void injectDependenciesInAotMode(TestContext testContext) throws Excepti
* Determine if we are running in AOT mode for the supplied test class.
*/
private boolean runningInAotMode(Class> testClass) {
- return (this.testAotMappings != null && this.testAotMappings.isSupportedTestClass(testClass));
+ return (this.aotTestContextInitializers != null &&
+ this.aotTestContextInitializers.isSupportedTestClass(testClass));
}
@Nullable
- private static TestAotMappings getTestAotMappings() {
+ private static AotTestContextInitializers getAotTestContextInitializers() {
if (AotDetector.useGeneratedArtifacts()) {
try {
- return new TestAotMappings();
+ return new AotTestContextInitializers();
}
catch (Exception ex) {
- throw new IllegalStateException("Failed to instantiate TestAotMappings", ex);
+ throw new IllegalStateException("Failed to instantiate AotTestContextInitializers", ex);
}
}
return null;
diff --git a/spring-test/src/test/java/org/springframework/test/context/aot/AbstractAotTests.java b/spring-test/src/test/java/org/springframework/test/context/aot/AbstractAotTests.java
index 142142949e0d..5c83a336c462 100644
--- a/spring-test/src/test/java/org/springframework/test/context/aot/AbstractAotTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/aot/AbstractAotTests.java
@@ -31,7 +31,7 @@ abstract class AbstractAotTests {
static final String[] expectedSourceFilesForBasicSpringTests = {
// Global
- "org/springframework/test/context/aot/TestAotMappings__Generated.java",
+ "org/springframework/test/context/aot/AotTestContextInitializers__Generated.java",
"org/springframework/test/context/aot/AotTestAttributes__Generated.java",
// BasicSpringJupiterSharedConfigTests
"org/springframework/context/event/DefaultEventListenerFactory__TestContext001_BeanDefinitions.java",
diff --git a/spring-test/src/test/java/org/springframework/test/context/aot/TestContextAotGeneratorTests.java b/spring-test/src/test/java/org/springframework/test/context/aot/TestContextAotGeneratorTests.java
index 8b7a33bd83b6..d7000fdaddb4 100644
--- a/spring-test/src/test/java/org/springframework/test/context/aot/TestContextAotGeneratorTests.java
+++ b/spring-test/src/test/java/org/springframework/test/context/aot/TestContextAotGeneratorTests.java
@@ -74,7 +74,7 @@
import static org.springframework.test.web.servlet.setup.MockMvcBuilders.webAppContextSetup;
/**
- * Tests for {@link TestContextAotGenerator}, {@link TestAotMappings},
+ * Tests for {@link TestContextAotGenerator}, {@link AotTestContextInitializers},
* {@link AotTestAttributes}, {@link AotContextLoader}, and run-time hints.
*
* @author Sam Brannen
@@ -126,11 +126,11 @@ void endToEndTests() {
assertThat(aotAttributes.getString("bogus")).isNull();
assertThat(aotAttributes.getBoolean("bogus")).isFalse();
- TestAotMappings testAotMappings = new TestAotMappings();
+ AotTestContextInitializers aotContextInitializers = new AotTestContextInitializers();
for (Class> testClass : testClasses) {
MergedContextConfiguration mergedConfig = buildMergedContextConfiguration(testClass);
ApplicationContextInitializer contextInitializer =
- testAotMappings.getContextInitializer(testClass);
+ aotContextInitializers.getContextInitializer(testClass);
assertThat(contextInitializer).isNotNull();
ApplicationContext context = ((AotContextLoader) mergedConfig.getContextLoader())
.loadContextForAotRuntime(mergedConfig, contextInitializer);
@@ -153,7 +153,7 @@ else if (testClass.getPackageName().contains("jdbc")) {
}
private static void assertRuntimeHints(RuntimeHints runtimeHints) {
- assertReflectionRegistered(runtimeHints, TestAotMappings.GENERATED_MAPPINGS_CLASS_NAME, INVOKE_PUBLIC_METHODS);
+ assertReflectionRegistered(runtimeHints, AotTestContextInitializers.GENERATED_MAPPINGS_CLASS_NAME, INVOKE_PUBLIC_METHODS);
assertReflectionRegistered(runtimeHints, AotTestAttributesCodeGenerator.GENERATED_ATTRIBUTES_CLASS_NAME, INVOKE_PUBLIC_METHODS);
Stream.of(
@@ -356,7 +356,7 @@ record Mapping(MergedContextConfiguration mergedConfig, ClassName className) {
private static final String[] expectedSourceFiles = {
// Global
- "org/springframework/test/context/aot/TestAotMappings__Generated.java",
+ "org/springframework/test/context/aot/AotTestContextInitializers__Generated.java",
"org/springframework/test/context/aot/AotTestAttributes__Generated.java",
// BasicSpringJupiterSharedConfigTests
"org/springframework/context/event/DefaultEventListenerFactory__TestContext001_BeanDefinitions.java",