@ -1,5 +1,5 @@
/ *
/ *
* Copyright 2002 - 2022 the original author or authors .
* Copyright 2002 - 2023 the original author or authors .
*
*
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* Licensed under the Apache License , Version 2 . 0 ( the "License" ) ;
* you may not use this file except in compliance with the License .
* you may not use this file except in compliance with the License .
@ -50,6 +50,7 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
* @author Rob Harrop
* @author Rob Harrop
* @author Rod Johnson
* @author Rod Johnson
* @author Chris Beams
* @author Chris Beams
* @author Yanming Zhou
* /
* /
public class AspectJExpressionPointcutTests {
public class AspectJExpressionPointcutTests {
@ -424,6 +425,19 @@ public class AspectJExpressionPointcutTests {
assertThat ( ajexp . matches ( BeanA . class . getMethod ( "getAge" ) , proxy . getClass ( ) ) ) . isTrue ( ) ;
assertThat ( ajexp . matches ( BeanA . class . getMethod ( "getAge" ) , proxy . getClass ( ) ) ) . isTrue ( ) ;
}
}
@Test
public void testNotAnnotationOnCglibProxyMethod ( ) throws Exception {
String expression = "!@annotation(test.annotation.transaction.Tx)" ;
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut ( ) ;
ajexp . setExpression ( expression ) ;
ProxyFactory factory = new ProxyFactory ( new BeanA ( ) ) ;
factory . setProxyTargetClass ( true ) ;
BeanA proxy = ( BeanA ) factory . getProxy ( ) ;
assertThat ( ajexp . matches ( BeanA . class . getMethod ( "getAge" ) , proxy . getClass ( ) ) ) . isFalse ( ) ;
}
@Test
@Test
public void testAnnotationOnDynamicProxyMethod ( ) throws Exception {
public void testAnnotationOnDynamicProxyMethod ( ) throws Exception {
String expression = "@annotation(test.annotation.transaction.Tx)" ;
String expression = "@annotation(test.annotation.transaction.Tx)" ;
@ -436,6 +450,18 @@ public class AspectJExpressionPointcutTests {
assertThat ( ajexp . matches ( IBeanA . class . getMethod ( "getAge" ) , proxy . getClass ( ) ) ) . isTrue ( ) ;
assertThat ( ajexp . matches ( IBeanA . class . getMethod ( "getAge" ) , proxy . getClass ( ) ) ) . isTrue ( ) ;
}
}
@Test
public void testNotAnnotationOnDynamicProxyMethod ( ) throws Exception {
String expression = "!@annotation(test.annotation.transaction.Tx)" ;
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut ( ) ;
ajexp . setExpression ( expression ) ;
ProxyFactory factory = new ProxyFactory ( new BeanA ( ) ) ;
factory . setProxyTargetClass ( false ) ;
IBeanA proxy = ( IBeanA ) factory . getProxy ( ) ;
assertThat ( ajexp . matches ( IBeanA . class . getMethod ( "getAge" ) , proxy . getClass ( ) ) ) . isFalse ( ) ;
}
@Test
@Test
public void testAnnotationOnMethodWithWildcard ( ) throws Exception {
public void testAnnotationOnMethodWithWildcard ( ) throws Exception {
String expression = "execution(@(test.annotation..*) * *(..))" ;
String expression = "execution(@(test.annotation..*) * *(..))" ;