Test status quo for invocation order of all advice types

Prior to this commit we did not have tests in place to verify the status
quo for the invocation order of all advice types when declared within
a single aspect, either via the <aop:aspect> XML namespace or AspectJ
auto-proxy support.

This commit introduces such tests that demonstrate where such ordering
is broken or suboptimal.

The only test for which the advice invocation order is correct or at
least as expected is the afterAdviceTypes() test method in
ReflectiveAspectJAdvisorFactoryTests, where an AOP proxy is hand crafted
using ReflectiveAspectJAdvisorFactory without the use of Spring's
AspectJPrecedenceComparator.

See gh-25186
This commit is contained in:
Sam Brannen
2020-06-05 15:22:27 +02:00
parent 04c8de4e50
commit fbeecf3bf8
7 changed files with 124 additions and 44 deletions

View File

@@ -7,14 +7,16 @@
<bean id="echo" class="org.springframework.aop.config.AopNamespaceHandlerAdviceOrderIntegrationTests$Echo"/>
<bean id="echoAspect" class="org.springframework.aop.config.AopNamespaceHandlerAdviceOrderIntegrationTests$EchoAspect" />
<bean id="invocationTrackingAspect" class="org.springframework.aop.config.AopNamespaceHandlerAdviceOrderIntegrationTests$InvocationTrackingAspect" />
<aop:config>
<aop:aspect id="echoAdvice" ref="echoAspect">
<aop:aspect id="echoAdvice" ref="invocationTrackingAspect">
<aop:pointcut id="echoMethod" expression="execution(* echo(*))" />
<aop:around method="around" pointcut-ref="echoMethod" />
<aop:before method="before" pointcut-ref="echoMethod" />
<aop:after method="after" pointcut-ref="echoMethod" />
<aop:after-throwing method="failed" pointcut-ref="echoMethod" />
<aop:after-returning method="succeeded" pointcut-ref="echoMethod" />
<aop:after-throwing method="afterThrowing" pointcut-ref="echoMethod" />
<aop:after-returning method="afterReturning" pointcut-ref="echoMethod" />
</aop:aspect>
</aop:config>

View File

@@ -7,13 +7,15 @@
<bean id="echo" class="org.springframework.aop.config.AopNamespaceHandlerAdviceOrderIntegrationTests$Echo"/>
<bean id="echoAspect" class="org.springframework.aop.config.AopNamespaceHandlerAdviceOrderIntegrationTests$EchoAspect" />
<bean id="invocationTrackingAspect" class="org.springframework.aop.config.AopNamespaceHandlerAdviceOrderIntegrationTests$InvocationTrackingAspect" />
<aop:config>
<aop:aspect id="echoAdvice" ref="echoAspect">
<aop:aspect id="echoAdvice" ref="invocationTrackingAspect">
<aop:pointcut id="echoMethod" expression="execution(* echo(*))" />
<aop:after-returning method="succeeded" pointcut-ref="echoMethod" />
<aop:after-throwing method="failed" pointcut-ref="echoMethod" />
<aop:around method="around" pointcut-ref="echoMethod" />
<aop:before method="before" pointcut-ref="echoMethod" />
<aop:after-throwing method="afterThrowing" pointcut-ref="echoMethod" />
<aop:after-returning method="afterReturning" pointcut-ref="echoMethod" />
<aop:after method="after" pointcut-ref="echoMethod" />
</aop:aspect>
</aop:config>