@Test public void redirect() throws Exception { MockHttpServletResponse response = new MockHttpServletResponse(); response.sendRedirect("/login"); assertEquals(response.getStatus(), HttpServletResponse.SC_FOUND); assertEquals(response.getRedirect(), "/login"); }
@Test public void sendRedirect() throws IOException { String redirectUrl = "/redirect"; response.sendRedirect(redirectUrl); assertEquals(HttpServletResponse.SC_MOVED_TEMPORARILY, response.getStatus()); assertEquals(redirectUrl, response.getHeader("Location")); assertEquals(redirectUrl, response.getRedirectedUrl()); assertTrue(response.isCommitted()); }