|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2020 the original author or authors. |
| 2 | + * Copyright 2012-2021 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
25 | 25 | import org.springframework.boot.autoconfigure.AutoConfigurations;
|
26 | 26 | import org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration;
|
27 | 27 | import org.springframework.boot.test.context.runner.ApplicationContextRunner;
|
| 28 | +import org.springframework.jdbc.datasource.DataSourceTransactionManager; |
28 | 29 | import org.springframework.jdbc.support.JdbcTransactionManager;
|
29 | 30 | import org.springframework.transaction.TransactionManager;
|
30 | 31 |
|
@@ -83,6 +84,29 @@ void transactionManagerWithExistingTransactionManagerIsNotOverridden() {
|
83 | 84 | .hasBean("myTransactionManager"));
|
84 | 85 | }
|
85 | 86 |
|
| 87 | + @Test // gh-24321 |
| 88 | + void transactionManagerWithDaoExceptionTranslationDisabled() { |
| 89 | + this.contextRunner.withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class)) |
| 90 | + .withPropertyValues("spring.dao.exceptiontranslation.enable=false") |
| 91 | + .run((context) -> assertThat(context.getBean(TransactionManager.class)) |
| 92 | + .isExactlyInstanceOf(DataSourceTransactionManager.class)); |
| 93 | + } |
| 94 | + |
| 95 | + @Test // gh-24321 |
| 96 | + void transactionManagerWithDaoExceptionTranslationEnabled() { |
| 97 | + this.contextRunner.withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class)) |
| 98 | + .withPropertyValues("spring.dao.exceptiontranslation.enable=true") |
| 99 | + .run((context) -> assertThat(context.getBean(TransactionManager.class)) |
| 100 | + .isExactlyInstanceOf(JdbcTransactionManager.class)); |
| 101 | + } |
| 102 | + |
| 103 | + @Test // gh-24321 |
| 104 | + void transactionManagerWithDaoExceptionTranslationDefault() { |
| 105 | + this.contextRunner.withConfiguration(AutoConfigurations.of(DataSourceAutoConfiguration.class)) |
| 106 | + .run((context) -> assertThat(context.getBean(TransactionManager.class)) |
| 107 | + .isExactlyInstanceOf(JdbcTransactionManager.class)); |
| 108 | + } |
| 109 | + |
86 | 110 | @Test
|
87 | 111 | void transactionWithMultipleDataSourcesIsNotConfigured() {
|
88 | 112 | this.contextRunner.withUserConfiguration(MultiDataSourceConfiguration.class)
|
|
0 commit comments