@@ -1271,10 +1271,11 @@ void autowireWithTwoMatchesForConstructorDependency() {
1271
1271
lbf .registerBeanDefinition ("rod" , bd );
1272
1272
RootBeanDefinition bd2 = new RootBeanDefinition (TestBean .class );
1273
1273
lbf .registerBeanDefinition ("rod2" , bd2 );
1274
- assertThatExceptionOfType (UnsatisfiedDependencyException .class ).isThrownBy (() ->
1275
- lbf .autowire (ConstructorDependency .class , AutowireCapableBeanFactory .AUTOWIRE_CONSTRUCTOR , false ))
1276
- .withMessageContaining ("rod" )
1277
- .withMessageContaining ("rod2" );
1274
+
1275
+ assertThatExceptionOfType (UnsatisfiedDependencyException .class )
1276
+ .isThrownBy (() -> lbf .autowire (ConstructorDependency .class , AutowireCapableBeanFactory .AUTOWIRE_CONSTRUCTOR , false ))
1277
+ .withMessageContaining ("rod" )
1278
+ .withMessageContaining ("rod2" );
1278
1279
}
1279
1280
1280
1281
@ Test
@@ -1336,11 +1337,12 @@ void dependsOnCycle() {
1336
1337
RootBeanDefinition bd2 = new RootBeanDefinition (TestBean .class );
1337
1338
bd2 .setDependsOn ("tb1" );
1338
1339
lbf .registerBeanDefinition ("tb2" , bd2 );
1339
- assertThatExceptionOfType (BeanCreationException .class ).isThrownBy (() ->
1340
- lbf .preInstantiateSingletons ())
1341
- .withMessageContaining ("Circular" )
1342
- .withMessageContaining ("'tb2'" )
1343
- .withMessageContaining ("'tb1'" );
1340
+
1341
+ assertThatExceptionOfType (BeanCreationException .class )
1342
+ .isThrownBy (() -> lbf .preInstantiateSingletons ())
1343
+ .withMessageContaining ("Circular" )
1344
+ .withMessageContaining ("'tb2'" )
1345
+ .withMessageContaining ("'tb1'" );
1344
1346
}
1345
1347
1346
1348
@ Test
@@ -1354,11 +1356,12 @@ void implicitDependsOnCycle() {
1354
1356
RootBeanDefinition bd3 = new RootBeanDefinition (TestBean .class );
1355
1357
bd3 .setDependsOn ("tb1" );
1356
1358
lbf .registerBeanDefinition ("tb3" , bd3 );
1357
- assertThatExceptionOfType (BeanCreationException .class ).isThrownBy (
1358
- lbf ::preInstantiateSingletons )
1359
- .withMessageContaining ("Circular" )
1360
- .withMessageContaining ("'tb3'" )
1361
- .withMessageContaining ("'tb1'" );
1359
+
1360
+ assertThatExceptionOfType (BeanCreationException .class )
1361
+ .isThrownBy (lbf ::preInstantiateSingletons )
1362
+ .withMessageContaining ("Circular" )
1363
+ .withMessageContaining ("'tb3'" )
1364
+ .withMessageContaining ("'tb1'" );
1362
1365
}
1363
1366
1364
1367
@ Test
@@ -1493,10 +1496,11 @@ void getBeanByTypeWithMultiplePriority() {
1493
1496
RootBeanDefinition bd2 = new RootBeanDefinition (HighPriorityTestBean .class );
1494
1497
lbf .registerBeanDefinition ("bd1" , bd1 );
1495
1498
lbf .registerBeanDefinition ("bd2" , bd2 );
1496
- assertThatExceptionOfType (NoUniqueBeanDefinitionException .class ).isThrownBy (() ->
1497
- lbf .getBean (TestBean .class ))
1498
- .withMessageContaining ("Multiple beans found with the same priority" )
1499
- .withMessageContaining ("5" ); // conflicting priority
1499
+
1500
+ assertThatExceptionOfType (NoUniqueBeanDefinitionException .class )
1501
+ .isThrownBy (() -> lbf .getBean (TestBean .class ))
1502
+ .withMessageContaining ("Multiple beans found with the same priority" )
1503
+ .withMessageContaining ("5" ); // conflicting priority
1500
1504
}
1501
1505
1502
1506
@ Test
@@ -1698,9 +1702,9 @@ void getBeanByTypeInstanceWithMultiplePrimary() {
1698
1702
lbf .registerBeanDefinition ("bd1" , bd1 );
1699
1703
lbf .registerBeanDefinition ("bd2" , bd2 );
1700
1704
1701
- assertThatExceptionOfType (NoUniqueBeanDefinitionException .class ). isThrownBy (() ->
1702
- lbf .getBean (ConstructorDependency .class , 42 ))
1703
- .withMessageContaining ("more than one 'primary'" );
1705
+ assertThatExceptionOfType (NoUniqueBeanDefinitionException .class )
1706
+ . isThrownBy (() -> lbf .getBean (ConstructorDependency .class , 42 ))
1707
+ .withMessageContaining ("more than one 'primary'" );
1704
1708
}
1705
1709
1706
1710
@ Test
@@ -1881,10 +1885,11 @@ void autowireBeanByTypeWithTwoMatches() {
1881
1885
RootBeanDefinition bd2 = new RootBeanDefinition (TestBean .class );
1882
1886
lbf .registerBeanDefinition ("test" , bd );
1883
1887
lbf .registerBeanDefinition ("spouse" , bd2 );
1884
- assertThatExceptionOfType (UnsatisfiedDependencyException .class ).isThrownBy (() ->
1885
- lbf .autowire (DependenciesBean .class , AutowireCapableBeanFactory .AUTOWIRE_BY_TYPE , true ))
1886
- .withMessageContaining ("test" )
1887
- .withMessageContaining ("spouse" );
1888
+
1889
+ assertThatExceptionOfType (UnsatisfiedDependencyException .class )
1890
+ .isThrownBy (() -> lbf .autowire (DependenciesBean .class , AutowireCapableBeanFactory .AUTOWIRE_BY_TYPE , true ))
1891
+ .withMessageContaining ("test" )
1892
+ .withMessageContaining ("spouse" );
1888
1893
}
1889
1894
1890
1895
@ Test
@@ -1946,10 +1951,11 @@ void autowireBeanByTypeWithIdenticalPriorityCandidates() {
1946
1951
RootBeanDefinition bd2 = new RootBeanDefinition (HighPriorityTestBean .class );
1947
1952
lbf .registerBeanDefinition ("test" , bd );
1948
1953
lbf .registerBeanDefinition ("spouse" , bd2 );
1949
- assertThatExceptionOfType (UnsatisfiedDependencyException .class ).isThrownBy (() ->
1950
- lbf .autowire (DependenciesBean .class , AutowireCapableBeanFactory .AUTOWIRE_BY_TYPE , true ))
1951
- .withCauseExactlyInstanceOf (NoUniqueBeanDefinitionException .class )
1952
- .withMessageContaining ("5" );
1954
+
1955
+ assertThatExceptionOfType (UnsatisfiedDependencyException .class )
1956
+ .isThrownBy (() -> lbf .autowire (DependenciesBean .class , AutowireCapableBeanFactory .AUTOWIRE_BY_TYPE , true ))
1957
+ .withCauseExactlyInstanceOf (NoUniqueBeanDefinitionException .class )
1958
+ .withMessageContaining ("5" );
1953
1959
}
1954
1960
1955
1961
@ Test
@@ -2185,19 +2191,21 @@ void constructorDependencyWithUnresolvableClass() {
2185
2191
@ Test
2186
2192
void beanDefinitionWithInterface () {
2187
2193
lbf .registerBeanDefinition ("test" , new RootBeanDefinition (ITestBean .class ));
2188
- assertThatExceptionOfType (BeanCreationException .class ).isThrownBy (() ->
2189
- lbf .getBean ("test" ))
2190
- .withMessageContaining ("interface" )
2191
- .satisfies (ex -> assertThat (ex .getBeanName ()).isEqualTo ("test" ));
2194
+
2195
+ assertThatExceptionOfType (BeanCreationException .class )
2196
+ .isThrownBy (() -> lbf .getBean ("test" ))
2197
+ .withMessageContaining ("interface" )
2198
+ .satisfies (ex -> assertThat (ex .getBeanName ()).isEqualTo ("test" ));
2192
2199
}
2193
2200
2194
2201
@ Test
2195
2202
void beanDefinitionWithAbstractClass () {
2196
2203
lbf .registerBeanDefinition ("test" , new RootBeanDefinition (AbstractBeanFactory .class ));
2197
- assertThatExceptionOfType (BeanCreationException .class ).isThrownBy (() ->
2198
- lbf .getBean ("test" ))
2199
- .withMessageContaining ("abstract" )
2200
- .satisfies (ex -> assertThat (ex .getBeanName ()).isEqualTo ("test" ));
2204
+
2205
+ assertThatExceptionOfType (BeanCreationException .class )
2206
+ .isThrownBy (() -> lbf .getBean ("test" ))
2207
+ .withMessageContaining ("abstract" )
2208
+ .satisfies (ex -> assertThat (ex .getBeanName ()).isEqualTo ("test" ));
2201
2209
}
2202
2210
2203
2211
@ Test
0 commit comments