Polishing

This commit is contained in:
Sam Brannen
2022-11-13 16:01:37 +01:00
parent 1f0a35bacc
commit eb91d21ada
13 changed files with 69 additions and 36 deletions

View File

@@ -137,15 +137,20 @@ public class TestContextAotGenerator {
mergedConfigMappings.add(mergedConfig, testClass);
collectRuntimeHintsRegistrarClasses(testClass, coreRuntimeHintsRegistrarClasses);
reflectiveRuntimeHintsRegistrar.registerRuntimeHints(this.runtimeHints, testClass);
this.testRuntimeHintsRegistrars.forEach(registrar ->
registrar.registerHints(this.runtimeHints, testClass, classLoader));
this.testRuntimeHintsRegistrars.forEach(registrar -> {
if (logger.isTraceEnabled()) {
logger.trace("Processing RuntimeHints contribution from class [%s]"
.formatted(registrar.getClass().getCanonicalName()));
}
registrar.registerHints(this.runtimeHints, testClass, classLoader);
});
});
coreRuntimeHintsRegistrarClasses.stream()
.map(BeanUtils::instantiateClass)
.forEach(registrar -> {
if (logger.isTraceEnabled()) {
logger.trace("Processing RuntimeHints contribution from test class [%s]"
logger.trace("Processing RuntimeHints contribution from class [%s]"
.formatted(registrar.getClass().getCanonicalName()));
}
registrar.registerHints(this.runtimeHints, classLoader);

View File

@@ -34,6 +34,12 @@ import org.springframework.aot.hint.RuntimeHints;
* specific to particular test classes, favor implementing {@code RuntimeHintsRegistrar}
* over this API.
*
* <p>As an alternative to implementing and registering a {@code TestRuntimeHintsRegistrar},
* you may choose to annotate a test class with
* {@link org.springframework.aot.hint.annotation.Reflective @Reflective},
* {@link org.springframework.aot.hint.annotation.RegisterReflectionForBinding @RegisterReflectionForBinding},
* or {@link org.springframework.context.annotation.ImportRuntimeHints @ImportRuntimeHints}.
*
* @author Sam Brannen
* @since 6.0
* @see org.springframework.aot.hint.RuntimeHintsRegistrar