|
|
|
|
@ -1370,8 +1370,8 @@ class DefaultListableBeanFactoryTests {
@@ -1370,8 +1370,8 @@ class DefaultListableBeanFactoryTests {
|
|
|
|
|
lbf.registerBeanDefinition("rod2", bd2); |
|
|
|
|
lbf.setParameterNameDiscoverer(new DefaultParameterNameDiscoverer()); |
|
|
|
|
|
|
|
|
|
assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(() -> |
|
|
|
|
lbf.autowire(ConstructorDependency.class, AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false)) |
|
|
|
|
assertThatExceptionOfType(UnsatisfiedDependencyException.class) |
|
|
|
|
.isThrownBy(() -> lbf.autowire(ConstructorDependency.class, AutowireCapableBeanFactory.AUTOWIRE_CONSTRUCTOR, false)) |
|
|
|
|
.withMessageContaining("rod") |
|
|
|
|
.withMessageContaining("rod2"); |
|
|
|
|
} |
|
|
|
|
@ -1441,8 +1441,8 @@ class DefaultListableBeanFactoryTests {
@@ -1441,8 +1441,8 @@ class DefaultListableBeanFactoryTests {
|
|
|
|
|
bd2.setDependsOn("tb1"); |
|
|
|
|
lbf.registerBeanDefinition("tb2", bd2); |
|
|
|
|
|
|
|
|
|
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> |
|
|
|
|
lbf.preInstantiateSingletons()) |
|
|
|
|
assertThatExceptionOfType(BeanCreationException.class) |
|
|
|
|
.isThrownBy(() -> lbf.preInstantiateSingletons()) |
|
|
|
|
.withMessageContaining("Circular") |
|
|
|
|
.withMessageContaining("'tb2'") |
|
|
|
|
.withMessageContaining("'tb1'"); |
|
|
|
|
@ -1460,8 +1460,8 @@ class DefaultListableBeanFactoryTests {
@@ -1460,8 +1460,8 @@ class DefaultListableBeanFactoryTests {
|
|
|
|
|
bd3.setDependsOn("tb1"); |
|
|
|
|
lbf.registerBeanDefinition("tb3", bd3); |
|
|
|
|
|
|
|
|
|
assertThatExceptionOfType(BeanCreationException.class).isThrownBy( |
|
|
|
|
lbf::preInstantiateSingletons) |
|
|
|
|
assertThatExceptionOfType(BeanCreationException.class) |
|
|
|
|
.isThrownBy(lbf::preInstantiateSingletons) |
|
|
|
|
.withMessageContaining("Circular") |
|
|
|
|
.withMessageContaining("'tb3'") |
|
|
|
|
.withMessageContaining("'tb1'"); |
|
|
|
|
@ -1607,8 +1607,8 @@ class DefaultListableBeanFactoryTests {
@@ -1607,8 +1607,8 @@ class DefaultListableBeanFactoryTests {
|
|
|
|
|
lbf.registerBeanDefinition("bd1", bd1); |
|
|
|
|
lbf.registerBeanDefinition("bd2", bd2); |
|
|
|
|
|
|
|
|
|
assertThatExceptionOfType(NoUniqueBeanDefinitionException.class).isThrownBy(() -> |
|
|
|
|
lbf.getBean(TestBean.class)) |
|
|
|
|
assertThatExceptionOfType(NoUniqueBeanDefinitionException.class) |
|
|
|
|
.isThrownBy(() -> lbf.getBean(TestBean.class)) |
|
|
|
|
.withMessageContaining("Multiple beans found with the same priority") |
|
|
|
|
.withMessageContaining("5"); // conflicting priority
|
|
|
|
|
} |
|
|
|
|
@ -1815,8 +1815,8 @@ class DefaultListableBeanFactoryTests {
@@ -1815,8 +1815,8 @@ class DefaultListableBeanFactoryTests {
|
|
|
|
|
lbf.registerBeanDefinition("bd1", bd1); |
|
|
|
|
lbf.registerBeanDefinition("bd2", bd2); |
|
|
|
|
|
|
|
|
|
assertThatExceptionOfType(NoUniqueBeanDefinitionException.class).isThrownBy(() -> |
|
|
|
|
lbf.getBean(ConstructorDependency.class, 42)) |
|
|
|
|
assertThatExceptionOfType(NoUniqueBeanDefinitionException.class) |
|
|
|
|
.isThrownBy(() -> lbf.getBean(ConstructorDependency.class, 42)) |
|
|
|
|
.withMessageContaining("more than one 'primary'"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -2004,8 +2004,8 @@ class DefaultListableBeanFactoryTests {
@@ -2004,8 +2004,8 @@ class DefaultListableBeanFactoryTests {
|
|
|
|
|
lbf.registerBeanDefinition("test", bd); |
|
|
|
|
lbf.registerBeanDefinition("spouse", bd2); |
|
|
|
|
|
|
|
|
|
assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(() -> |
|
|
|
|
lbf.autowire(DependenciesBean.class, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true)) |
|
|
|
|
assertThatExceptionOfType(UnsatisfiedDependencyException.class) |
|
|
|
|
.isThrownBy(() -> lbf.autowire(DependenciesBean.class, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true)) |
|
|
|
|
.withMessageContaining("test") |
|
|
|
|
.withMessageContaining("spouse"); |
|
|
|
|
} |
|
|
|
|
@ -2071,8 +2071,8 @@ class DefaultListableBeanFactoryTests {
@@ -2071,8 +2071,8 @@ class DefaultListableBeanFactoryTests {
|
|
|
|
|
lbf.registerBeanDefinition("test", bd); |
|
|
|
|
lbf.registerBeanDefinition("spouse", bd2); |
|
|
|
|
|
|
|
|
|
assertThatExceptionOfType(UnsatisfiedDependencyException.class).isThrownBy(() -> |
|
|
|
|
lbf.autowire(DependenciesBean.class, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true)) |
|
|
|
|
assertThatExceptionOfType(UnsatisfiedDependencyException.class) |
|
|
|
|
.isThrownBy(() -> lbf.autowire(DependenciesBean.class, AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, true)) |
|
|
|
|
.withCauseExactlyInstanceOf(NoUniqueBeanDefinitionException.class) |
|
|
|
|
.withMessageContaining("5"); |
|
|
|
|
} |
|
|
|
|
@ -2337,8 +2337,8 @@ class DefaultListableBeanFactoryTests {
@@ -2337,8 +2337,8 @@ class DefaultListableBeanFactoryTests {
|
|
|
|
|
void beanDefinitionWithInterface() { |
|
|
|
|
lbf.registerBeanDefinition("test", new RootBeanDefinition(ITestBean.class)); |
|
|
|
|
|
|
|
|
|
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> |
|
|
|
|
lbf.getBean("test")) |
|
|
|
|
assertThatExceptionOfType(BeanCreationException.class) |
|
|
|
|
.isThrownBy(() -> lbf.getBean("test")) |
|
|
|
|
.withMessageContaining("interface") |
|
|
|
|
.satisfies(ex -> assertThat(ex.getBeanName()).isEqualTo("test")); |
|
|
|
|
} |
|
|
|
|
@ -2347,8 +2347,8 @@ class DefaultListableBeanFactoryTests {
@@ -2347,8 +2347,8 @@ class DefaultListableBeanFactoryTests {
|
|
|
|
|
void beanDefinitionWithAbstractClass() { |
|
|
|
|
lbf.registerBeanDefinition("test", new RootBeanDefinition(AbstractBeanFactory.class)); |
|
|
|
|
|
|
|
|
|
assertThatExceptionOfType(BeanCreationException.class).isThrownBy(() -> |
|
|
|
|
lbf.getBean("test")) |
|
|
|
|
assertThatExceptionOfType(BeanCreationException.class) |
|
|
|
|
.isThrownBy(() -> lbf.getBean("test")) |
|
|
|
|
.withMessageContaining("abstract") |
|
|
|
|
.satisfies(ex -> assertThat(ex.getBeanName()).isEqualTo("test")); |
|
|
|
|
} |
|
|
|
|
|