Align implementation of injectDependencies() with injectDependenciesInAotMode()

This commit is contained in:
Sam Brannen
2026-02-26 18:01:01 +01:00
parent 0dc44f79d5
commit 824aa137f8
@@ -151,10 +151,11 @@ public class DependencyInjectionTestExecutionListener extends AbstractTestExecut
*/
protected void injectDependencies(TestContext testContext) throws Exception {
Object bean = testContext.getTestInstance();
Class<?> clazz = testContext.getTestClass();
String beanName = testContext.getTestClass().getName() + AutowireCapableBeanFactory.ORIGINAL_INSTANCE_SUFFIX;
AutowireCapableBeanFactory beanFactory = testContext.getApplicationContext().getAutowireCapableBeanFactory();
beanFactory.autowireBeanProperties(bean, AutowireCapableBeanFactory.AUTOWIRE_NO, false);
beanFactory.initializeBean(bean, clazz.getName() + AutowireCapableBeanFactory.ORIGINAL_INSTANCE_SUFFIX);
beanFactory.initializeBean(bean, beanName);
testContext.removeAttribute(REINJECT_DEPENDENCIES_ATTRIBUTE);
}