23
23
import org .junit .jupiter .api .Test ;
24
24
25
25
import org .springframework .aop .support .AopUtils ;
26
+ import org .springframework .beans .factory .NoUniqueBeanDefinitionException ;
26
27
import org .springframework .beans .factory .annotation .Autowired ;
27
28
import org .springframework .context .ConfigurableApplicationContext ;
28
29
import org .springframework .context .annotation .AdviceMode ;
46
47
47
48
import static org .assertj .core .api .Assertions .assertThat ;
48
49
import static org .assertj .core .api .Assertions .assertThatException ;
50
+ import static org .assertj .core .api .AssertionsForClassTypes .assertThatExceptionOfType ;
49
51
50
52
/**
51
53
* Tests demonstrating use of @EnableTransactionManagement @Configuration classes.
@@ -226,8 +228,8 @@ void proxyTypeAspectJCausesRegistrationOfAnnotationTransactionAspect() {
226
228
// should throw CNFE when trying to load AnnotationTransactionAspect.
227
229
// Do you actually have org.springframework.aspects on the classpath?
228
230
assertThatException ()
229
- .isThrownBy (() -> new AnnotationConfigApplicationContext (EnableAspectjTxConfig .class , TxManagerConfig .class ))
230
- .withMessageContaining ("AspectJJtaTransactionManagementConfiguration" );
231
+ .isThrownBy (() -> new AnnotationConfigApplicationContext (EnableAspectjTxConfig .class , TxManagerConfig .class ))
232
+ .withMessageContaining ("AspectJJtaTransactionManagementConfiguration" );
231
233
}
232
234
233
235
@ Test
@@ -254,11 +256,13 @@ void spr11915TransactionManagerAsManualSingleton() {
254
256
assertThat (txManager .commits ).isEqualTo (2 );
255
257
assertThat (txManager .rollbacks ).isEqualTo (0 );
256
258
259
+ assertThatExceptionOfType (NoUniqueBeanDefinitionException .class ).isThrownBy (bean ::findAllFoos );
260
+
257
261
ctx .close ();
258
262
}
259
263
260
264
@ Test
261
- void spr14322FindsOnInterfaceWithInterfaceProxy () {
265
+ void spr14322AnnotationOnInterfaceWithInterfaceProxy () {
262
266
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext (Spr14322ConfigA .class );
263
267
TransactionalTestInterface bean = ctx .getBean (TransactionalTestInterface .class );
264
268
CallCountingTransactionManager txManager = ctx .getBean (CallCountingTransactionManager .class );
@@ -273,7 +277,7 @@ void spr14322FindsOnInterfaceWithInterfaceProxy() {
273
277
}
274
278
275
279
@ Test
276
- void spr14322FindsOnInterfaceWithCglibProxy () {
280
+ void spr14322AnnotationOnInterfaceWithCglibProxy () {
277
281
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext (Spr14322ConfigB .class );
278
282
TransactionalTestInterface bean = ctx .getBean (TransactionalTestInterface .class );
279
283
CallCountingTransactionManager txManager = ctx .getBean (CallCountingTransactionManager .class );
@@ -504,6 +508,11 @@ public void initializeApp(ConfigurableApplicationContext applicationContext) {
504
508
public TransactionalTestBean testBean () {
505
509
return new TransactionalTestBean ();
506
510
}
511
+
512
+ @ Bean
513
+ public CallCountingTransactionManager otherTxManager () {
514
+ return new CallCountingTransactionManager ();
515
+ }
507
516
}
508
517
509
518
0 commit comments