37
37
import org .springframework .context .ConfigurableApplicationContext ;
38
38
import org .springframework .core .env .Profiles ;
39
39
import org .springframework .javapoet .ClassName ;
40
+ import org .springframework .test .context .BootstrapUtils ;
40
41
import org .springframework .test .context .MergedContextConfiguration ;
42
+ import org .springframework .test .context .TestContextBootstrapper ;
41
43
import org .springframework .test .context .aot .samples .basic .BasicSpringJupiterSharedConfigTests ;
42
44
import org .springframework .test .context .aot .samples .basic .BasicSpringJupiterTests ;
43
45
import org .springframework .test .context .aot .samples .basic .BasicSpringTestNGTests ;
@@ -103,7 +105,7 @@ void processAheadOfTimeAndGenerateAotTestMappings() {
103
105
TestCompiler .forSystem ().withFiles (generatedFiles ).compile (ThrowingConsumer .of (compiled -> {
104
106
AotTestMappings aotTestMappings = new AotTestMappings ();
105
107
for (Class <?> testClass : testClasses ) {
106
- MergedContextConfiguration mergedConfig = generator . buildMergedContextConfiguration (testClass );
108
+ MergedContextConfiguration mergedConfig = buildMergedContextConfiguration (testClass );
107
109
ApplicationContextInitializer <ConfigurableApplicationContext > contextInitializer =
108
110
aotTestMappings .getContextInitializer (testClass );
109
111
assertThat (contextInitializer ).isNotNull ();
@@ -291,7 +293,7 @@ private List<Mapping> processAheadOfTime(TestContextAotGenerator generator, Set<
291
293
List <Mapping > mappings = new ArrayList <>();
292
294
testClasses .forEach (testClass -> {
293
295
DefaultGenerationContext generationContext = generator .createGenerationContext (testClass );
294
- MergedContextConfiguration mergedConfig = generator . buildMergedContextConfiguration (testClass );
296
+ MergedContextConfiguration mergedConfig = buildMergedContextConfiguration (testClass );
295
297
ClassName className = generator .processAheadOfTime (mergedConfig , generationContext );
296
298
assertThat (className ).isNotNull ();
297
299
mappings .add (new Mapping (mergedConfig , className ));
@@ -301,6 +303,11 @@ private List<Mapping> processAheadOfTime(TestContextAotGenerator generator, Set<
301
303
}
302
304
303
305
306
+ private static MergedContextConfiguration buildMergedContextConfiguration (Class <?> testClass ) {
307
+ TestContextBootstrapper testContextBootstrapper = BootstrapUtils .resolveTestContextBootstrapper (testClass );
308
+ return testContextBootstrapper .buildMergedContextConfiguration ();
309
+ }
310
+
304
311
record Mapping (MergedContextConfiguration mergedConfig , ClassName className ) {
305
312
}
306
313
0 commit comments