Example usage for org.springframework.aop.framework DefaultAopProxyFactory createAopProxy

List of usage examples for org.springframework.aop.framework DefaultAopProxyFactory createAopProxy

Introduction

In this page you can find the example usage for org.springframework.aop.framework DefaultAopProxyFactory createAopProxy.

Prototype

@Override
    public AopProxy createAopProxy(AdvisedSupport config) throws AopConfigException 

Source Link

Usage

From source file:com.yeahmobi.yunit.testutils.MustNotSwallowSpringJUnit4ClassRunner.java

@Override
public void run(RunNotifier notifier) {
    AdvisedSupport config = new AdvisedSupport();
    config.setTarget(notifier);/*from ww  w . jav a  2  s. c  o  m*/
    config.addAdvice(new org.aopalliance.intercept.MethodInterceptor() {
        public Object invoke(MethodInvocation invocation) throws Throwable {
            if ("fireTestFailure".equals(invocation.getMethod().getName())) {
                Failure failure = (Failure) invocation.getArguments()[0];
                if (failure.getException() instanceof NotSwallowedException) {
                    // We expect this
                    return null;
                }
            }
            return invocation.proceed();
        }
    });
    DefaultAopProxyFactory aopProxyFactory = new DefaultAopProxyFactory();
    RunNotifier runNotifierProxy = (RunNotifier) aopProxyFactory.createAopProxy(config).getProxy();
    super.run(runNotifierProxy);
}