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