@Test public void testContinueSessionByNormalUser() throws Exception { String sessionIdString = "555"; long newSessionId = 556; String actionString = Action.ContinueSession.toString(); long sessionIdLong = Long.parseLong(sessionIdString); when(mockHttpServletRequest.getParameter(ServletUtil.ACTION)).thenReturn(actionString); when(mockHttpServletRequest.getParameter(ServletUtil.PROJECT)).thenReturn(projectString); when(mockHttpServletRequest.getParameter(ServletUtil.SESSION_ID)).thenReturn(sessionIdString); // set AuthenticateOneTimeUser false prepareEnterAuthenticateOneTimeUser(false); User user = stubbingCheckUser(); UsersCache userCacheHelper = mock(UsersCache.class); mockStatic(UsersCacheFactory.class); when(UsersCacheFactory.getInstance()).thenReturn(userCacheHelper); when(userCacheHelper.pingWithLabel(sessionIdLong, loginString, CLIENT_TYPE, projectString)) .thenReturn(newSessionId); // RUN... defaultConnectionStrategy.execute(mockHttpServletRequest, mockHttpServletResponse); verifyNecessaryChecks(actionString); verifyStatic(org.mockito.Mockito.times(1)); ConnectionUtil.checkUser(loginString, password, false); PrintWriter writer = mockHttpServletResponse.getWriter(); writer.flush(); System.out.println(outStringWriter.toString()); // ASSERT... assertThat(outStringWriter.toString(), is("RESPONSE:" + String.valueOf(newSessionId))); }
@Test public void testContinueSessionsActionsByAuthenticateOneTimeUser() throws Exception { testSessionActionsByAuthenticateOneTimeUser(Action.ContinueSession.toString()); }