Browse Source

Polishing

pull/29083/head
Sam Brannen 3 years ago
parent
commit
35bbe9f99d
  1. 2
      spring-test/src/main/java/org/springframework/test/context/aot/TestContextAotGenerator.java
  2. 11
      spring-test/src/test/java/org/springframework/test/context/aot/TestContextAotGeneratorTests.java

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

@ -204,7 +204,7 @@ public class TestContextAotGenerator { @@ -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

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

@ -37,7 +37,9 @@ import org.springframework.context.ApplicationContextInitializer; @@ -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 { @@ -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<ConfigurableApplicationContext> contextInitializer =
aotTestMappings.getContextInitializer(testClass);
assertThat(contextInitializer).isNotNull();
@ -291,7 +293,7 @@ class TestContextAotGeneratorTests extends AbstractAotTests { @@ -291,7 +293,7 @@ class TestContextAotGeneratorTests extends AbstractAotTests {
List<Mapping> 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 { @@ -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) {
}

Loading…
Cancel
Save