@@ -788,9 +788,10 @@ void canReferenceParentBeanFromChildViaAlias() {
788
788
TestBean child = (TestBean ) factory .getBean ("child" );
789
789
assertThat (child .getName ()).isEqualTo (EXPECTED_NAME );
790
790
assertThat (child .getAge ()).isEqualTo (EXPECTED_AGE );
791
+ Object mergedBeanDefinition1 = factory .getMergedBeanDefinition ("child" );
791
792
Object mergedBeanDefinition2 = factory .getMergedBeanDefinition ("child" );
792
793
793
- assertThat (mergedBeanDefinition2 ).as ("Use cached merged bean definition" ).isEqualTo (mergedBeanDefinition2 );
794
+ assertThat (mergedBeanDefinition1 ).as ("Use cached merged bean definition" ).isEqualTo (mergedBeanDefinition2 );
794
795
}
795
796
796
797
@ Test
@@ -1838,8 +1839,7 @@ void autowireBeanWithFactoryBeanByType() {
1838
1839
assertThat (factoryBean ).as ("The FactoryBean should have been registered." ).isNotNull ();
1839
1840
FactoryBeanDependentBean bean = (FactoryBeanDependentBean ) lbf .autowire (FactoryBeanDependentBean .class ,
1840
1841
AutowireCapableBeanFactory .AUTOWIRE_BY_TYPE , true );
1841
- Object mergedBeanDefinition2 = bean .getFactoryBean ();
1842
- assertThat (mergedBeanDefinition2 ).as ("The FactoryBeanDependentBean should have been autowired 'by type' with the LazyInitFactory." ).isEqualTo (mergedBeanDefinition2 );
1842
+ assertThat (bean .getFactoryBean ()).as ("The FactoryBeanDependentBean should have been autowired 'by type' with the LazyInitFactory." ).isEqualTo (factoryBean );
1843
1843
}
1844
1844
1845
1845
@ Test
@@ -2388,8 +2388,7 @@ public Object postProcessBeforeInitialization(Object bean, String beanName) {
2388
2388
BeanWithDestroyMethod .closeCount = 0 ;
2389
2389
lbf .preInstantiateSingletons ();
2390
2390
lbf .destroySingletons ();
2391
- Object mergedBeanDefinition2 = BeanWithDestroyMethod .closeCount ;
2392
- assertThat (mergedBeanDefinition2 ).as ("Destroy methods invoked" ).isEqualTo (mergedBeanDefinition2 );
2391
+ assertThat (BeanWithDestroyMethod .closeCount ).as ("Destroy methods invoked" ).isEqualTo (1 );
2393
2392
}
2394
2393
2395
2394
@ Test
@@ -2403,8 +2402,7 @@ void destroyMethodOnInnerBean() {
2403
2402
BeanWithDestroyMethod .closeCount = 0 ;
2404
2403
lbf .preInstantiateSingletons ();
2405
2404
lbf .destroySingletons ();
2406
- Object mergedBeanDefinition2 = BeanWithDestroyMethod .closeCount ;
2407
- assertThat (mergedBeanDefinition2 ).as ("Destroy methods invoked" ).isEqualTo (mergedBeanDefinition2 );
2405
+ assertThat (BeanWithDestroyMethod .closeCount ).as ("Destroy methods invoked" ).isEqualTo (2 );
2408
2406
}
2409
2407
2410
2408
@ Test
@@ -2419,8 +2417,7 @@ void destroyMethodOnInnerBeanAsPrototype() {
2419
2417
BeanWithDestroyMethod .closeCount = 0 ;
2420
2418
lbf .preInstantiateSingletons ();
2421
2419
lbf .destroySingletons ();
2422
- Object mergedBeanDefinition2 = BeanWithDestroyMethod .closeCount ;
2423
- assertThat (mergedBeanDefinition2 ).as ("Destroy methods invoked" ).isEqualTo (mergedBeanDefinition2 );
2420
+ assertThat (BeanWithDestroyMethod .closeCount ).as ("Destroy methods invoked" ).isEqualTo (1 );
2424
2421
}
2425
2422
2426
2423
@ Test
@@ -2542,14 +2539,15 @@ void explicitScopeInheritanceForChildBeanDefinitions() {
2542
2539
factory .registerBeanDefinition ("child" , child );
2543
2540
2544
2541
AbstractBeanDefinition def = (AbstractBeanDefinition ) factory .getBeanDefinition ("child" );
2545
- Object mergedBeanDefinition2 = def .getScope ();
2546
- assertThat (mergedBeanDefinition2 ).as ("Child 'scope' not overriding parent scope (it must)." ).isEqualTo (mergedBeanDefinition2 );
2542
+ assertThat (def .getScope ()).as ("Child 'scope' not overriding parent scope (it must)." ).isEqualTo (theChildScope );
2547
2543
}
2548
2544
2549
2545
@ Test
2550
2546
void scopeInheritanceForChildBeanDefinitions () {
2547
+ String theParentScope = "bonanza!" ;
2548
+
2551
2549
RootBeanDefinition parent = new RootBeanDefinition ();
2552
- parent .setScope ("bonanza!" );
2550
+ parent .setScope (theParentScope );
2553
2551
2554
2552
AbstractBeanDefinition child = new ChildBeanDefinition ("parent" );
2555
2553
child .setBeanClass (TestBean .class );
@@ -2559,8 +2557,7 @@ void scopeInheritanceForChildBeanDefinitions() {
2559
2557
factory .registerBeanDefinition ("child" , child );
2560
2558
2561
2559
BeanDefinition def = factory .getMergedBeanDefinition ("child" );
2562
- Object mergedBeanDefinition2 = def .getScope ();
2563
- assertThat (mergedBeanDefinition2 ).as ("Child 'scope' not inherited" ).isEqualTo (mergedBeanDefinition2 );
2560
+ assertThat (def .getScope ()).as ("Child 'scope' not inherited" ).isEqualTo (theParentScope );
2564
2561
}
2565
2562
2566
2563
@ Test
@@ -2596,15 +2593,12 @@ public boolean postProcessAfterInstantiation(Object bean, String beanName) throw
2596
2593
});
2597
2594
lbf .preInstantiateSingletons ();
2598
2595
TestBean tb = (TestBean ) lbf .getBean ("test" );
2599
- Object mergedBeanDefinition2 = tb .getName ();
2600
- assertThat (mergedBeanDefinition2 ).as ("Name was set on field by IAPP" ).isEqualTo (mergedBeanDefinition2 );
2596
+ assertThat (tb .getName ()).as ("Name was set on field by IAPP" ).isEqualTo (nameSetOnField );
2601
2597
if (!skipPropertyPopulation ) {
2602
- Object mergedBeanDefinition21 = tb .getAge ();
2603
- assertThat (mergedBeanDefinition21 ).as ("Property value still set" ).isEqualTo (mergedBeanDefinition21 );
2598
+ assertThat (tb .getAge ()).as ("Property value still set" ).isEqualTo (ageSetByPropertyValue );
2604
2599
}
2605
2600
else {
2606
- Object mergedBeanDefinition21 = tb .getAge ();
2607
- assertThat (mergedBeanDefinition21 ).as ("Property value was NOT set and still has default value" ).isEqualTo (mergedBeanDefinition21 );
2601
+ assertThat (tb .getAge ()).as ("Property value was NOT set and still has default value" ).isEqualTo (0 );
2608
2602
}
2609
2603
}
2610
2604
0 commit comments