Register runtime hints for TestContextBootstrappers
This commit automatically registers runtime hints for TestContextBootstrapper classes, including default bootstrappers as well as any bootstrapper configured via @BootstrapWith. Closes gh-29023
This commit is contained in:
@@ -198,6 +198,7 @@ public class TestContextAotGenerator {
|
||||
MergedContextConfiguration buildMergedContextConfiguration(Class<?> testClass) {
|
||||
TestContextBootstrapper testContextBootstrapper =
|
||||
BootstrapUtils.resolveTestContextBootstrapper(testClass);
|
||||
registerDeclaredConstructors(testContextBootstrapper.getClass());
|
||||
return testContextBootstrapper.buildMergedContextConfiguration();
|
||||
}
|
||||
|
||||
|
||||
@@ -44,25 +44,12 @@ class TestContextRuntimeHints implements RuntimeHintsRegistrar {
|
||||
|
||||
ReflectionHints reflectionHints = runtimeHints.reflection();
|
||||
|
||||
// Loaded reflectively in BootstrapUtils
|
||||
registerPublicConstructors(reflectionHints,
|
||||
// Loaded reflectively in BootstrapUtils
|
||||
org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.class,
|
||||
// Loaded reflectively in BootstrapUtils
|
||||
org.springframework.test.context.support.DefaultBootstrapContext.class
|
||||
);
|
||||
|
||||
registerDeclaredConstructors(reflectionHints,
|
||||
// Loaded reflectively in BootstrapUtils
|
||||
org.springframework.test.context.support.DefaultTestContextBootstrapper.class
|
||||
);
|
||||
|
||||
if (servletPresent) {
|
||||
registerDeclaredConstructors(reflectionHints,
|
||||
// Loaded reflectively in BootstrapUtils
|
||||
"org.springframework.test.context.web.WebTestContextBootstrapper"
|
||||
);
|
||||
}
|
||||
|
||||
if (groovyPresent) {
|
||||
registerDeclaredConstructors(reflectionHints,
|
||||
// Loaded reflectively in DelegatingSmartContextLoader
|
||||
@@ -90,10 +77,6 @@ class TestContextRuntimeHints implements RuntimeHintsRegistrar {
|
||||
reflectionHints.registerTypes(types, TypeHint.builtWith(MemberCategory.INVOKE_PUBLIC_CONSTRUCTORS));
|
||||
}
|
||||
|
||||
private static void registerDeclaredConstructors(ReflectionHints reflectionHints, Class<?>... types) {
|
||||
registerDeclaredConstructors(reflectionHints, TypeReference.listOf(types));
|
||||
}
|
||||
|
||||
private static void registerDeclaredConstructors(ReflectionHints reflectionHints, String... classNames) {
|
||||
registerDeclaredConstructors(reflectionHints, listOf(classNames));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user