|
24 | 24 | import java.util.List;
|
25 | 25 | import java.util.Map;
|
26 | 26 | import java.util.Properties;
|
| 27 | +import java.util.function.Consumer; |
27 | 28 | import java.util.function.Predicate;
|
28 | 29 | import java.util.stream.Stream;
|
29 | 30 |
|
@@ -190,6 +191,18 @@ void componentTypesOfArraysAreRegisteredForReflection() {
|
190 | 191 | .accepts(generationContext.getRuntimeHints());
|
191 | 192 | }
|
192 | 193 |
|
| 194 | + @Test |
| 195 | + void placeholdersInComponentClassAttributeAreReplaced() { |
| 196 | + ComponentModel component = new ComponentModel(); |
| 197 | + component.setClassName("${VARIABLE_CLASS_NAME}"); |
| 198 | + TestGenerationContext generationContext = applyContribution(component, |
| 199 | + (context) -> context.putProperty("VARIABLE_CLASS_NAME", Outer.class.getName())); |
| 200 | + assertThat(invokePublicConstructorsAndInspectAndInvokePublicMethodsOf(Outer.class)) |
| 201 | + .accepts(generationContext.getRuntimeHints()); |
| 202 | + assertThat(invokePublicConstructorsAndInspectAndInvokePublicMethodsOf(Implementation.class)) |
| 203 | + .accepts(generationContext.getRuntimeHints()); |
| 204 | + } |
| 205 | + |
193 | 206 | private Predicate<RuntimeHints> invokePublicConstructorsOf(String name) {
|
194 | 207 | return RuntimeHintsPredicates.reflection()
|
195 | 208 | .onType(TypeReference.of(name))
|
@@ -220,7 +233,13 @@ private Condition<InMemoryGeneratedFiles> resource(String name) {
|
220 | 233 | }
|
221 | 234 |
|
222 | 235 | private TestGenerationContext applyContribution(Model model) {
|
| 236 | + return this.applyContribution(model, (context) -> { |
| 237 | + }); |
| 238 | + } |
| 239 | + |
| 240 | + private TestGenerationContext applyContribution(Model model, Consumer<LoggerContext> contextCustomizer) { |
223 | 241 | LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
|
| 242 | + contextCustomizer.accept(context); |
224 | 243 | SpringBootJoranConfigurator configurator = new SpringBootJoranConfigurator(null);
|
225 | 244 | configurator.setContext(context);
|
226 | 245 | withSystemProperty("spring.aot.processing", "true", () -> configurator.processModel(model));
|
|
0 commit comments