protected void setUp() throws Exception {
    mConfig = new Configuration();
    mConfig.setTestMode(true);
    mConfig.save();

    // 刪除資料庫
    InitialSQL ini = new InitialSQL(mConfig);
    ini.exe();

    // create project
    mCP = new CreateProject(1);
    mCP.exeCreate();

    // create sprint
    mCS = new CreateSprint(2, mCP);
    mCS.exe();

    mProject = mCP.getAllProjects().get(0);
    super.setUp();

    // ================ set action info ========================
    setContextDirectory(new File(mConfig.getBaseDirPath() + "/WebContent"));
    setServletConfigFile("/WEB-INF/struts-config.xml");
    setRequestPathInfo(mActionPath);

    ini = null;
  }
示例#2
0
  @Before
  public void setUp() {
    mConfig = new Configuration();
    mConfig.setTestMode(true);
    mConfig.save();

    InitialSQL ini = new InitialSQL(mConfig);
    ini.exe();

    mCP = new CreateProject(1);
    mCP.exeCreate();

    mData = new StoryDataForFilter();
  }
示例#3
0
  @After
  public void tearDown() {
    InitialSQL ini = new InitialSQL(mConfig);
    ini.exe();
    // 刪除外部檔案
    ProjectManager projectManager = new ProjectManager();
    projectManager.deleteAllProject();

    // 讓 config 回到  Production 模式
    mConfig.setTestMode(false);
    mConfig.save();

    mCP = null;
    mData = null;
  }
  /** no story */
  public void testAddExistedStory_1() {
    long sprintId = mCS.getSprintsId().get(0);
    String releaseId = "-1";
    String[] selects = {};

    // ================ set request info ========================
    String projectName = mProject.getName();
    request.setHeader("Referer", "?PID=" + projectName);
    addRequestParameter("selects", selects);
    addRequestParameter("sprintID", String.valueOf(sprintId));
    addRequestParameter("releaseID", releaseId);

    // ================ set session info ========================
    request.getSession().setAttribute("UserSession", mConfig.getUserSession());

    // ================ 執行 action ======================
    actionPerform();

    // ================ assert ========================
    verifyNoActionErrors();
    verifyNoActionMessages();
    // assert response text
    String expectedResponseText = "";
    String actualResponseText = response.getWriterBuffer().toString();
    assertEquals(expectedResponseText, actualResponseText);
  }
  // case 1: no sprint
  public void testNoSprint() throws Exception {
    // ================ set initial data =======================
    IProject project = mCP.getProjectList().get(0);
    // ================ set initial data =======================

    // ================== set parameter info ====================
    addRequestParameter("sprintID", Integer.toString(-1)); // 取得第一筆 SprintPlan
    // ================== set parameter info ====================

    // ================ set session info ========================
    request.getSession().setAttribute("UserSession", mConfig.getUserSession());
    request.getSession().setAttribute("Project", project);
    // ================ set session info ========================
    request.setHeader(
        "Referer", "?PID=" + project.getName()); // SessionManager 會對URL的參數作分析 ,未帶入此參數無法存入session

    actionPerform(); // 執行 action

    // 驗證回傳 path
    verifyForwardPath(null);
    verifyForward(null);
    verifyNoActionErrors();

    // 比對資料是否正確(sprintID = -1)
    String expected =
        "<Retrospectives><Sprint><Id>-1</Id><Name>Sprint #-1</Name></Sprint></Retrospectives>";
    //    	System.out.println("response: " + response.getWriterBuffer().toString());
    assertEquals(expected, response.getWriterBuffer().toString());
  }
  // case 5: One sprint with 1 Good + 1 Improvement
  public void testOneSprint1g1i() throws Exception {
    mCS = new CreateSprint(1, mCP);
    mCS.exe(); // 新增一個 Sprint	

    mCR = new CreateRetrospective(1, 1, mCP, mCS);
    mCR.exe();

    // ================ set initial data =======================
    IProject project = mCP.getProjectList().get(0);
    long sprintID = mCS.getSprintsId().get(0);
    // ================ set initial data =======================

    // ================== set parameter info ====================
    addRequestParameter("sprintID", String.valueOf(sprintID)); // 取得第一筆 SprintPlan
    // ================== set parameter info ====================

    // ================ set session info ========================
    request.getSession().setAttribute("UserSession", mConfig.getUserSession());
    request.getSession().setAttribute("Project", project);
    // ================ set session info ========================
    request.setHeader(
        "Referer", "?PID=" + project.getName()); // SessionManager 會對URL的參數作分析 ,未帶入此參數無法存入session

    actionPerform(); // 執行 action

    // 驗證回傳 path
    verifyForwardPath(null);
    verifyForward(null);
    verifyNoActionErrors();

    // 比對資料是否正確
    String expected = genXML(String.valueOf(sprintID));
    assertEquals(expected, response.getWriterBuffer().toString());
  }
  /** 專案擁有一個Sprint但該專案沒有成員 */
  public void testShowInformationAction_2() {
    int sprintCount = 1;
    CreateSprint createSprint = new CreateSprint(sprintCount, mCP);
    createSprint.exe();

    // ================ set request info ========================
    String expectedSprintID = "1";
    String projectName = mProject.getName();
    request.setHeader("Referer", "?PID=" + projectName);
    addRequestParameter("sprintID", expectedSprintID);

    // ================ set session info ========================
    request.getSession().setAttribute("UserSession", mConfig.getUserSession());

    // ================ 執行 action ======================
    actionPerform();

    // ================ assert ========================
    verifyNoActionErrors();
    verifyNoActionMessages();
    /*
     * in struts-config.xml
     * <forward name="success" path="sprintInformation.show"/>
     * 因此根據sprintInformation.show必須到tiles-defs.xml找到要轉發的頁面
     * in tiles-defs.xml
     * <definition name="sprintInformation.show" path="/Pages/ShowSprintInformation.jsp"></definition>
     */
    verifyForward("success");
    verifyForwardPath("/Pages/ShowSprintInformation.jsp");

    String actualSprintID = String.valueOf(request.getAttribute("SprintID"));
    String actualStoryPoint = String.valueOf(request.getAttribute("StoryPoint"));
    ISprintPlanDesc actualSprintPlan = (ISprintPlanDesc) request.getAttribute("SprintPlan");
    String actualActors = String.valueOf(request.getAttribute("Actors"));
    String actualSprintPeriod = String.valueOf(request.getAttribute("SprintPeriod"));
    @SuppressWarnings("unchecked")
    ArrayList<StoryObject> actualIIssueList =
        (ArrayList<StoryObject>) request.getAttribute("Stories");

    TestTool testTool = new TestTool();
    Date today = createSprint.mToday;
    Date startDate = testTool.getSprintStartDate(CreateSprint.SPRINT_INTERVAL, today);
    Date endDate = testTool.getSprintEndDate(CreateSprint.SPRINT_INTERVAL, today);
    String expectedSprintPeriod =
        testTool.transformDate(startDate) + " to " + testTool.transformDate(endDate);

    assertEquals(expectedSprintID, actualSprintID); // 	verify sprint ID
    assertEquals("0.0", actualStoryPoint); // 	verify story points
    assertNotNull(actualSprintPlan); // 	verify sprint plan object
    assertEquals(
        createSprint.TEST_SPRINT_GOAL + expectedSprintID,
        actualSprintPlan.getGoal()); // 	verify sprint goal
    assertEquals("[]", actualActors); // 	verify 參與此專案的人(因為尚未加入團隊成員因此為空的)
    assertEquals(expectedSprintPeriod, actualSprintPeriod); // 	verify Sprint週期
    //	verify story information
    assertNotNull(actualIIssueList);
    assertEquals(0, actualIIssueList.size());
    assertEquals("0.0", actualStoryPoint); // 	verify story points
  }
  @After
  public void tearDown() {
    // 初始化 SQL
    InitialSQL ini = new InitialSQL(mConfig);
    ini.exe();

    // 刪除外部檔案
    ProjectManager projectManager = new ProjectManager();
    projectManager.deleteAllProject();

    mConfig.setTestMode(false);
    mConfig.save();

    // release
    ini = null;
    mCP = null;
    mProject = null;
    mConfig = null;
    mControl = null;
  }
  @Before
  public void setUp() {
    mConfig = new Configuration();
    mConfig.setTestMode(true);
    mConfig.save();

    InitialSQL ini = new InitialSQL(mConfig);
    ini.exe();

    mCP = new CreateProject(mProjectCount);
    mCP.exeCreate();

    mControl = new MySQLControl(mConfig);
    mControl.connect();

    mProject = mCP.getAllProjects().get(0);

    // create a retrospective
    mRtrospectiveId = createRetrospective();
  }
  protected void tearDown() throws IOException, Exception {
    //	刪除資料庫
    InitialSQL ini = new InitialSQL(mConfig);
    ini.exe();

    //	刪除外部檔案
    ProjectManager projectManager = new ProjectManager();
    projectManager.deleteAllProject();

    // 讓 config 回到  Production 模式
    mConfig.setTestMode(false);
    mConfig.save();

    // ============= release ==============
    ini = null;
    mCP = null;
    mConfig = null;

    super.tearDown();
  }
  protected void tearDown() throws Exception {
    // 刪除資料庫
    InitialSQL ini = new InitialSQL(mConfig);
    ini.exe();

    // 刪除外部檔案
    ProjectManager projectManager = new ProjectManager();
    projectManager.deleteAllProject();

    mConfig.setTestMode(false);
    mConfig.save();

    super.tearDown();

    ini = null;
    projectManager = null;
    mCP = null;
    mCS = null;
    mConfig = null;
    mProject = null;
  }
  protected void setUp() throws Exception {
    mConfig = new Configuration();
    mConfig.setTestMode(true);
    mConfig.save();

    InitialSQL ini = new InitialSQL(mConfig);
    ini.exe(); // 初始化 SQL

    mCP = new CreateProject(1);
    mCP.exeCreate(); // 新增一測試專案

    super.setUp();

    setContextDirectory(new File(mConfig.getBaseDirPath() + "/WebContent")); // 設定讀取的
    // struts-config
    // 檔案路徑
    setServletConfigFile("/WEB-INF/struts-config.xml");
    setRequestPathInfo("/showRetrospective2");

    // ============= release ==============
    ini = null;
  }
  protected void setUp() throws Exception {
    mConfig = new Configuration();
    mConfig.setTestMode(true);
    mConfig.save();

    // 初始化 SQL
    InitialSQL ini = new InitialSQL(mConfig);
    ini.exe();

    //	新增一測試專案
    mCP = new CreateProject(1);
    mCP.exeCreate();
    mProject = mCP.getAllProjects().get(0);

    super.setUp();

    setContextDirectory(
        new File(mConfig.getBaseDirPath() + "/WebContent")); // 設定讀取的 struts-config 檔案路徑
    setServletConfigFile("/WEB-INF/struts-config.xml");
    setRequestPathInfo(mACTION_PATH);

    // ============= release ==============
    ini = null;
  }
  /** 專案沒有一個 Sprint */
  public void testShowInformationAction_1() {
    // ================ set request info ========================
    String sprintId = "1";
    String projectName = mProject.getName();

    request.setHeader("Referer", "?PID=" + projectName);
    addRequestParameter("sprintID", sprintId);

    // ================ set session info ========================
    request.getSession().setAttribute("UserSession", mConfig.getUserSession());

    // ================ 執行 action ======================
    actionPerform();

    // ================ assert ========================
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward("error");
    verifyForwardPath("/Error.jsp");
  }
  /** two stories */
  public void testAddExistedStory_2() {
    int storyCount = 2;
    CreateProductBacklog CPB = new CreateProductBacklog(storyCount, mCP);
    CPB.exe();

    long sprintId = mCS.getSprintsId().get(0);
    String releaseID = "-1";
    String[] selects = {"1", "2"};

    // ================ set request info ========================
    String projectName = mProject.getName();
    request.setHeader("Referer", "?PID=" + projectName);
    addRequestParameter("selects", selects);
    addRequestParameter("sprintID", String.valueOf(sprintId));
    addRequestParameter("releaseID", releaseID);

    // ================ set session info ========================
    request.getSession().setAttribute("UserSession", mConfig.getUserSession());

    // ================ 執行 action ======================
    actionPerform();

    // ================ assert ========================
    verifyNoActionErrors();
    verifyNoActionMessages();
    // assert response text
    String actualResponseText = response.getWriterBuffer().toString();
    StringBuilder expectedResponseText = new StringBuilder();
    expectedResponseText.append("");
    assertEquals(expectedResponseText.toString(), actualResponseText);

    // 驗證是否確實有被加入sprint中
    String showSprintBacklog_ActionPath = "/showSprintBacklog2";
    setRequestPathInfo(showSprintBacklog_ActionPath);

    clearRequestParameters();
    response.reset();

    // ================ set request info ========================
    request.setHeader("Referer", "?PID=" + projectName);
    addRequestParameter("sprintID", String.valueOf(sprintId));

    // ================ set session info ========================
    request.getSession().setAttribute("UserSession", mConfig.getUserSession());

    // ================ 執行 action ======================
    actionPerform();

    // ================ assert ========================
    verifyNoActionErrors();
    verifyNoActionMessages();
    // assert response text
    String expectedStoryEstimation = "2";
    String expectedSprintGoal = "TEST_SPRINTGOAL_1";
    String expectedSprintHoursToCommit = "10";
    for (int i = 0; i < mCS.getSprintCount() - 1; i++) {
      expectedResponseText
          .append("{\"success\":true,\"Total\":2,")
          .append("\"Sprint\":{")
          .append("\"Id\":")
          .append(sprintId)
          .append(",")
          .append("\"Name\":\"Sprint #")
          .append(sprintId)
          .append("\",")
          .append("\"CurrentPoint\":")
          .append(Integer.parseInt(expectedStoryEstimation) * 2)
          .append(",")
          .append("\"LimitedPoint\":")
          .append(Integer.parseInt(expectedSprintHoursToCommit))
          .append(",")
          .append("\"TaskPoint\":0,")
          .append("\"ReleaseID\":\"Release #None\",")
          .append("\"SprintGoal\":\"")
          .append(expectedSprintGoal)
          .append("\"},")
          .append("\"Stories\":[");

      for (StoryObject story : CPB.getStories()) {
        expectedResponseText
            .append("{\"Id\":")
            .append(story.getId())
            .append(",")
            .append("\"Link\":\"")
            .append("\",")
            .append("\"Name\":\"")
            .append(story.getName())
            .append("\",")
            .append("\"Value\":")
            .append(story.getValue())
            .append(",")
            .append("\"Importance\":")
            .append(story.getImportance())
            .append(",")
            .append("\"Estimate\":")
            .append(story.getEstimate())
            .append(",")
            .append("\"Status\":\"new\",")
            .append("\"Notes\":\"")
            .append(story.getNotes())
            .append("\",")
            .append("\"Tag\":\"\",")
            .append("\"HowToDemo\":\"")
            .append(story.getHowToDemo())
            .append("\",")
            .append("\"Release\":\"\",")
            .append("\"Sprint\":")
            .append(sprintId)
            .append(",")
            .append("\"Attach\":false,")
            .append("\"AttachFileList\":[]},");
      }
      expectedResponseText.deleteCharAt(expectedResponseText.length() - 1);
      expectedResponseText.append("]}");
    }
    actualResponseText = response.getWriterBuffer().toString();
    assertEquals(expectedResponseText.toString(), actualResponseText);
  }
  /**
   * 專案擁有一個Sprint且專案擁有一位成員
   *
   * @throws Exception
   */
  public void testShowInformationAction_3() throws Exception {
    int sprintCount = 1;
    CreateSprint createSprint = new CreateSprint(sprintCount, mCP);
    createSprint.exe();

    int storyCount = 1;
    int expectStoryEstimation = 5;
    AddStoryToSprint addStoryToSprint =
        new AddStoryToSprint(
            storyCount,
            expectStoryEstimation,
            createSprint,
            mCP,
            CreateProductBacklog.COLUMN_TYPE_EST);
    addStoryToSprint.exe();

    int accountCount = 1;
    CreateAccount createAccount = new CreateAccount(accountCount);
    createAccount.exe();
    AddUserToRole addUserToRole = new AddUserToRole(mCP, createAccount);
    addUserToRole.exe_ST();

    // ================ set request info ========================
    String expectedSprintID = "1";
    String projectName = mProject.getName();
    request.setHeader("Referer", "?PID=" + projectName);
    addRequestParameter("sprintID", expectedSprintID);

    // ================ set session info ========================
    request.getSession().setAttribute("UserSession", mConfig.getUserSession());

    // ================ 執行 action ======================
    actionPerform();

    // ================ assert ========================
    verifyNoActionErrors();
    verifyNoActionMessages();
    /*
     * in struts-config.xml
     * <forward name="success" path="sprintInformation.show"/>
     * 因此根據sprintInformation.show必須到tiles-defs.xml找到要轉發的頁面
     * in tiles-defs.xml
     * <definition name="sprintInformation.show" path="/Pages/ShowSprintInformation.jsp"></definition>
     */
    verifyForward("success");
    verifyForwardPath("/Pages/ShowSprintInformation.jsp");

    String actualSprintID = String.valueOf(request.getAttribute("SprintID"));
    String actualStoryPoint = String.valueOf(request.getAttribute("StoryPoint"));
    ISprintPlanDesc actualSprintPlan = (ISprintPlanDesc) request.getAttribute("SprintPlan");
    String actualSprintPeriod = String.valueOf(request.getAttribute("SprintPeriod"));
    @SuppressWarnings("unchecked")
    ArrayList<StoryObject> actualStories = (ArrayList<StoryObject>) request.getAttribute("Stories");
    @SuppressWarnings("unchecked")
    ArrayList<String> actualActors = (ArrayList<String>) request.getAttribute("Actors");

    TestTool testTool = new TestTool();
    Date today = createSprint.mToday;
    Date startDate = testTool.getSprintStartDate(CreateSprint.SPRINT_INTERVAL, today);
    Date endDate = testTool.getSprintEndDate(CreateSprint.SPRINT_INTERVAL, today);
    String expectedSprintPeriod =
        testTool.transformDate(startDate) + " to " + testTool.transformDate(endDate);

    /**
     * 1. verify sprint ID 2. verify story information 3. verify sprint plan information 5. verify
     * Sprint週期 6. verify 參與此專案的人
     */
    //	verify sprint ID
    assertEquals(expectedSprintID, actualSprintID);

    //	verify story information
    assertNotNull(actualStories);
    assertEquals("TEST_STORY_1", actualStories.get(0).getName());
    assertEquals("5.0", actualStoryPoint);

    //	verify sprint plan information
    assertNotNull(actualSprintPlan);
    assertEquals(createSprint.TEST_SPRINT_GOAL + expectedSprintID, actualSprintPlan.getGoal());

    //	verify Sprint週期
    assertEquals(expectedSprintPeriod, actualSprintPeriod);

    //	verify 參與此專案的人
    String expectAccountID = createAccount.getAccount_ID(1);
    boolean isExistedAccount = false;
    for (String accountID : actualActors) {
      if (accountID.equals(expectAccountID)) {
        isExistedAccount = true;
        break;
      }
    }
    assertTrue(isExistedAccount);
  }