From 35bbe9f99dc15edc37ec540cc23fd5cc6f3e5741 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Mon, 5 Sep 2022 12:51:14 +0200 Subject: [PATCH] Polishing --- .../test/context/aot/TestContextAotGenerator.java | 2 +- .../context/aot/TestContextAotGeneratorTests.java | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) 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 4663a96a02..7b430a9f41 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 @@ -204,7 +204,7 @@ public class TestContextAotGenerator { contextLoader.getClass().getName())); } - MergedContextConfiguration buildMergedContextConfiguration(Class testClass) { + private MergedContextConfiguration buildMergedContextConfiguration(Class testClass) { TestContextBootstrapper testContextBootstrapper = BootstrapUtils.resolveTestContextBootstrapper(testClass); // @BootstrapWith 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 b443098e9d..1fab19cdad 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 @@ -37,7 +37,9 @@ import org.springframework.context.ApplicationContextInitializer; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.core.env.Profiles; import org.springframework.javapoet.ClassName; +import org.springframework.test.context.BootstrapUtils; import org.springframework.test.context.MergedContextConfiguration; +import org.springframework.test.context.TestContextBootstrapper; import org.springframework.test.context.aot.samples.basic.BasicSpringJupiterSharedConfigTests; import org.springframework.test.context.aot.samples.basic.BasicSpringJupiterTests; import org.springframework.test.context.aot.samples.basic.BasicSpringTestNGTests; @@ -103,7 +105,7 @@ class TestContextAotGeneratorTests extends AbstractAotTests { TestCompiler.forSystem().withFiles(generatedFiles).compile(ThrowingConsumer.of(compiled -> { AotTestMappings aotTestMappings = new AotTestMappings(); for (Class testClass : testClasses) { - MergedContextConfiguration mergedConfig = generator.buildMergedContextConfiguration(testClass); + MergedContextConfiguration mergedConfig = buildMergedContextConfiguration(testClass); ApplicationContextInitializer contextInitializer = aotTestMappings.getContextInitializer(testClass); assertThat(contextInitializer).isNotNull(); @@ -291,7 +293,7 @@ class TestContextAotGeneratorTests extends AbstractAotTests { List mappings = new ArrayList<>(); testClasses.forEach(testClass -> { DefaultGenerationContext generationContext = generator.createGenerationContext(testClass); - MergedContextConfiguration mergedConfig = generator.buildMergedContextConfiguration(testClass); + MergedContextConfiguration mergedConfig = buildMergedContextConfiguration(testClass); ClassName className = generator.processAheadOfTime(mergedConfig, generationContext); assertThat(className).isNotNull(); mappings.add(new Mapping(mergedConfig, className)); @@ -301,6 +303,11 @@ class TestContextAotGeneratorTests extends AbstractAotTests { } + private static MergedContextConfiguration buildMergedContextConfiguration(Class testClass) { + TestContextBootstrapper testContextBootstrapper = BootstrapUtils.resolveTestContextBootstrapper(testClass); + return testContextBootstrapper.buildMergedContextConfiguration(); + } + record Mapping(MergedContextConfiguration mergedConfig, ClassName className) { }