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