@ -35,6 +35,10 @@ import org.junit.jupiter.api.Test;
@@ -35,6 +35,10 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir ;
import org.springframework.aot.AotDetector ;
import org.springframework.aot.generate.GenerationContext ;
import org.springframework.aot.hint.MemberCategory ;
import org.springframework.aot.hint.TypeReference ;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates ;
import org.springframework.aot.test.generate.TestGenerationContext ;
import org.springframework.beans.factory.aot.BeanFactoryInitializationAotContribution ;
import org.springframework.beans.factory.support.DefaultListableBeanFactory ;
@ -209,6 +213,24 @@ class EnvironmentPostProcessorApplicationListenerTests {
@@ -209,6 +213,24 @@ class EnvironmentPostProcessorApplicationListenerTests {
} ) ;
}
@Test
void aotContributionRegistersReflectionHints ( ) {
GenericApplicationContext applicationContext = new GenericApplicationContext ( ) ;
ConfigurableEnvironment environment = new StandardEnvironment ( ) ;
environment . setActiveProfiles ( "one" , "two" ) ;
applicationContext . getBeanFactory ( ) . registerSingleton ( "environment" , environment ) ;
BeanFactoryInitializationAotContribution aotContribution = new EnvironmentBeanFactoryInitializationAotProcessor ( )
. processAheadOfTime ( applicationContext . getBeanFactory ( ) ) ;
assertThat ( aotContribution ) . isNotNull ( ) ;
GenerationContext generationContext = new TestGenerationContext ( ) ;
aotContribution . applyTo ( generationContext , null ) ;
assertThat ( RuntimeHintsPredicates . reflection ( )
. onType ( TypeReference . of ( TestGenerationContext . TEST_TARGET + "__"
+ EnvironmentPostProcessorApplicationListener . AOT_FEATURE_NAME ) )
. withMemberCategory ( MemberCategory . INVOKE_PUBLIC_CONSTRUCTORS ) )
. accepts ( generationContext . getRuntimeHints ( ) ) ;
}
@Test
void shouldUseAotEnvironmentPostProcessor ( ) {
SpringApplication application = new SpringApplication ( ExampleAotProcessedApp . class ) ;