(点击上方公众号,可快速关注)来源:chanjarster,github.com/chanjarster/spring-test-examplesSpring提供了一套AOP工具,但是当你把各种Aspect写完之后,如何确定这些Aspect都正确的应用到目标Bean上了呢?本章将举例说明如何对Spring AOP做测试。首先先来看我们事先定义的Bean以及Aspect。FooServiceImpl:@Componentpublic class FooServiceImpl implements FooService { private int count; @Override public int incrementAndGet() { count++; return count; } }FooAspect:@Component@Aspectpublic class FooAspect { @Pointcut("execution(* me.chanjar.aop.service.FooServiceImpl.incrementAndGet())") public void pointcut() { } @Around("pointcut()") public int changeIncrementAndGet(ProceedingJoinPoint pjp) { return 0; } }可以看到FooAspect会修改FooServiceImpl.incrementAndG
………………………………