@ -1,5 +1,5 @@
/ *
* Copyright 2012 - 201 6 the original author or authors .
* Copyright 2012 - 201 7 the original author or authors .
*
* Licensed under the Apache License , Version 2.0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
@ -37,10 +37,10 @@ import org.springframework.stereotype.Repository;
import static org.assertj.core.api.Assertions.assertThat ;
/ * *
*
* Tests for { @link PersistenceExceptionTranslationAutoConfiguration }
*
* @author Andy Wilkinson
* @author Stephane Nicoll
* /
public class PersistenceExceptionTranslationAutoConfigurationTests {
@ -54,7 +54,7 @@ public class PersistenceExceptionTranslationAutoConfigurationTests {
}
@Test
public void exceptionTranslationPostProcessor BeanIsCreated ( ) {
public void exceptionTranslationPostProcessor UsesCglibByDefault ( ) {
this . context = new AnnotationConfigApplicationContext (
PersistenceExceptionTranslationAutoConfiguration . class ) ;
Map < String , PersistenceExceptionTranslationPostProcessor > beans = this . context
@ -64,7 +64,20 @@ public class PersistenceExceptionTranslationAutoConfigurationTests {
}
@Test
public void exceptionTranslationPostProcessorBeanIsDisabled ( ) {
public void exceptionTranslationPostProcessorCanBeConfiguredToUseJdkProxy ( ) {
this . context = new AnnotationConfigApplicationContext ( ) ;
EnvironmentTestUtils . addEnvironment ( this . context ,
"spring.aop.proxyTargetClass=false" ) ;
this . context . register ( PersistenceExceptionTranslationAutoConfiguration . class ) ;
this . context . refresh ( ) ;
Map < String , PersistenceExceptionTranslationPostProcessor > beans = this . context
. getBeansOfType ( PersistenceExceptionTranslationPostProcessor . class ) ;
assertThat ( beans ) . hasSize ( 1 ) ;
assertThat ( beans . values ( ) . iterator ( ) . next ( ) . isProxyTargetClass ( ) ) . isFalse ( ) ;
}
@Test
public void exceptionTranslationPostProcessorCanBeDisabled ( ) {
this . context = new AnnotationConfigApplicationContext ( ) ;
EnvironmentTestUtils . addEnvironment ( this . context ,
"spring.dao.exceptiontranslation.enabled=false" ) ;