|
36 | 36 | import org.junit.jupiter.api.io.TempDir; |
37 | 37 |
|
38 | 38 | import org.springframework.aot.AotDetector; |
| 39 | +import org.springframework.aot.generate.GenerationContext; |
| 40 | +import org.springframework.aot.hint.MemberCategory; |
| 41 | +import org.springframework.aot.hint.TypeReference; |
| 42 | +import org.springframework.aot.hint.predicate.RuntimeHintsPredicates; |
39 | 43 | import org.springframework.aot.test.generate.TestGenerationContext; |
40 | 44 | import org.springframework.beans.factory.aot.BeanFactoryInitializationAotContribution; |
41 | 45 | import org.springframework.beans.factory.support.DefaultListableBeanFactory; |
@@ -211,6 +215,24 @@ void aotContributionRegistersActiveProfiles() { |
211 | 215 | }); |
212 | 216 | } |
213 | 217 |
|
| 218 | + @Test |
| 219 | + void aotContributionRegistersReflectionHints() { |
| 220 | + GenericApplicationContext applicationContext = new GenericApplicationContext(); |
| 221 | + ConfigurableEnvironment environment = new StandardEnvironment(); |
| 222 | + environment.setActiveProfiles("one", "two"); |
| 223 | + applicationContext.getBeanFactory().registerSingleton("environment", environment); |
| 224 | + BeanFactoryInitializationAotContribution aotContribution = new EnvironmentBeanFactoryInitializationAotProcessor() |
| 225 | + .processAheadOfTime(applicationContext.getBeanFactory()); |
| 226 | + assertThat(aotContribution).isNotNull(); |
| 227 | + GenerationContext generationContext = new TestGenerationContext(); |
| 228 | + aotContribution.applyTo(generationContext, null); |
| 229 | + assertThat(RuntimeHintsPredicates.reflection() |
| 230 | + .onType(TypeReference.of(TestGenerationContext.TEST_TARGET + "__" |
| 231 | + + EnvironmentPostProcessorApplicationListener.AOT_FEATURE_NAME)) |
| 232 | + .withMemberCategory(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS)) |
| 233 | + .accepts(generationContext.getRuntimeHints()); |
| 234 | + } |
| 235 | + |
214 | 236 | @Test |
215 | 237 | void shouldUseAotEnvironmentPostProcessor() { |
216 | 238 | SpringApplication application = new SpringApplication(ExampleAotProcessedApp.class); |
|
0 commit comments