Populate dependencies metadata for resolved target behind lazy dependency proxy
Closes gh-25562
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,9 +26,11 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.beans.testfixture.beans.TestBean;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
@@ -49,14 +51,18 @@ public class LazyAutowiredAnnotationBeanPostProcessorTests {
|
||||
ac.registerBeanDefinition("testBean", tbd);
|
||||
ac.refresh();
|
||||
|
||||
ConfigurableListableBeanFactory bf = ac.getBeanFactory();
|
||||
TestBeanHolder bean = ac.getBean("annotatedBean", TestBeanHolder.class);
|
||||
assertThat(ac.getBeanFactory().containsSingleton("testBean")).isFalse();
|
||||
assertThat(bf.containsSingleton("testBean")).isFalse();
|
||||
assertThat(bean.getTestBean()).isNotNull();
|
||||
assertThat(bean.getTestBean().getName()).isNull();
|
||||
assertThat(ac.getBeanFactory().containsSingleton("testBean")).isTrue();
|
||||
assertThat(bf.containsSingleton("testBean")).isTrue();
|
||||
TestBean tb = (TestBean) ac.getBean("testBean");
|
||||
tb.setName("tb");
|
||||
assertThat(bean.getTestBean().getName()).isSameAs("tb");
|
||||
|
||||
assertThat(ObjectUtils.containsElement(bf.getDependenciesForBean("annotatedBean"), "testBean")).isTrue();
|
||||
assertThat(ObjectUtils.containsElement(bf.getDependentBeans("testBean"), "annotatedBean")).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user