Exemplo n.º 1
0
  /**
   * Test as Html.
   *
   * @param jspName jsp name, with full path
   * @throws Exception any axception thrown during test.
   */
  public void doTest(String jspName) throws Exception {

    WebRequest request = new GetMethodWebRequest(jspName);

    WebResponse response = runner.getResponse(request);

    if (log.isDebugEnabled()) {
      log.debug("RESPONSE: " + response.getText());
    }

    WebTable[] tables = response.getTables();

    assertEquals("Wrong number of tables.", 1, tables.length);

    assertEquals("Bad number of generated columns.", 2, tables[0].getColumnCount());

    assertEquals(
        "Bad value in column header.", //
        StringUtils.capitalize(KnownValue.ANT),
        tables[0].getCellAsText(0, 0));
    assertEquals(
        "Bad value in column header.", //
        StringUtils.capitalize(KnownValue.CAMEL),
        tables[0].getCellAsText(0, 1));
  }
Exemplo n.º 2
0
  /**
   * @param jspName jsp name, with full path
   * @throws Exception any axception thrown during test.
   */
  @Test
  public void doTest() throws Exception {

    WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));

    WebResponse response = runner.getResponse(request);

    if (log.isDebugEnabled()) {
      log.debug(response.getText());
    }

    WebTable[] tables = response.getTables();
    Assert.assertEquals("Wrong number of tables.", 1, tables.length);

    Assert.assertEquals("Wrong number of columns.", 2, tables[0].getColumnCount());
    Assert.assertEquals("Wrong number of rows.", 3, tables[0].getRowCount()); // 2 plus header

    TableRow[] rows = tables[0].getRows();

    Assert.assertEquals("Wrong id for row 1", "idcamel0", rows[1].getID());
    Assert.assertEquals("Wrong id for row 2", "idcamel1", rows[2].getID());

    Assert.assertEquals("Wrong class for row 1", "odd classcamel0", rows[1].getClassName());
    Assert.assertEquals("Wrong class for row 2", "even classcamel1", rows[2].getClassName());
  }
Exemplo n.º 3
0
  /**
   * Check sorted column.
   *
   * @param jspName jsp name, with full path
   * @throws Exception any axception thrown during test.
   */
  @Test
  public void doTest() throws Exception {
    WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));

    ParamEncoder encoder = new ParamEncoder("table");
    request.setParameter(encoder.encodeParameterName(TableTagParameters.PARAMETER_SORT), "1");
    request.setParameter(
        encoder.encodeParameterName(TableTagParameters.PARAMETER_SORTUSINGNAME), "1");

    WebResponse response = runner.getResponse(request);

    if (log.isDebugEnabled()) {
      log.debug(response.getText());
    }

    WebTable[] tables = response.getTables();
    Assert.assertEquals("Wrong number of tables in result.", 1, tables.length);
    Assert.assertEquals("Wrong number of rows in result.", 3, tables[0].getRowCount());

    if (log.isDebugEnabled()) {
      log.debug(response.getText());
    }

    Assert.assertEquals(
        "Wrong value in first row. Table incorrectly sorted?", "2", tables[0].getCellAsText(1, 1));
    Assert.assertEquals(
        "Column 1 should not be marked as sorted.",
        "sortable",
        tables[0].getTableCell(0, 1).getClassName());
    Assert.assertEquals(
        "Column 2 should be marked as sorted.",
        "sortable sorted order1",
        tables[0].getTableCell(0, 2).getClassName());
  }
Exemplo n.º 4
0
  public void testRemoveAppt() throws Exception {
    // login hcp
    gen.uc22();
    WebConversation wc = login("9000000000", "pw");
    WebResponse wr = wc.getCurrentPage();
    assertEquals("iTrust - HCP Home", wr.getTitle());
    assertLogged(TransactionType.HOME_VIEW, 9000000000L, 0L, "");

    wr = wr.getLinkWith("View My Appointments").click();
    assertLogged(TransactionType.APPOINTMENT_ALL_VIEW, 9000000000L, 0L, "");

    WebTable table = wr.getTables()[0];
    int row = 0;
    for (int i = 0; i < table.getRowCount(); i++) {
      if (table.getCellAsText(i, 0).equals("Anakin Skywalker")) {
        row = i;
        break;
      }
    }

    wr = table.getTableCell(row, 5).getLinkWith("Edit/Remove").click();
    assertTrue(wr.getText().contains("Anakin Skywalker"));
    WebForm wf = wr.getFormWithID("mainForm");

    wf.getSubmitButtonWithID("removeButton").click();
    wr = wc.getCurrentPage();

    assertTrue(wr.getText().contains("Success: Appointment removed"));
    assertLogged(TransactionType.APPOINTMENT_REMOVE, 9000000000L, 100L, "");
  }
Exemplo n.º 5
0
  public void testSetPassedDate() throws Exception {
    // login hcp
    gen.uc22();
    WebConversation wc = login("9000000000", "pw");
    WebResponse wr = wc.getCurrentPage();
    assertEquals("iTrust - HCP Home", wr.getTitle());
    assertLogged(TransactionType.HOME_VIEW, 9000000000L, 0L, "");
    wr = wr.getLinkWith("View My Appointments").click();
    assertLogged(TransactionType.APPOINTMENT_ALL_VIEW, 9000000000L, 0L, "");

    WebTable table = wr.getTables()[0];
    int row = 0;
    for (int i = 0; i < table.getRowCount(); i++) {
      if (table.getCellAsText(i, 0).equals("Anakin Skywalker")) {
        row = i;
        break;
      }
    }

    wr = table.getTableCell(row, 5).getLinkWith("Edit/Remove").click();
    assertTrue(wr.getText().contains("Anakin Skywalker"));
    WebForm wf = wr.getFormWithID("mainForm");
    wf.setParameter("schedDate", "10/10/2009");

    wf.getSubmitButtonWithID("changeButton").click();
    wr = wc.getCurrentPage();

    assertTrue(wr.getText().contains("The scheduled date of this appointment"));
    assertTrue(wr.getText().contains("has already passed."));
    assertNotLogged(TransactionType.APPOINTMENT_EDIT, 9000000000L, 100L, "");
  }
Exemplo n.º 6
0
  public void testEditAppt() throws Exception {
    // login hcp
    WebConversation wc = login("9000000000", "pw");
    WebResponse wr = wc.getCurrentPage();
    assertEquals("iTrust - HCP Home", wr.getTitle());
    assertLogged(TransactionType.HOME_VIEW, 9000000000L, 0L, "");

    wr = wr.getLinkWith("View My Appointments").click();
    assertLogged(TransactionType.APPOINTMENT_ALL_VIEW, 9000000000L, 0L, "");

    WebTable table = wr.getTables()[0];
    wr = table.getTableCell(table.getRowCount() - 1, 5).getLinkWith("Edit/Remove").click();
    assertTrue(wr.getText().contains("Andy Programmer"));
    WebForm wf = wr.getFormWithID("mainForm");
    wf.setParameter("comment", "New comment!");

    SubmitButton[] buttons = wf.getSubmitButtons();
    wr = wf.submit(buttons[0]); // Submit as "Change"
    assertTrue(wr.getText().contains("Success: Appointment changed"));
    assertLogged(TransactionType.APPOINTMENT_EDIT, 9000000000L, 2L, "");
  }