use of org.springframework.web.servlet.HandlerExecutionChain in project spring-framework by spring-projects.
the class PathMatchingUrlHandlerMappingTests method defaultMapping.
@Test
public void defaultMapping() throws Exception {
Object bean = wac.getBean("starController");
MockHttpServletRequest req = new MockHttpServletRequest("GET", "/goggog.html");
HandlerExecutionChain hec = getHandler(req);
assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);
}
use of org.springframework.web.servlet.HandlerExecutionChain in project spring-framework by spring-projects.
the class PathMatchingUrlHandlerMappingTests method requestsWithHandlers.
@Test
public void requestsWithHandlers() throws Exception {
Object bean = wac.getBean("mainController");
MockHttpServletRequest req = new MockHttpServletRequest("GET", "/welcome.html");
HandlerExecutionChain hec = getHandler(req);
assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);
req = new MockHttpServletRequest("GET", "/show.html");
hec = getHandler(req);
assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);
req = new MockHttpServletRequest("GET", "/bookseats.html");
hec = getHandler(req);
assertTrue("Handler is correct bean", hec != null && hec.getHandler() == bean);
}
use of org.springframework.web.servlet.HandlerExecutionChain in project spring-framework by spring-projects.
the class RequestMappingInfoHandlerMappingTests method getHandler.
private HandlerMethod getHandler(MockHttpServletRequest request) throws Exception {
HandlerExecutionChain chain = this.handlerMapping.getHandler(request);
assertNotNull(chain);
return (HandlerMethod) chain.getHandler();
}
use of org.springframework.web.servlet.HandlerExecutionChain in project spring-framework by spring-projects.
the class CrossOriginTests method customOriginDefinedViaValueAttribute.
@Test
public void customOriginDefinedViaValueAttribute() throws Exception {
this.handlerMapping.registerHandler(new MethodLevelController());
this.request.setRequestURI("/customOrigin");
HandlerExecutionChain chain = this.handlerMapping.getHandler(request);
CorsConfiguration config = getCorsConfiguration(chain, false);
assertNotNull(config);
assertEquals(Arrays.asList("http://example.com"), config.getAllowedOrigins());
assertTrue(config.getAllowCredentials());
}
use of org.springframework.web.servlet.HandlerExecutionChain in project spring-framework by spring-projects.
the class CrossOriginTests method preFlightRequest.
@Test
public void preFlightRequest() throws Exception {
this.handlerMapping.registerHandler(new MethodLevelController());
this.request.setMethod("OPTIONS");
this.request.addHeader(HttpHeaders.ACCESS_CONTROL_REQUEST_METHOD, "GET");
this.request.setRequestURI("/default");
HandlerExecutionChain chain = this.handlerMapping.getHandler(request);
CorsConfiguration config = getCorsConfiguration(chain, true);
assertNotNull(config);
assertArrayEquals(new String[] { "GET" }, config.getAllowedMethods().toArray());
assertArrayEquals(new String[] { "*" }, config.getAllowedOrigins().toArray());
assertTrue(config.getAllowCredentials());
assertArrayEquals(new String[] { "*" }, config.getAllowedHeaders().toArray());
assertTrue(CollectionUtils.isEmpty(config.getExposedHeaders()));
assertEquals(new Long(1800), config.getMaxAge());
}
Aggregations