Search in sources :

Example 1 with StaticMethodMatcherPointcut

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

the class AopUtilsTests method testPointcutAppliesToOneMethodOnObject.

@Test
public void testPointcutAppliesToOneMethodOnObject() {
    class TestPointcut extends StaticMethodMatcherPointcut {

        @Override
        public boolean matches(Method method, Class<?> clazz) {
            return method.getName().equals("hashCode");
        }
    }
    Pointcut pc = new TestPointcut();
    // will return true if we're not proxying interfaces
    assertThat(AopUtils.canApply(pc, Object.class)).isTrue();
}
Also used : Pointcut(cn.taketoday.aop.Pointcut) StaticMethodMatcherPointcut(cn.taketoday.aop.support.StaticMethodMatcherPointcut) StaticMethodMatcherPointcut(cn.taketoday.aop.support.StaticMethodMatcherPointcut) Method(java.lang.reflect.Method) Test(org.junit.jupiter.api.Test)

Example 2 with StaticMethodMatcherPointcut

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

the class AopUtilsTests method testPointcutCanNeverApply.

@Test
public void testPointcutCanNeverApply() {
    class TestPointcut extends StaticMethodMatcherPointcut {

        @Override
        public boolean matches(Method method, Class<?> clazzy) {
            return false;
        }
    }
    Pointcut no = new TestPointcut();
    assertThat(AopUtils.canApply(no, Object.class)).isFalse();
}
Also used : Pointcut(cn.taketoday.aop.Pointcut) StaticMethodMatcherPointcut(cn.taketoday.aop.support.StaticMethodMatcherPointcut) StaticMethodMatcherPointcut(cn.taketoday.aop.support.StaticMethodMatcherPointcut) Method(java.lang.reflect.Method) Test(org.junit.jupiter.api.Test)

Aggregations

Pointcut (cn.taketoday.aop.Pointcut)2 StaticMethodMatcherPointcut (cn.taketoday.aop.support.StaticMethodMatcherPointcut)2 Method (java.lang.reflect.Method)2 Test (org.junit.jupiter.api.Test)2