Skip to content

Commit d56e3bf

Browse files
committed
Add tests for doma.exception-translation-enabled
1 parent 2374ed0 commit d56e3bf

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

doma-spring-boot-autoconfigure/src/test/java/org/seasar/doma/boot/autoconfigure/DomaAutoConfigurationTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
import org.seasar.doma.jdbc.dialect.PostgresDialect;
2525
import org.seasar.doma.jdbc.dialect.StandardDialect;
2626
import org.seasar.doma.message.Message;
27+
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
2728
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
29+
import org.springframework.boot.test.EnvironmentTestUtils;
2830
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
2931
import org.springframework.context.annotation.Bean;
3032
import org.springframework.context.annotation.Configuration;
@@ -108,6 +110,28 @@ public void testConfigWithConfig() {
108110
assertThat(translator, is(instanceOf(DomaPersistenceExceptionTranslator.class)));
109111
}
110112

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+
111135
@Test
112136
public void testSQLExceptionTranslator() {
113137
this.context.register(DomaAutoConfiguration.class,

0 commit comments

Comments
 (0)