Search in sources :

Example 1 with ExceptionThrowingAspect

use of cn.taketoday.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactoryTests.ExceptionThrowingAspect in project today-framework by TAKETODAY.

the class AspectJPointcutAdvisorTests method testSingleton.

@Test
public void testSingleton() throws SecurityException, NoSuchMethodException {
    AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
    ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);
    InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(ajexp, TestBean.class.getMethod("getAge"), af, new SingletonMetadataAwareAspectInstanceFactory(new ExceptionThrowingAspect(null), "someBean"), 1, "someBean");
    assertThat(ajpa.getAspectMetadata().getPerClausePointcut()).isSameAs(Pointcut.TRUE);
    assertThat(ajpa.isPerInstance()).isFalse();
}
Also used : TestBean(cn.taketoday.beans.testfixture.beans.TestBean) AspectJExpressionPointcut(cn.taketoday.aop.aspectj.AspectJExpressionPointcut) ExceptionThrowingAspect(cn.taketoday.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactoryTests.ExceptionThrowingAspect) Test(org.junit.jupiter.api.Test)

Example 2 with ExceptionThrowingAspect

use of cn.taketoday.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactoryTests.ExceptionThrowingAspect in project today-infrastructure by TAKETODAY.

the class AspectJPointcutAdvisorTests method testSingleton.

@Test
public void testSingleton() throws SecurityException, NoSuchMethodException {
    AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
    ajexp.setExpression(AspectJExpressionPointcutTests.MATCH_ALL_METHODS);
    InstantiationModelAwarePointcutAdvisorImpl ajpa = new InstantiationModelAwarePointcutAdvisorImpl(ajexp, TestBean.class.getMethod("getAge"), af, new SingletonMetadataAwareAspectInstanceFactory(new ExceptionThrowingAspect(null), "someBean"), 1, "someBean");
    assertThat(ajpa.getAspectMetadata().getPerClausePointcut()).isSameAs(Pointcut.TRUE);
    assertThat(ajpa.isPerInstance()).isFalse();
}
Also used : TestBean(cn.taketoday.beans.testfixture.beans.TestBean) AspectJExpressionPointcut(cn.taketoday.aop.aspectj.AspectJExpressionPointcut) ExceptionThrowingAspect(cn.taketoday.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactoryTests.ExceptionThrowingAspect) Test(org.junit.jupiter.api.Test)

Aggregations

AspectJExpressionPointcut (cn.taketoday.aop.aspectj.AspectJExpressionPointcut)2 ExceptionThrowingAspect (cn.taketoday.aop.aspectj.annotation.ReflectiveAspectJAdvisorFactoryTests.ExceptionThrowingAspect)2 TestBean (cn.taketoday.beans.testfixture.beans.TestBean)2 Test (org.junit.jupiter.api.Test)2