@Override protected void setUp() throws Exception { MockitoAnnotations.initMocks(this); servlet = new SignOutServlet(sessionManager); when(req.getSession(false)).thenReturn(session); PrintWriter writer = mock(PrintWriter.class); when(resp.getWriter()).thenReturn(writer); }
public void testServletWorksWhenSessionIsMissing() throws Exception { when(req.getSession(false)).thenReturn(null); servlet.doGet(req, resp); verify(resp).setStatus(HttpServletResponse.SC_OK); } }
public void testServletRedirects() throws Exception { String redirect_location = "/abc123?nested=query&string"; when(req.getParameter("r")).thenReturn(redirect_location); servlet.doGet(req, resp); verify(resp).sendRedirect(redirect_location); }
@Override protected void setUp() throws Exception { MockitoAnnotations.initMocks(this); servlet = new SignOutServlet(sessionManager); when(req.getSession(eq(false))).thenReturn(session); when(req.getSession()).thenReturn(session); PrintWriter writer = mock(PrintWriter.class); when(resp.getWriter()).thenReturn(writer); }
public void testServletDoesNotRedirectToRemoteUrl() throws Exception { String redirect_location = "http://example.com/"; when(req.getParameter("r")).thenReturn(redirect_location); servlet.doGet(req, resp); verify(resp, never()).sendRedirect(anyString()); }
public void testServletRedirects() throws Exception { String redirect_location = "/abc123?nested=query&string"; when(req.getParameter("r")).thenReturn(redirect_location); servlet.doGet(req, resp); verify(resp).sendRedirect(redirect_location); }
public void testServletWorksWhenSessionIsMissing() throws Exception { when(req.getSession(false)).thenReturn(null); servlet.doGet(req, resp); verify(resp).setStatus(HttpServletResponse.SC_OK); } }
public void testServletDoesNotRedirectToRemoteUrl() throws Exception { String redirect_location = "http://example.com/"; when(req.getParameter("r")).thenReturn(redirect_location); servlet.doGet(req, resp); verify(resp, never()).sendRedirect(anyString()); }
public void testUserSignedOut() throws Exception { servlet.doGet(req, resp); verify(sessionManager).logout(session); verify(resp).setStatus(HttpServletResponse.SC_OK); }
public void testUserSignedOut() throws Exception { servlet.doGet(req, resp); verify(sessionManager).logout(session); verify(resp).setStatus(HttpServletResponse.SC_OK); }