@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
/ *
* Copyright 2002 - 2017 the original author or authors .
* Copyright 2002 - 2018 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 .
@ -13,6 +13,7 @@
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License .
* /
package org.springframework.aop.aspectj ;
import java.lang.reflect.Method ;
@ -34,47 +35,6 @@ import static org.junit.Assert.*;
@@ -34,47 +35,6 @@ import static org.junit.Assert.*;
* /
public class AspectJAdviceParameterNameDiscovererTests {
// methods to discover parameter names for
public void noArgs ( ) {
}
public void tjp ( JoinPoint jp ) {
}
public void tjpsp ( JoinPoint . StaticPart tjpsp ) {
}
public void twoJoinPoints ( JoinPoint jp1 , JoinPoint jp2 ) {
}
public void oneThrowable ( Exception ex ) {
}
public void jpAndOneThrowable ( JoinPoint jp , Exception ex ) {
}
public void jpAndTwoThrowables ( JoinPoint jp , Exception ex , Error err ) {
}
public void oneObject ( Object x ) {
}
public void twoObjects ( Object x , Object y ) {
}
public void onePrimitive ( int x ) {
}
public void oneObjectOnePrimitive ( Object x , int y ) {
}
public void oneThrowableOnePrimitive ( Throwable x , int y ) {
}
public void theBigOne ( JoinPoint jp , Throwable x , int y , Object foo ) {
}
@Test
public void testNoArgs ( ) {
assertParameterNames ( getMethod ( "noArgs" ) , "execution(* *(..))" , new String [ 0 ] ) ;
@ -221,22 +181,26 @@ public class AspectJAdviceParameterNameDiscovererTests {
@@ -221,22 +181,26 @@ public class AspectJAdviceParameterNameDiscovererTests {
@Test
public void testThisAndPrimitive ( ) {
assertParameterNames ( getMethod ( "oneObjectOnePrimitive" ) , "args(count) && this(obj)" , new String [ ] { "obj" , "count" } ) ;
assertParameterNames ( getMethod ( "oneObjectOnePrimitive" ) , "args(count) && this(obj)" ,
new String [ ] { "obj" , "count" } ) ;
}
@Test
public void testTargetAndPrimitive ( ) {
assertParameterNames ( getMethod ( "oneObjectOnePrimitive" ) , "args(count) && target(obj)" , new String [ ] { "obj" , "count" } ) ;
assertParameterNames ( getMethod ( "oneObjectOnePrimitive" ) , "args(count) && target(obj)" ,
new String [ ] { "obj" , "count" } ) ;
}
@Test
public void testThrowingAndPrimitive ( ) {
assertParameterNames ( getMethod ( "oneThrowableOnePrimitive" ) , "args(count)" , null , "ex" , new String [ ] { "ex" , "count" } ) ;
assertParameterNames ( getMethod ( "oneThrowableOnePrimitive" ) , "args(count)" , null , "ex" ,
new String [ ] { "ex" , "count" } ) ;
}
@Test
public void testAllTogetherNow ( ) {
assertParameterNames ( getMethod ( "theBigOne" ) , "this(foo) && args(x)" , null , "ex" , new String [ ] { "thisJoinPoint" , "ex" , "x" , "foo" } ) ;
assertParameterNames ( getMethod ( "theBigOne" ) , "this(foo) && args(x)" , null , "ex" ,
new String [ ] { "thisJoinPoint" , "ex" , "x" , "foo" } ) ;
}
@Test
@ -253,8 +217,8 @@ public class AspectJAdviceParameterNameDiscovererTests {
@@ -253,8 +217,8 @@ public class AspectJAdviceParameterNameDiscovererTests {
protected Method getMethod ( String name ) {
// a ssumes no overloading of test methods...
Method [ ] candidates = this . getClass ( ) . getMethods ( ) ;
// A ssumes no overloading of test methods...
Method [ ] candidates = getClass ( ) . getMethods ( ) ;
for ( Method candidate : candidates ) {
if ( candidate . getName ( ) . equals ( name ) ) {
return candidate ;
@ -268,8 +232,8 @@ public class AspectJAdviceParameterNameDiscovererTests {
@@ -268,8 +232,8 @@ public class AspectJAdviceParameterNameDiscovererTests {
assertParameterNames ( method , pointcut , null , null , parameterNames ) ;
}
protected void assertParameterNames ( Method method , String pointcut , String returning , String throwing ,
String [ ] parameterNames ) {
protected void assertParameterNames (
Method method , String pointcut , String returning , String throwing , String [ ] parameterNames ) {
assertEquals ( "bad test specification, must have same number of parameter names as method arguments" ,
method . getParameterCount ( ) , parameterNames . length ) ;
@ -300,8 +264,8 @@ public class AspectJAdviceParameterNameDiscovererTests {
@@ -300,8 +264,8 @@ public class AspectJAdviceParameterNameDiscovererTests {
assertException ( method , pointcut , null , null , exceptionType , message ) ;
}
protected void assertException ( Method method , String pointcut , String returning , String throwing ,
Class < ? > exceptionType , String message ) {
protected void assertException (
Method method , String pointcut , String returning , String throwing , Class < ? > exceptionType , String message ) {
AspectJAdviceParameterNameDiscoverer discoverer = new AspectJAdviceParameterNameDiscoverer ( pointcut ) ;
discoverer . setRaiseExceptions ( true ) ;
@ -333,4 +297,46 @@ public class AspectJAdviceParameterNameDiscovererTests {
@@ -333,4 +297,46 @@ public class AspectJAdviceParameterNameDiscovererTests {
return sb . toString ( ) ;
}
// Methods to discover parameter names for
public void noArgs ( ) {
}
public void tjp ( JoinPoint jp ) {
}
public void tjpsp ( JoinPoint . StaticPart tjpsp ) {
}
public void twoJoinPoints ( JoinPoint jp1 , JoinPoint jp2 ) {
}
public void oneThrowable ( Exception ex ) {
}
public void jpAndOneThrowable ( JoinPoint jp , Exception ex ) {
}
public void jpAndTwoThrowables ( JoinPoint jp , Exception ex , Error err ) {
}
public void oneObject ( Object x ) {
}
public void twoObjects ( Object x , Object y ) {
}
public void onePrimitive ( int x ) {
}
public void oneObjectOnePrimitive ( Object x , int y ) {
}
public void oneThrowableOnePrimitive ( Throwable x , int y ) {
}
public void theBigOne ( JoinPoint jp , Throwable x , int y , Object foo ) {
}
}