Search in sources :

Example 11 with MethodBeforeAdvice

use of cn.taketoday.aop.MethodBeforeAdvice in project today-framework by TAKETODAY.

the class AbstractAopProxyTests method testProxyConfigString.

/**
 * Check that the string is informative.
 */
@Test
public void testProxyConfigString() {
    TestBean target = new TestBean();
    ProxyFactory pc = new ProxyFactory(target);
    pc.setInterfaces(ITestBean.class);
    pc.addAdvice(new NopInterceptor());
    MethodBeforeAdvice mba = new CountingBeforeAdvice();
    Advisor advisor = new DefaultPointcutAdvisor(new NameMatchMethodPointcut(), mba);
    pc.addAdvisor(advisor);
    ITestBean proxied = (ITestBean) createProxy(pc);
    String proxyConfigString = ((Advised) proxied).toProxyConfigString();
    assertThat(proxyConfigString.contains(advisor.toString())).isTrue();
    assertThat(proxyConfigString.contains("1 interface")).isTrue();
}
Also used : ITestBean(cn.taketoday.beans.testfixture.beans.ITestBean) NopInterceptor(cn.taketoday.aop.NopInterceptor) SerializableNopInterceptor(cn.taketoday.aop.SerializableNopInterceptor) ITestBean(cn.taketoday.beans.testfixture.beans.ITestBean) TestBean(cn.taketoday.beans.testfixture.beans.TestBean) ProxyFactory(cn.taketoday.aop.framework.ProxyFactory) Advised(cn.taketoday.aop.framework.Advised) MethodBeforeAdvice(cn.taketoday.aop.MethodBeforeAdvice) DefaultPointcutAdvisor(cn.taketoday.aop.support.DefaultPointcutAdvisor) DefaultIntroductionAdvisor(cn.taketoday.aop.support.DefaultIntroductionAdvisor) Advisor(cn.taketoday.aop.Advisor) LockMixinAdvisor(cn.taketoday.aop.mixin.LockMixinAdvisor) StaticMethodMatcherPointcutAdvisor(cn.taketoday.aop.support.StaticMethodMatcherPointcutAdvisor) DefaultPointcutAdvisor(cn.taketoday.aop.support.DefaultPointcutAdvisor) NameMatchMethodPointcut(cn.taketoday.aop.support.NameMatchMethodPointcut) Test(org.junit.jupiter.api.Test)

Aggregations

MethodBeforeAdvice (cn.taketoday.aop.MethodBeforeAdvice)11 ITestBean (cn.taketoday.beans.testfixture.beans.ITestBean)11 TestBean (cn.taketoday.beans.testfixture.beans.TestBean)11 Test (org.junit.jupiter.api.Test)11 ProxyFactory (cn.taketoday.aop.framework.ProxyFactory)9 AopContext (cn.taketoday.aop.framework.AopContext)8 ExposeInvocationInterceptor (cn.taketoday.aop.interceptor.ExposeInvocationInterceptor)8 AopUtils (cn.taketoday.aop.support.AopUtils)8 IOException (java.io.IOException)8 Arrays (java.util.Arrays)8 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)8 JoinPoint (org.aspectj.lang.JoinPoint)8 StaticPart (org.aspectj.lang.JoinPoint.StaticPart)8 ProceedingJoinPoint (org.aspectj.lang.ProceedingJoinPoint)8 MethodSignature (org.aspectj.lang.reflect.MethodSignature)8 SourceLocation (org.aspectj.lang.reflect.SourceLocation)8 Factory (org.aspectj.runtime.reflect.Factory)8 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)8 Assertions.assertThatExceptionOfType (org.assertj.core.api.Assertions.assertThatExceptionOfType)8 Assertions.assertThatIllegalStateException (org.assertj.core.api.Assertions.assertThatIllegalStateException)8