@@ -63,9 +63,8 @@ public class BeanFactoryUtilsTests {
63
63
64
64
65
65
@ BeforeEach
66
- public void setUp () {
66
+ public void setup () {
67
67
// Interesting hierarchical factory to test counts.
68
- // Slow to read so we cache it.
69
68
70
69
DefaultListableBeanFactory grandParent = new DefaultListableBeanFactory ();
71
70
new XmlBeanDefinitionReader (grandParent ).loadBeanDefinitions (ROOT_CONTEXT );
@@ -93,22 +92,22 @@ public void testHierarchicalCountBeansWithNonHierarchicalFactory() {
93
92
* Check that override doesn't count as two separate beans.
94
93
*/
95
94
@ Test
96
- public void testHierarchicalCountBeansWithOverride () throws Exception {
95
+ public void testHierarchicalCountBeansWithOverride () {
97
96
// Leaf count
98
97
assertThat (this .listableBeanFactory .getBeanDefinitionCount () == 1 ).isTrue ();
99
98
// Count minus duplicate
100
99
assertThat (BeanFactoryUtils .countBeansIncludingAncestors (this .listableBeanFactory ) == 8 ).as ("Should count 8 beans, not " + BeanFactoryUtils .countBeansIncludingAncestors (this .listableBeanFactory )).isTrue ();
101
100
}
102
101
103
102
@ Test
104
- public void testHierarchicalNamesWithNoMatch () throws Exception {
103
+ public void testHierarchicalNamesWithNoMatch () {
105
104
List <String > names = Arrays .asList (
106
105
BeanFactoryUtils .beanNamesForTypeIncludingAncestors (this .listableBeanFactory , NoOp .class ));
107
106
assertThat (names .size ()).isEqualTo (0 );
108
107
}
109
108
110
109
@ Test
111
- public void testHierarchicalNamesWithMatchOnlyInRoot () throws Exception {
110
+ public void testHierarchicalNamesWithMatchOnlyInRoot () {
112
111
List <String > names = Arrays .asList (
113
112
BeanFactoryUtils .beanNamesForTypeIncludingAncestors (this .listableBeanFactory , IndexedTestBean .class ));
114
113
assertThat (names .size ()).isEqualTo (1 );
@@ -118,7 +117,7 @@ public void testHierarchicalNamesWithMatchOnlyInRoot() throws Exception {
118
117
}
119
118
120
119
@ Test
121
- public void testGetBeanNamesForTypeWithOverride () throws Exception {
120
+ public void testGetBeanNamesForTypeWithOverride () {
122
121
List <String > names = Arrays .asList (
123
122
BeanFactoryUtils .beanNamesForTypeIncludingAncestors (this .listableBeanFactory , ITestBean .class ));
124
123
// includes 2 TestBeans from FactoryBeans (DummyFactory definitions)
@@ -236,7 +235,7 @@ public void testFindsBeansOfTypeWithDefaultFactory() {
236
235
}
237
236
238
237
@ Test
239
- public void testHierarchicalResolutionWithOverride () throws Exception {
238
+ public void testHierarchicalResolutionWithOverride () {
240
239
Object test3 = this .listableBeanFactory .getBean ("test3" );
241
240
Object test = this .listableBeanFactory .getBean ("test" );
242
241
@@ -276,14 +275,14 @@ public void testHierarchicalResolutionWithOverride() throws Exception {
276
275
}
277
276
278
277
@ Test
279
- public void testHierarchicalNamesForAnnotationWithNoMatch () throws Exception {
278
+ public void testHierarchicalNamesForAnnotationWithNoMatch () {
280
279
List <String > names = Arrays .asList (
281
280
BeanFactoryUtils .beanNamesForAnnotationIncludingAncestors (this .listableBeanFactory , Override .class ));
282
281
assertThat (names .size ()).isEqualTo (0 );
283
282
}
284
283
285
284
@ Test
286
- public void testHierarchicalNamesForAnnotationWithMatchOnlyInRoot () throws Exception {
285
+ public void testHierarchicalNamesForAnnotationWithMatchOnlyInRoot () {
287
286
List <String > names = Arrays .asList (
288
287
BeanFactoryUtils .beanNamesForAnnotationIncludingAncestors (this .listableBeanFactory , TestAnnotation .class ));
289
288
assertThat (names .size ()).isEqualTo (1 );
@@ -293,7 +292,7 @@ public void testHierarchicalNamesForAnnotationWithMatchOnlyInRoot() throws Excep
293
292
}
294
293
295
294
@ Test
296
- public void testGetBeanNamesForAnnotationWithOverride () throws Exception {
295
+ public void testGetBeanNamesForAnnotationWithOverride () {
297
296
AnnotatedBean annotatedBean = new AnnotatedBean ();
298
297
this .listableBeanFactory .registerSingleton ("anotherAnnotatedBean" , annotatedBean );
299
298
List <String > names = Arrays .asList (
@@ -433,6 +432,7 @@ public void isSingletonAndIsPrototypeWithStaticFactory() {
433
432
String basePackage () default "" ;
434
433
}
435
434
435
+
436
436
@ Retention (RetentionPolicy .RUNTIME )
437
437
@ ControllerAdvice
438
438
@interface RestControllerAdvice {
@@ -444,18 +444,23 @@ public void isSingletonAndIsPrototypeWithStaticFactory() {
444
444
String basePackage () default "" ;
445
445
}
446
446
447
+
447
448
@ ControllerAdvice ("com.example" )
448
449
static class ControllerAdviceClass {
449
450
}
450
451
452
+
451
453
@ RestControllerAdvice ("com.example" )
452
454
static class RestControllerAdviceClass {
453
455
}
454
456
457
+
455
458
static class TestBeanSmartFactoryBean implements SmartFactoryBean <TestBean > {
456
459
457
460
private final TestBean testBean = new TestBean ("enigma" , 42 );
461
+
458
462
private final boolean singleton ;
463
+
459
464
private final boolean prototype ;
460
465
461
466
TestBeanSmartFactoryBean (boolean singleton , boolean prototype ) {
@@ -478,7 +483,7 @@ public Class<TestBean> getObjectType() {
478
483
return TestBean .class ;
479
484
}
480
485
481
- public TestBean getObject () throws Exception {
486
+ public TestBean getObject () {
482
487
// We don't really care if the actual instance is a singleton or prototype
483
488
// for the tests that use this factory.
484
489
return this .testBean ;
0 commit comments