use of org.springframework.web.method.HandlerMethod in project spring-framework by spring-projects.
the class PrintingResultHandler method printHandler.
/**
* Print the handler.
*/
protected void printHandler(Object handler, HandlerInterceptor[] interceptors) throws Exception {
if (handler == null) {
this.printer.printValue("Type", null);
} else {
if (handler instanceof HandlerMethod) {
HandlerMethod handlerMethod = (HandlerMethod) handler;
this.printer.printValue("Type", handlerMethod.getBeanType().getName());
this.printer.printValue("Method", handlerMethod);
} else {
this.printer.printValue("Type", handler.getClass().getName());
}
}
}
use of org.springframework.web.method.HandlerMethod in project spring-framework by spring-projects.
the class StandaloneMockMvcBuilderTests method placeHoldersInRequestMapping.
// SPR-10825
@Test
public void placeHoldersInRequestMapping() throws Exception {
TestStandaloneMockMvcBuilder builder = new TestStandaloneMockMvcBuilder(new PlaceholderController());
builder.addPlaceholderValue("sys.login.ajax", "/foo");
builder.build();
RequestMappingHandlerMapping hm = builder.wac.getBean(RequestMappingHandlerMapping.class);
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo");
HandlerExecutionChain chain = hm.getHandler(request);
assertNotNull(chain);
assertEquals("handleWithPlaceholders", ((HandlerMethod) chain.getHandler()).getMethod().getName());
}
use of org.springframework.web.method.HandlerMethod in project spring-boot by spring-projects.
the class MvcEndpointSecurityInterceptorTests method setup.
@Before
public void setup() throws Exception {
this.roles = Arrays.asList("SUPER_HERO");
this.securityInterceptor = new MvcEndpointSecurityInterceptor(true, this.roles);
this.endpoint = new TestEndpoint("a");
this.mvcEndpoint = new TestMvcEndpoint(this.endpoint);
this.handlerMethod = new HandlerMethod(this.mvcEndpoint, "invoke");
this.servletContext = new MockServletContext();
this.request = new MockHttpServletRequest(this.servletContext);
this.response = mock(HttpServletResponse.class);
}
use of org.springframework.web.method.HandlerMethod in project spring-boot by spring-projects.
the class NoSpringSecurityMvcEndpointSecurityInterceptorTests method setup.
@Before
public void setup() throws Exception {
this.roles = Arrays.asList("SUPER_HERO");
this.securityInterceptor = new MvcEndpointSecurityInterceptor(true, this.roles);
this.endpoint = new TestEndpoint("a");
this.mvcEndpoint = new TestMvcEndpoint(this.endpoint);
this.handlerMethod = new HandlerMethod(this.mvcEndpoint, "invoke");
this.servletContext = new MockServletContext();
this.request = new MockHttpServletRequest(this.servletContext);
this.response = mock(HttpServletResponse.class);
}
use of org.springframework.web.method.HandlerMethod in project spring-boot by spring-projects.
the class EndpointHandlerMappingTests method withoutPrefix.
@Test
public void withoutPrefix() throws Exception {
TestMvcEndpoint endpointA = new TestMvcEndpoint(new TestEndpoint("a"));
TestMvcEndpoint endpointB = new TestMvcEndpoint(new TestEndpoint("b"));
EndpointHandlerMapping mapping = new EndpointHandlerMapping(Arrays.asList(endpointA, endpointB));
mapping.setApplicationContext(this.context);
mapping.afterPropertiesSet();
assertThat(mapping.getHandler(request("GET", "/a")).getHandler()).isEqualTo(new HandlerMethod(endpointA, this.method));
assertThat(mapping.getHandler(request("GET", "/b")).getHandler()).isEqualTo(new HandlerMethod(endpointB, this.method));
assertThat(mapping.getHandler(request("GET", "/c"))).isNull();
}
Aggregations