use of org.springframework.aop.support.DefaultPointcutAdvisor in project spring-framework by spring-projects.
the class GroovyAspectTests method manualGroovyBeanWithUnconditionalPointcut.
@Test
public void manualGroovyBeanWithUnconditionalPointcut() throws Exception {
TestService target = (TestService) scriptFactory.getScriptedObject(new ResourceScriptSource(new ClassPathResource("GroovyServiceImpl.grv", getClass())));
testAdvice(new DefaultPointcutAdvisor(logAdvice), logAdvice, target, "GroovyServiceImpl");
}
use of org.springframework.aop.support.DefaultPointcutAdvisor in project spring-framework by spring-projects.
the class GroovyAspectTests method manualGroovyBeanWithDynamicPointcutProxyTargetClass.
@Test
public void manualGroovyBeanWithDynamicPointcutProxyTargetClass() throws Exception {
TestService target = (TestService) scriptFactory.getScriptedObject(new ResourceScriptSource(new ClassPathResource("GroovyServiceImpl.grv", getClass())));
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
pointcut.setExpression(String.format("@within(%s.Log)", ClassUtils.getPackageName(getClass())));
testAdvice(new DefaultPointcutAdvisor(pointcut, logAdvice), logAdvice, target, "GroovyServiceImpl", true);
}
use of org.springframework.aop.support.DefaultPointcutAdvisor in project spring-framework by spring-projects.
the class GroovyAspectTests method manualGroovyBeanWithDynamicPointcut.
@Test
public void manualGroovyBeanWithDynamicPointcut() throws Exception {
TestService target = (TestService) scriptFactory.getScriptedObject(new ResourceScriptSource(new ClassPathResource("GroovyServiceImpl.grv", getClass())));
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
pointcut.setExpression(String.format("@within(%s.Log)", ClassUtils.getPackageName(getClass())));
testAdvice(new DefaultPointcutAdvisor(pointcut, logAdvice), logAdvice, target, "GroovyServiceImpl", false);
}
use of org.springframework.aop.support.DefaultPointcutAdvisor in project spring-framework by spring-projects.
the class ServletAnnotationControllerHandlerMethodTests method requestMappingInterfaceWithProxy.
@PathPatternsParameterizedTest
void requestMappingInterfaceWithProxy(boolean usePathPatterns) throws Exception {
initDispatcherServlet(IMyControllerImpl.class, usePathPatterns, wac -> {
DefaultAdvisorAutoProxyCreator autoProxyCreator = new DefaultAdvisorAutoProxyCreator();
autoProxyCreator.setBeanFactory(wac.getBeanFactory());
wac.getBeanFactory().addBeanPostProcessor(autoProxyCreator);
wac.getBeanFactory().registerSingleton("advisor", new DefaultPointcutAdvisor(new SimpleTraceInterceptor()));
});
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/handle");
MockHttpServletResponse response = new MockHttpServletResponse();
getServlet().service(request, response);
assertThat(response.getContentAsString()).isEqualTo("handle null");
request = new MockHttpServletRequest("GET", "/handle");
request.addParameter("p", "value");
response = new MockHttpServletResponse();
getServlet().service(request, response);
assertThat(response.getContentAsString()).isEqualTo("handle value");
}
use of org.springframework.aop.support.DefaultPointcutAdvisor in project spring-framework by spring-projects.
the class ServletAnnotationControllerHandlerMethodTests method proxiedFormController.
@PathPatternsParameterizedTest
void proxiedFormController(boolean usePathPatterns) throws Exception {
initDispatcherServlet(MyFormController.class, usePathPatterns, wac -> {
wac.registerBeanDefinition("viewResolver", new RootBeanDefinition(TestViewResolver.class));
DefaultAdvisorAutoProxyCreator autoProxyCreator = new DefaultAdvisorAutoProxyCreator();
autoProxyCreator.setBeanFactory(wac.getBeanFactory());
wac.getBeanFactory().addBeanPostProcessor(autoProxyCreator);
wac.getBeanFactory().registerSingleton("advisor", new DefaultPointcutAdvisor(new SimpleTraceInterceptor()));
});
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/myPath.do");
request.addParameter("name", "name1");
request.addParameter("age", "value2");
MockHttpServletResponse response = new MockHttpServletResponse();
getServlet().service(request, response);
assertThat(response.getContentAsString()).isEqualTo("myView-name1-typeMismatch-tb1-myValue");
}
Aggregations