|
24 | 24 | import org.seasar.doma.jdbc.dialect.PostgresDialect; |
25 | 25 | import org.seasar.doma.jdbc.dialect.StandardDialect; |
26 | 26 | import org.seasar.doma.message.Message; |
| 27 | +import org.springframework.beans.factory.NoSuchBeanDefinitionException; |
27 | 28 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; |
| 29 | +import org.springframework.boot.test.EnvironmentTestUtils; |
28 | 30 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; |
29 | 31 | import org.springframework.context.annotation.Bean; |
30 | 32 | import org.springframework.context.annotation.Configuration; |
@@ -108,6 +110,28 @@ public void testConfigWithConfig() { |
108 | 110 | assertThat(translator, is(instanceOf(DomaPersistenceExceptionTranslator.class))); |
109 | 111 | } |
110 | 112 |
|
| 113 | + @Test(expected = NoSuchBeanDefinitionException.class) |
| 114 | + public void testExceptionTranslationEnabledSpecifyFalse() { |
| 115 | + EnvironmentTestUtils.addEnvironment(this.context, |
| 116 | + "doma.exception-translation-enabled:false"); |
| 117 | + this.context.register(DomaAutoConfiguration.class, |
| 118 | + DataSourceAutoConfiguration.class); |
| 119 | + this.context.refresh(); |
| 120 | + this.context.getBean(PersistenceExceptionTranslator.class); |
| 121 | + } |
| 122 | + |
| 123 | + @Test |
| 124 | + public void testExceptionTranslationEnabledSpecifyTrue() { |
| 125 | + EnvironmentTestUtils.addEnvironment(this.context, |
| 126 | + "doma.exception-translation-enabled:true"); |
| 127 | + this.context.register(DomaAutoConfiguration.class, |
| 128 | + DataSourceAutoConfiguration.class); |
| 129 | + this.context.refresh(); |
| 130 | + PersistenceExceptionTranslator translator = this.context |
| 131 | + .getBean(PersistenceExceptionTranslator.class); |
| 132 | + assertThat(translator, is(instanceOf(DomaPersistenceExceptionTranslator.class))); |
| 133 | + } |
| 134 | + |
111 | 135 | @Test |
112 | 136 | public void testSQLExceptionTranslator() { |
113 | 137 | this.context.register(DomaAutoConfiguration.class, |
|
0 commit comments