Skip to content

Commit 35bbe9f

Browse files
committed
Polishing
1 parent ea13238 commit 35bbe9f

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

spring-test/src/main/java/org/springframework/test/context/aot/TestContextAotGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ private GenericApplicationContext loadContextForAotProcessing(
204204
contextLoader.getClass().getName()));
205205
}
206206

207-
MergedContextConfiguration buildMergedContextConfiguration(Class<?> testClass) {
207+
private MergedContextConfiguration buildMergedContextConfiguration(Class<?> testClass) {
208208
TestContextBootstrapper testContextBootstrapper =
209209
BootstrapUtils.resolveTestContextBootstrapper(testClass);
210210
// @BootstrapWith

spring-test/src/test/java/org/springframework/test/context/aot/TestContextAotGeneratorTests.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
import org.springframework.context.ConfigurableApplicationContext;
3838
import org.springframework.core.env.Profiles;
3939
import org.springframework.javapoet.ClassName;
40+
import org.springframework.test.context.BootstrapUtils;
4041
import org.springframework.test.context.MergedContextConfiguration;
42+
import org.springframework.test.context.TestContextBootstrapper;
4143
import org.springframework.test.context.aot.samples.basic.BasicSpringJupiterSharedConfigTests;
4244
import org.springframework.test.context.aot.samples.basic.BasicSpringJupiterTests;
4345
import org.springframework.test.context.aot.samples.basic.BasicSpringTestNGTests;
@@ -103,7 +105,7 @@ void processAheadOfTimeAndGenerateAotTestMappings() {
103105
TestCompiler.forSystem().withFiles(generatedFiles).compile(ThrowingConsumer.of(compiled -> {
104106
AotTestMappings aotTestMappings = new AotTestMappings();
105107
for (Class<?> testClass : testClasses) {
106-
MergedContextConfiguration mergedConfig = generator.buildMergedContextConfiguration(testClass);
108+
MergedContextConfiguration mergedConfig = buildMergedContextConfiguration(testClass);
107109
ApplicationContextInitializer<ConfigurableApplicationContext> contextInitializer =
108110
aotTestMappings.getContextInitializer(testClass);
109111
assertThat(contextInitializer).isNotNull();
@@ -291,7 +293,7 @@ private List<Mapping> processAheadOfTime(TestContextAotGenerator generator, Set<
291293
List<Mapping> mappings = new ArrayList<>();
292294
testClasses.forEach(testClass -> {
293295
DefaultGenerationContext generationContext = generator.createGenerationContext(testClass);
294-
MergedContextConfiguration mergedConfig = generator.buildMergedContextConfiguration(testClass);
296+
MergedContextConfiguration mergedConfig = buildMergedContextConfiguration(testClass);
295297
ClassName className = generator.processAheadOfTime(mergedConfig, generationContext);
296298
assertThat(className).isNotNull();
297299
mappings.add(new Mapping(mergedConfig, className));
@@ -301,6 +303,11 @@ private List<Mapping> processAheadOfTime(TestContextAotGenerator generator, Set<
301303
}
302304

303305

306+
private static MergedContextConfiguration buildMergedContextConfiguration(Class<?> testClass) {
307+
TestContextBootstrapper testContextBootstrapper = BootstrapUtils.resolveTestContextBootstrapper(testClass);
308+
return testContextBootstrapper.buildMergedContextConfiguration();
309+
}
310+
304311
record Mapping(MergedContextConfiguration mergedConfig, ClassName className) {
305312
}
306313

0 commit comments

Comments
 (0)