Search in sources :

Example 1 with AspectJProxyFactory

use of org.springframework.aop.aspectj.annotation.AspectJProxyFactory in project java-chassis by ServiceComb.

the class TestBeanUtils method test.

@Test
public void test() {
    Intf target = new Impl();
    AspectJProxyFactory factory = new AspectJProxyFactory(target);
    MyAspect aspect = new MyAspect();
    factory.addAspect(aspect);
    Intf proxy = factory.getProxy();
    Assert.assertEquals(Impl.class, BeanUtils.getImplClassFromBean(proxy));
    Assert.assertEquals(Impl.class, BeanUtils.getImplClassFromBean(new Impl()));
}
Also used : AspectJProxyFactory(org.springframework.aop.aspectj.annotation.AspectJProxyFactory) Test(org.junit.Test)

Example 2 with AspectJProxyFactory

use of org.springframework.aop.aspectj.annotation.AspectJProxyFactory in project incubator-servicecomb-java-chassis by apache.

the class TestBeanUtils method test.

@Test
public void test() {
    Intf target = new Impl();
    AspectJProxyFactory factory = new AspectJProxyFactory(target);
    MyAspect aspect = new MyAspect();
    factory.addAspect(aspect);
    Intf proxy = factory.getProxy();
    Assert.assertEquals(Impl.class, BeanUtils.getImplClassFromBean(proxy));
    Assert.assertEquals(Impl.class, BeanUtils.getImplClassFromBean(new Impl()));
}
Also used : AspectJProxyFactory(org.springframework.aop.aspectj.annotation.AspectJProxyFactory) Test(org.junit.Test)

Example 3 with AspectJProxyFactory

use of org.springframework.aop.aspectj.annotation.AspectJProxyFactory in project irida by phac-nml.

the class ProjectEventAspectTest method setup.

@Before
public void setup() {
    eventHandler = mock(ProjectEventHandler.class);
    projectEventAspect = new ProjectEventAspect(eventHandler);
    annotatedClass = new AnnotatedClass();
    AspectJProxyFactory proxyFactory = new AspectJProxyFactory(annotatedClass);
    proxyFactory.addAspect(projectEventAspect);
    annotatedClass = proxyFactory.getProxy();
}
Also used : AspectJProxyFactory(org.springframework.aop.aspectj.annotation.AspectJProxyFactory) Before(org.junit.Before)

Example 4 with AspectJProxyFactory

use of org.springframework.aop.aspectj.annotation.AspectJProxyFactory in project micrometer by micrometer-metrics.

the class TimedAspectTest method timeMethod.

@Test
void timeMethod() {
    MeterRegistry registry = new SimpleMeterRegistry();
    AspectJProxyFactory pf = new AspectJProxyFactory(new TimedService());
    pf.addAspect(new TimedAspect(registry));
    TimedService service = pf.getProxy();
    service.call();
    assertThat(registry.get("call").tag("class", "io.micrometer.core.aop.TimedAspectTest$TimedService").tag("method", "call").tag("extra", "tag").timer().count()).isEqualTo(1);
}
Also used : AspectJProxyFactory(org.springframework.aop.aspectj.annotation.AspectJProxyFactory) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Test(org.junit.jupiter.api.Test)

Example 5 with AspectJProxyFactory

use of org.springframework.aop.aspectj.annotation.AspectJProxyFactory in project commons by craftercms.

the class HasPermissionAnnotationHandlerTest method createTestService.

private void createTestService() throws PermissionException {
    AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new MockSecuredServiceImpl());
    proxyFactory.addAspect(annotationHandler);
    service = proxyFactory.getProxy();
}
Also used : AspectJProxyFactory(org.springframework.aop.aspectj.annotation.AspectJProxyFactory)

Aggregations

AspectJProxyFactory (org.springframework.aop.aspectj.annotation.AspectJProxyFactory)12 Test (org.junit.Test)5 Before (org.junit.Before)3 Test (org.junit.jupiter.api.Test)2 User (ca.corefacility.bioinformatics.irida.model.user.User)1 MeterRegistry (io.micrometer.core.instrument.MeterRegistry)1 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)1 Method (java.lang.reflect.Method)1 Advice (org.aopalliance.aop.Advice)1 AspectJAroundAdvice (org.springframework.aop.aspectj.AspectJAroundAdvice)1 SingletonAspectInstanceFactory (org.springframework.aop.aspectj.SingletonAspectInstanceFactory)1 Advised (org.springframework.aop.framework.Advised)1 ITestBean (org.springframework.beans.testfixture.beans.ITestBean)1 TestBean (org.springframework.beans.testfixture.beans.TestBean)1 SecurityContext (org.springframework.security.core.context.SecurityContext)1 PreAuthenticatedAuthenticationToken (org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken)1