Search in sources :

Example 6 with PersistenceExceptionTranslationPostProcessor

use of org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor in project spring-boot by spring-projects.

the class PersistenceExceptionTranslationAutoConfigurationTests method exceptionTranslationPostProcessorCanBeDisabled.

@Test
void exceptionTranslationPostProcessorCanBeDisabled() {
    this.context = new AnnotationConfigApplicationContext();
    TestPropertyValues.of("spring.dao.exceptiontranslation.enabled=false").applyTo(this.context);
    this.context.register(PersistenceExceptionTranslationAutoConfiguration.class);
    this.context.refresh();
    Map<String, PersistenceExceptionTranslationPostProcessor> beans = this.context.getBeansOfType(PersistenceExceptionTranslationPostProcessor.class);
    assertThat(beans).isEmpty();
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) PersistenceExceptionTranslationPostProcessor(org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor) Test(org.junit.jupiter.api.Test)

Example 7 with PersistenceExceptionTranslationPostProcessor

use of org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor in project spring-boot by spring-projects.

the class PersistenceExceptionTranslationAutoConfigurationTests method exceptionTranslationPostProcessorUsesCglibByDefault.

@Test
void exceptionTranslationPostProcessorUsesCglibByDefault() {
    this.context = new AnnotationConfigApplicationContext(PersistenceExceptionTranslationAutoConfiguration.class);
    Map<String, PersistenceExceptionTranslationPostProcessor> beans = this.context.getBeansOfType(PersistenceExceptionTranslationPostProcessor.class);
    assertThat(beans).hasSize(1);
    assertThat(beans.values().iterator().next().isProxyTargetClass()).isTrue();
}
Also used : AnnotationConfigApplicationContext(org.springframework.context.annotation.AnnotationConfigApplicationContext) PersistenceExceptionTranslationPostProcessor(org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor) Test(org.junit.jupiter.api.Test)

Aggregations

PersistenceExceptionTranslationPostProcessor (org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor)7 AnnotationConfigApplicationContext (org.springframework.context.annotation.AnnotationConfigApplicationContext)5 Test (org.junit.jupiter.api.Test)3 Test (org.junit.Test)2 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)2 ConditionalOnProperty (org.springframework.boot.autoconfigure.condition.ConditionalOnProperty)2 Bean (org.springframework.context.annotation.Bean)2