@@ -799,9 +799,10 @@ void canReferenceParentBeanFromChildViaAlias() {
799
799
TestBean child = (TestBean ) factory .getBean ("child" );
800
800
assertThat (child .getName ()).isEqualTo (EXPECTED_NAME );
801
801
assertThat (child .getAge ()).isEqualTo (EXPECTED_AGE );
802
+ Object mergedBeanDefinition1 = factory .getMergedBeanDefinition ("child" );
802
803
Object mergedBeanDefinition2 = factory .getMergedBeanDefinition ("child" );
803
804
804
- assertThat (mergedBeanDefinition2 ).as ("Use cached merged bean definition" ).isEqualTo (mergedBeanDefinition2 );
805
+ assertThat (mergedBeanDefinition1 ).as ("Use cached merged bean definition" ).isEqualTo (mergedBeanDefinition2 );
805
806
}
806
807
807
808
@ Test
@@ -1849,8 +1850,7 @@ void autowireBeanWithFactoryBeanByType() {
1849
1850
assertThat (factoryBean ).as ("The FactoryBean should have been registered." ).isNotNull ();
1850
1851
FactoryBeanDependentBean bean = (FactoryBeanDependentBean ) lbf .autowire (FactoryBeanDependentBean .class ,
1851
1852
AutowireCapableBeanFactory .AUTOWIRE_BY_TYPE , true );
1852
- Object mergedBeanDefinition2 = bean .getFactoryBean ();
1853
- assertThat (mergedBeanDefinition2 ).as ("The FactoryBeanDependentBean should have been autowired 'by type' with the LazyInitFactory." ).isEqualTo (mergedBeanDefinition2 );
1853
+ assertThat (bean .getFactoryBean ()).as ("The FactoryBeanDependentBean should have been autowired 'by type' with the LazyInitFactory." ).isEqualTo (factoryBean );
1854
1854
}
1855
1855
1856
1856
@ Test
@@ -2556,8 +2556,7 @@ public Object postProcessBeforeInitialization(Object bean, String beanName) {
2556
2556
BeanWithDestroyMethod .closeCount = 0 ;
2557
2557
lbf .preInstantiateSingletons ();
2558
2558
lbf .destroySingletons ();
2559
- Object mergedBeanDefinition2 = BeanWithDestroyMethod .closeCount ;
2560
- assertThat (mergedBeanDefinition2 ).as ("Destroy methods invoked" ).isEqualTo (mergedBeanDefinition2 );
2559
+ assertThat (BeanWithDestroyMethod .closeCount ).as ("Destroy methods invoked" ).isEqualTo (1 );
2561
2560
}
2562
2561
2563
2562
@ Test
@@ -2571,8 +2570,7 @@ void destroyMethodOnInnerBean() {
2571
2570
BeanWithDestroyMethod .closeCount = 0 ;
2572
2571
lbf .preInstantiateSingletons ();
2573
2572
lbf .destroySingletons ();
2574
- Object mergedBeanDefinition2 = BeanWithDestroyMethod .closeCount ;
2575
- assertThat (mergedBeanDefinition2 ).as ("Destroy methods invoked" ).isEqualTo (mergedBeanDefinition2 );
2573
+ assertThat (BeanWithDestroyMethod .closeCount ).as ("Destroy methods invoked" ).isEqualTo (2 );
2576
2574
}
2577
2575
2578
2576
@ Test
@@ -2587,8 +2585,7 @@ void destroyMethodOnInnerBeanAsPrototype() {
2587
2585
BeanWithDestroyMethod .closeCount = 0 ;
2588
2586
lbf .preInstantiateSingletons ();
2589
2587
lbf .destroySingletons ();
2590
- Object mergedBeanDefinition2 = BeanWithDestroyMethod .closeCount ;
2591
- assertThat (mergedBeanDefinition2 ).as ("Destroy methods invoked" ).isEqualTo (mergedBeanDefinition2 );
2588
+ assertThat (BeanWithDestroyMethod .closeCount ).as ("Destroy methods invoked" ).isEqualTo (1 );
2592
2589
}
2593
2590
2594
2591
@ Test
@@ -2710,14 +2707,15 @@ void explicitScopeInheritanceForChildBeanDefinitions() {
2710
2707
factory .registerBeanDefinition ("child" , child );
2711
2708
2712
2709
AbstractBeanDefinition def = (AbstractBeanDefinition ) factory .getBeanDefinition ("child" );
2713
- Object mergedBeanDefinition2 = def .getScope ();
2714
- assertThat (mergedBeanDefinition2 ).as ("Child 'scope' not overriding parent scope (it must)." ).isEqualTo (mergedBeanDefinition2 );
2710
+ assertThat (def .getScope ()).as ("Child 'scope' not overriding parent scope (it must)." ).isEqualTo (theChildScope );
2715
2711
}
2716
2712
2717
2713
@ Test
2718
2714
void scopeInheritanceForChildBeanDefinitions () {
2715
+ String theParentScope = "bonanza!" ;
2716
+
2719
2717
RootBeanDefinition parent = new RootBeanDefinition ();
2720
- parent .setScope ("bonanza!" );
2718
+ parent .setScope (theParentScope );
2721
2719
2722
2720
AbstractBeanDefinition child = new ChildBeanDefinition ("parent" );
2723
2721
child .setBeanClass (TestBean .class );
@@ -2727,8 +2725,7 @@ void scopeInheritanceForChildBeanDefinitions() {
2727
2725
factory .registerBeanDefinition ("child" , child );
2728
2726
2729
2727
BeanDefinition def = factory .getMergedBeanDefinition ("child" );
2730
- Object mergedBeanDefinition2 = def .getScope ();
2731
- assertThat (mergedBeanDefinition2 ).as ("Child 'scope' not inherited" ).isEqualTo (mergedBeanDefinition2 );
2728
+ assertThat (def .getScope ()).as ("Child 'scope' not inherited" ).isEqualTo (theParentScope );
2732
2729
}
2733
2730
2734
2731
@ Test
@@ -2764,15 +2761,12 @@ public boolean postProcessAfterInstantiation(Object bean, String beanName) throw
2764
2761
});
2765
2762
lbf .preInstantiateSingletons ();
2766
2763
TestBean tb = (TestBean ) lbf .getBean ("test" );
2767
- Object mergedBeanDefinition2 = tb .getName ();
2768
- assertThat (mergedBeanDefinition2 ).as ("Name was set on field by IAPP" ).isEqualTo (mergedBeanDefinition2 );
2764
+ assertThat (tb .getName ()).as ("Name was set on field by IAPP" ).isEqualTo (nameSetOnField );
2769
2765
if (!skipPropertyPopulation ) {
2770
- Object mergedBeanDefinition21 = tb .getAge ();
2771
- assertThat (mergedBeanDefinition21 ).as ("Property value still set" ).isEqualTo (mergedBeanDefinition21 );
2766
+ assertThat (tb .getAge ()).as ("Property value still set" ).isEqualTo (ageSetByPropertyValue );
2772
2767
}
2773
2768
else {
2774
- Object mergedBeanDefinition21 = tb .getAge ();
2775
- assertThat (mergedBeanDefinition21 ).as ("Property value was NOT set and still has default value" ).isEqualTo (mergedBeanDefinition21 );
2769
+ assertThat (tb .getAge ()).as ("Property value was NOT set and still has default value" ).isEqualTo (0 );
2776
2770
}
2777
2771
}
2778
2772
0 commit comments