use of org.springframework.mock.web.test.MockHttpServletResponse in project spring-framework by spring-projects.
the class ResourceHandlerRegistryTests method setUp.
@Before
public void setUp() {
this.registry = new ResourceHandlerRegistry(new GenericWebApplicationContext(), new MockServletContext());
this.registration = registry.addResourceHandler("/resources/**");
this.registration.addResourceLocations("classpath:org/springframework/web/servlet/config/annotation/");
this.response = new MockHttpServletResponse();
}
use of org.springframework.mock.web.test.MockHttpServletResponse in project spring-framework by spring-projects.
the class UrlFilenameViewControllerTests method withPrefix.
@Test
public void withPrefix() throws Exception {
UrlFilenameViewController ctrl = new UrlFilenameViewController();
ctrl.setPrefix("mypre_");
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/index.html");
MockHttpServletResponse response = new MockHttpServletResponse();
ModelAndView mv = ctrl.handleRequest(request, response);
assertEquals("mypre_index", mv.getViewName());
assertTrue(mv.getModel().isEmpty());
}
use of org.springframework.mock.web.test.MockHttpServletResponse in project spring-framework by spring-projects.
the class UrlFilenameViewControllerTests method multiLevelMappingWithFallback.
@Test
public void multiLevelMappingWithFallback() throws Exception {
UrlFilenameViewController ctrl = new UrlFilenameViewController();
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/docs/cvs/commit.html");
exposePathInMapping(request, "/docs/cvs/commit.html");
MockHttpServletResponse response = new MockHttpServletResponse();
ModelAndView mv = ctrl.handleRequest(request, response);
assertEquals("docs/cvs/commit", mv.getViewName());
assertTrue(mv.getModel().isEmpty());
}
use of org.springframework.mock.web.test.MockHttpServletResponse in project spring-framework by spring-projects.
the class UrlFilenameViewControllerTests method withContextMapping.
@Test
public void withContextMapping() throws Exception {
UrlFilenameViewController ctrl = new UrlFilenameViewController();
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/myapp/docs/cvs/commit.html");
request.setContextPath("/myapp");
MockHttpServletResponse response = new MockHttpServletResponse();
ModelAndView mv = ctrl.handleRequest(request, response);
assertEquals("docs/cvs/commit", mv.getViewName());
assertTrue(mv.getModel().isEmpty());
}
use of org.springframework.mock.web.test.MockHttpServletResponse in project spring-framework by spring-projects.
the class UrlFilenameViewControllerTests method withFlashAttributes.
@Test
public void withFlashAttributes() throws Exception {
UrlFilenameViewController ctrl = new UrlFilenameViewController();
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/index");
request.setAttribute(DispatcherServlet.INPUT_FLASH_MAP_ATTRIBUTE, new ModelMap("name", "value"));
MockHttpServletResponse response = new MockHttpServletResponse();
ModelAndView mv = ctrl.handleRequest(request, response);
assertEquals("index", mv.getViewName());
assertEquals(1, mv.getModel().size());
assertEquals("value", mv.getModel().get("name"));
}
Aggregations