diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests.java index 5959ec8f46d2..56dd7d477e40 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests.java @@ -40,6 +40,7 @@ * * @author Ramnivas Laddad * @author Chris Beams + * @author Yanming Zhou */ class AfterReturningGenericTypeMatchingTests { @@ -107,77 +108,74 @@ void returnTypeLowerBoundMatching() { assertThat(counterAspect.getTestBeanInvocationsCount).isEqualTo(0); } -} - + static class GenericReturnTypeVariationClass { -class GenericReturnTypeVariationClass { + public Collection getStrings() { + return new ArrayList<>(); + } - public Collection getStrings() { - return new ArrayList<>(); - } + public Collection getIntegers() { + return new ArrayList<>(); + } - public Collection getIntegers() { - return new ArrayList<>(); - } + public Collection getTestBeans() { + return new ArrayList<>(); + } - public Collection getTestBeans() { - return new ArrayList<>(); + public Collection getEmployees() { + return new ArrayList<>(); + } } - public Collection getEmployees() { - return new ArrayList<>(); - } -} - + @Aspect + static class CounterAspect { -@Aspect -class CounterAspect { + int getRawsInvocationsCount; - int getRawsInvocationsCount; + int getStringsInvocationsCount; - int getStringsInvocationsCount; + int getIntegersInvocationsCount; - int getIntegersInvocationsCount; + int getNumbersInvocationsCount; - int getNumbersInvocationsCount; + int getTestBeanInvocationsCount; - int getTestBeanInvocationsCount; + @Pointcut("execution(* org.springframework.aop.aspectj.generic.AfterReturningGenericTypeMatchingTests.GenericReturnTypeVariationClass.*(..))") + public void anyTestMethod() { + } - @Pointcut("execution(* org.springframework.aop.aspectj.generic.GenericReturnTypeVariationClass.*(..))") - public void anyTestMethod() { - } + @AfterReturning(pointcut = "anyTestMethod()", returning = "ret") + public void incrementGetRawsInvocationsCount(Collection ret) { + getRawsInvocationsCount++; + } - @AfterReturning(pointcut = "anyTestMethod()", returning = "ret") - public void incrementGetRawsInvocationsCount(Collection ret) { - getRawsInvocationsCount++; - } + @AfterReturning(pointcut = "anyTestMethod()", returning = "ret") + public void incrementGetStringsInvocationsCount(Collection ret) { + getStringsInvocationsCount++; + } - @AfterReturning(pointcut = "anyTestMethod()", returning = "ret") - public void incrementGetStringsInvocationsCount(Collection ret) { - getStringsInvocationsCount++; - } + @AfterReturning(pointcut = "anyTestMethod()", returning = "ret") + public void incrementGetIntegersInvocationsCount(Collection ret) { + getIntegersInvocationsCount++; + } - @AfterReturning(pointcut = "anyTestMethod()", returning = "ret") - public void incrementGetIntegersInvocationsCount(Collection ret) { - getIntegersInvocationsCount++; - } + @AfterReturning(pointcut = "anyTestMethod()", returning = "ret") + public void incrementGetNumbersInvocationsCount(Collection ret) { + getNumbersInvocationsCount++; + } - @AfterReturning(pointcut = "anyTestMethod()", returning = "ret") - public void incrementGetNumbersInvocationsCount(Collection ret) { - getNumbersInvocationsCount++; - } + @AfterReturning(pointcut = "anyTestMethod()", returning = "ret") + public void incrementTestBeanInvocationsCount(Collection ret) { + getTestBeanInvocationsCount++; + } - @AfterReturning(pointcut = "anyTestMethod()", returning = "ret") - public void incrementTestBeanInvocationsCount(Collection ret) { - getTestBeanInvocationsCount++; + public void reset() { + getRawsInvocationsCount = 0; + getStringsInvocationsCount = 0; + getIntegersInvocationsCount = 0; + getNumbersInvocationsCount = 0; + getTestBeanInvocationsCount = 0; + } } - public void reset() { - getRawsInvocationsCount = 0; - getStringsInvocationsCount = 0; - getIntegersInvocationsCount = 0; - getNumbersInvocationsCount = 0; - getTestBeanInvocationsCount = 0; - } } - diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/generic/GenericBridgeMethodMatchingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/generic/GenericBridgeMethodMatchingTests.java index 513659388069..6a1f2389a680 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/generic/GenericBridgeMethodMatchingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/generic/GenericBridgeMethodMatchingTests.java @@ -40,6 +40,7 @@ * * @author Ramnivas Laddad * @author Chris Beams + * @author Yanming Zhou */ class GenericBridgeMethodMatchingTests { @@ -79,41 +80,39 @@ void genericBaseInterfaceMethodThroughInterface() { assertThat(counterAspect.count).isEqualTo(1); } -} + interface BaseInterface { + void genericBaseInterfaceMethod(T t); + } -interface BaseInterface { - void genericBaseInterfaceMethod(T t); -} + interface DerivedInterface extends BaseInterface { + void genericDerivedInterfaceMethod(T t); + } -interface DerivedInterface extends BaseInterface { - void genericDerivedInterfaceMethod(T t); -} + static class DerivedStringParameterizedClass implements DerivedInterface { + @Override + public void genericDerivedInterfaceMethod(String t) { + } -class DerivedStringParameterizedClass implements DerivedInterface { - - @Override - public void genericDerivedInterfaceMethod(String t) { + @Override + public void genericBaseInterfaceMethod(String t) { + } } - @Override - public void genericBaseInterfaceMethod(String t) { - } -} + @Aspect + static class GenericCounterAspect { -@Aspect -class GenericCounterAspect { + public int count; - public int count; + @Before("execution(* *..BaseInterface+.*(..))") + public void increment() { + count++; + } - @Before("execution(* *..BaseInterface+.*(..))") - public void increment() { - count++; } } - diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests-context.xml index 5c1cf831f5dd..51c00349797a 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests-context.xml @@ -7,8 +7,8 @@ - + - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/generic/GenericBridgeMethodMatchingClassProxyTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/generic/GenericBridgeMethodMatchingClassProxyTests-context.xml index c9ddeb3b6cd2..48ef39291e6e 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/generic/GenericBridgeMethodMatchingClassProxyTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/generic/GenericBridgeMethodMatchingClassProxyTests-context.xml @@ -7,8 +7,8 @@ - + - + diff --git a/spring-context/src/test/resources/org/springframework/aop/aspectj/generic/GenericBridgeMethodMatchingTests-context.xml b/spring-context/src/test/resources/org/springframework/aop/aspectj/generic/GenericBridgeMethodMatchingTests-context.xml index 46f8ba82bea0..bb1fe87759ef 100644 --- a/spring-context/src/test/resources/org/springframework/aop/aspectj/generic/GenericBridgeMethodMatchingTests-context.xml +++ b/spring-context/src/test/resources/org/springframework/aop/aspectj/generic/GenericBridgeMethodMatchingTests-context.xml @@ -7,8 +7,8 @@ - + - +