@Test
  public void testListProjectActionByAuthenticateOneTimeUser() throws Exception {

    String actionString = Action.ListProjects.toString();
    when(mockHttpServletRequest.getParameter(ServletUtil.ACTION)).thenReturn(actionString);

    // set AuthenticateOneTimeUser true
    prepareEnterAuthenticateOneTimeUser(true);

    String xmi = constructProjectsObjectsXmi();
    doThrow(
            new org.talend.gwtadministrator.server.remoteconnection.ConnectionUtil
                .ResponseException(xmi))
        .when(ConnectionUtil.class);
    ConnectionUtil.listAllProjects((User) any());

    // RUN...
    defaultConnectionStrategy.execute(mockHttpServletRequest, mockHttpServletResponse);

    verifyNecessaryChecks(actionString);

    // verify called listAllProjects once
    verifyStatic(org.mockito.Mockito.times(1));
    ConnectionUtil.listAllProjects((User) any());

    PrintWriter writer = mockHttpServletResponse.getWriter();
    writer.flush();
    System.out.println(outStringWriter.toString());
    // ASSERT...
    assertThat(outStringWriter.toString(), is("RESPONSE:" + xmi));
  }
  @Test
  public void testListProjectsActionSentByCmdline() throws Exception {

    String actionString = Action.ListProjects.toString();
    String loginString = ServletUtil.COMMAND_LIST_PROJECTS_HOOK;
    String passwdString = "any";

    when(mockHttpServletRequest.getParameter(ServletUtil.ACTION)).thenReturn(actionString);
    when(mockHttpServletRequest.getParameter(ServletUtil.VERSION)).thenReturn(versionString);
    when(mockHttpServletRequest.getParameter(ServletUtil.LOGIN)).thenReturn(loginString);
    when(mockHttpServletRequest.getParameter(ServletUtil.PASSWD)).thenReturn(passwdString);

    spy(ConnectionUtil.class);

    doNothing().when(ConnectionUtil.class);
    ConnectionUtil.checkParameter(versionString);

    doNothing().when(ConnectionUtil.class);
    ConnectionUtil.checkVersion(versionString);

    String xmi = constructProjectsObjectsXmi();
    doThrow(
            new org.talend.gwtadministrator.server.remoteconnection.ConnectionUtil
                .ResponseException(xmi))
        .when(ConnectionUtil.class);
    ConnectionUtil.listAllProjects((User) any());

    // RUN...
    defaultConnectionStrategy.execute(mockHttpServletRequest, mockHttpServletResponse);

    verifyNecessaryChecks(actionString);

    verifyStatic(org.mockito.Mockito.times(1));
    ConnectionUtil.listAllProjects((User) any());

    PrintWriter writer = mockHttpServletResponse.getWriter();
    writer.flush();
    System.out.println(outStringWriter.toString());
    // ASSERT...
    assertThat(outStringWriter.toString(), is("RESPONSE:" + xmi));
  }