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");
}
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");
}
Aggregations