Search in sources :

Example 11 with AspectJProxyFactory

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

the class RunAsUserAspectTest method setup.

@Before
public void setup() {
    aspect = new RunAsUserAspect();
    annotatedClass = new AnnotatedClass();
    AspectJProxyFactory proxyFactory = new AspectJProxyFactory(annotatedClass);
    proxyFactory.addAspect(aspect);
    annotatedClass = proxyFactory.getProxy();
    submittingUser = new User("tom", null, null, "Test", "User", null);
    submittingUser.setSystemRole(Role.ROLE_USER);
    adminUser = new User("admin", null, null, "admin", "User", null);
    PreAuthenticatedAuthenticationToken initialAuth = new PreAuthenticatedAuthenticationToken(adminUser, null, Lists.newArrayList(Role.ROLE_ADMIN));
    // Set initial context
    SecurityContext context = SecurityContextHolder.createEmptyContext();
    context.setAuthentication(initialAuth);
    SecurityContextHolder.setContext(context);
}
Also used : User(ca.corefacility.bioinformatics.irida.model.user.User) AspectJProxyFactory(org.springframework.aop.aspectj.annotation.AspectJProxyFactory) SecurityContext(org.springframework.security.core.context.SecurityContext) PreAuthenticatedAuthenticationToken(org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken) Before(org.junit.Before)

Example 12 with AspectJProxyFactory

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

the class ValidateMethodParametersAspectTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    AnnotatedMethodsClass target = new AnnotatedMethodsClass();
    AnnotatedInterfaceImpl interfaceProxyTarget = new AnnotatedInterfaceImpl();
    AspectJProxyFactory proxyFactory = new AspectJProxyFactory(target);
    AspectJProxyFactory interfaceProxyFactory = new AspectJProxyFactory(interfaceProxyTarget);
    aspect = new ValidMethodParametersAspect(validator);
    proxyFactory.addAspect(aspect);
    interfaceProxyFactory.addAspect(aspect);
    proxy = proxyFactory.getProxy();
    interfaceProxy = interfaceProxyFactory.getProxy();
}
Also used : AspectJProxyFactory(org.springframework.aop.aspectj.annotation.AspectJProxyFactory) Before(org.junit.Before)

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