@ -138,20 +138,22 @@ public class ProxyFactoryBeanTests {
private void testDoubleTargetSourceIsRejected ( String name ) {
private void testDoubleTargetSourceIsRejected ( String name ) {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory ( ) ;
DefaultListableBeanFactory bf = new DefaultListableBeanFactory ( ) ;
new XmlBeanDefinitionReader ( bf ) . loadBeanDefinitions ( new ClassPathResource ( DBL_TARGETSOURCE_CONTEXT , CLASS ) ) ;
new XmlBeanDefinitionReader ( bf ) . loadBeanDefinitions ( new ClassPathResource ( DBL_TARGETSOURCE_CONTEXT , CLASS ) ) ;
assertThatExceptionOfType ( BeanCreationException . class ) . as ( "Should not allow TargetSource to be specified in interceptorNames as well as targetSource property" ) . isThrownBy ( ( ) - >
assertThatExceptionOfType ( BeanCreationException . class ) . as ( "Should not allow TargetSource to be specified in interceptorNames as well as targetSource property" )
bf . getBean ( name ) )
. isThrownBy ( ( ) - > bf . getBean ( name ) )
. withCauseInstanceOf ( AopConfigException . class )
. havingCause ( )
. satisfies ( ex - > assertThat ( ex . getCause ( ) . getMessage ( ) ) . contains ( "TargetSource" ) ) ;
. isInstanceOf ( AopConfigException . class )
. withMessageContaining ( "TargetSource" ) ;
}
}
@Test
@Test
public void testTargetSourceNotAtEndOfInterceptorNamesIsRejected ( ) {
public void testTargetSourceNotAtEndOfInterceptorNamesIsRejected ( ) {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory ( ) ;
DefaultListableBeanFactory bf = new DefaultListableBeanFactory ( ) ;
new XmlBeanDefinitionReader ( bf ) . loadBeanDefinitions ( new ClassPathResource ( NOTLAST_TARGETSOURCE_CONTEXT , CLASS ) ) ;
new XmlBeanDefinitionReader ( bf ) . loadBeanDefinitions ( new ClassPathResource ( NOTLAST_TARGETSOURCE_CONTEXT , CLASS ) ) ;
assertThatExceptionOfType ( BeanCreationException . class ) . as ( "TargetSource or non-advised object must be last in interceptorNames" ) . isThrownBy ( ( ) - >
assertThatExceptionOfType ( BeanCreationException . class ) . as ( "TargetSource or non-advised object must be last in interceptorNames" )
bf . getBean ( "targetSourceNotLast" ) )
. isThrownBy ( ( ) - > bf . getBean ( "targetSourceNotLast" ) )
. withCauseInstanceOf ( AopConfigException . class )
. havingCause ( )
. satisfies ( ex - > assertThat ( ex . getCause ( ) . getMessage ( ) ) . contains ( "interceptorNames" ) ) ;
. isInstanceOf ( AopConfigException . class )
. withMessageContaining ( "interceptorNames" ) ;
}
}
@Test
@Test
@ -311,9 +313,9 @@ public class ProxyFactoryBeanTests {
assertThat ( config . getAdvisors ( ) . length ) . as ( "Have correct advisor count" ) . isEqualTo ( 2 ) ;
assertThat ( config . getAdvisors ( ) . length ) . as ( "Have correct advisor count" ) . isEqualTo ( 2 ) ;
ITestBean tb1 = ( ITestBean ) factory . getBean ( "test1" ) ;
ITestBean tb1 = ( ITestBean ) factory . getBean ( "test1" ) ;
assertThatExceptionOfType ( Exception . class ) . isThrownBy (
assertThatExceptionOfType ( Exception . class )
tb1 : : toString )
. isThrownBy ( tb1 : : toString )
. satisfies ( thrown - > assertThat ( thrown ) . isSameAs ( ex ) ) ;
. isSameAs ( ex ) ;
}
}
/ * *
/ * *