|
|
|
@ -22,8 +22,6 @@ import java.util.function.Consumer;
|
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
|
|
|
|
import org.springframework.aot.test.generate.TestGenerationContext;
|
|
|
|
|
import org.springframework.aot.test.generate.compile.CompileWithTargetClassAccess;
|
|
|
|
|
import org.springframework.aot.test.generate.compile.TestCompiler;
|
|
|
|
|
import org.springframework.beans.factory.aot.AotServices;
|
|
|
|
|
import org.springframework.beans.factory.aot.BeanRegistrationAotContribution;
|
|
|
|
|
import org.springframework.beans.factory.aot.BeanRegistrationAotProcessor;
|
|
|
|
@ -38,6 +36,8 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext
|
|
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.springframework.context.aot.ApplicationContextAotGenerator;
|
|
|
|
|
import org.springframework.context.support.GenericApplicationContext;
|
|
|
|
|
import org.springframework.core.test.tools.CompileWithForkedClassLoader;
|
|
|
|
|
import org.springframework.core.test.tools.TestCompiler;
|
|
|
|
|
import org.springframework.javapoet.ClassName;
|
|
|
|
|
import org.springframework.test.context.support.TestPropertySourceUtils;
|
|
|
|
|
|
|
|
|
@ -90,7 +90,7 @@ class ConfigurationPropertiesBeanRegistrationAotProcessorTests {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@CompileWithTargetClassAccess
|
|
|
|
|
@CompileWithForkedClassLoader
|
|
|
|
|
void aotContributedInitializerBindsValueObject() {
|
|
|
|
|
compile(createContext(ValueObjectSampleBeanConfiguration.class), (freshContext) -> {
|
|
|
|
|
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(freshContext, "test.name=Hello");
|
|
|
|
@ -101,7 +101,7 @@ class ConfigurationPropertiesBeanRegistrationAotProcessorTests {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@CompileWithTargetClassAccess
|
|
|
|
|
@CompileWithForkedClassLoader
|
|
|
|
|
void aotContributedInitializerBindsJavaBean() {
|
|
|
|
|
compile(createContext(JavaBeanSampleBeanConfiguration.class), (freshContext) -> {
|
|
|
|
|
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(freshContext, "test.name=Hello");
|
|
|
|
@ -112,7 +112,7 @@ class ConfigurationPropertiesBeanRegistrationAotProcessorTests {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@CompileWithTargetClassAccess
|
|
|
|
|
@CompileWithForkedClassLoader
|
|
|
|
|
void aotContributedInitializerBindsScannedValueObject() {
|
|
|
|
|
compile(createContext(ScanTestConfiguration.class), (freshContext) -> {
|
|
|
|
|
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(freshContext, "b.first.name=Hello");
|
|
|
|
@ -123,7 +123,7 @@ class ConfigurationPropertiesBeanRegistrationAotProcessorTests {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
@CompileWithTargetClassAccess
|
|
|
|
|
@CompileWithForkedClassLoader
|
|
|
|
|
void aotContributedInitializerBindsScannedJavaBean() {
|
|
|
|
|
compile(createContext(ScanTestConfiguration.class), (freshContext) -> {
|
|
|
|
|
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(freshContext, "b.second.number=42");
|
|
|
|
@ -145,7 +145,7 @@ class ConfigurationPropertiesBeanRegistrationAotProcessorTests {
|
|
|
|
|
TestGenerationContext generationContext = new TestGenerationContext(TestTarget.class);
|
|
|
|
|
ClassName className = new ApplicationContextAotGenerator().processAheadOfTime(context, generationContext);
|
|
|
|
|
generationContext.writeGeneratedContent();
|
|
|
|
|
TestCompiler.forSystem().withFiles(generationContext.getGeneratedFiles()).compile((compiled) -> {
|
|
|
|
|
TestCompiler.forSystem().with(generationContext).compile((compiled) -> {
|
|
|
|
|
GenericApplicationContext freshApplicationContext = new GenericApplicationContext();
|
|
|
|
|
ApplicationContextInitializer<GenericApplicationContext> initializer = compiled
|
|
|
|
|
.getInstance(ApplicationContextInitializer.class, className.toString());
|
|
|
|
|