Пример #1
0
  public void testViewAccessLogByDate() throws Exception {
    gen.transactionLog2();
    WebConversation wc = login("2", "pw");
    WebResponse wr = wc.getCurrentPage();
    assertEquals("iTrust - Patient Home", wr.getTitle());
    assertLogged(TransactionType.HOME_VIEW, 2L, 0L, "");

    wr = wr.getLinkWith("Access Log").click();
    assertFalse(wr.getText().contains("Exception"));

    WebForm form = wr.getForms()[0];
    form.setParameter("startDate", "03/01/2008");
    form.setParameter("endDate", "12/01/2008");
    form.getSubmitButtons()[0].click();

    wr = wr.getLinkWith("Date").click();
    /*
    WebTable table = wr.getTableStartingWithPrefix("Date");
    assertTrue(table.getCellAsText(1, 3).contains("View emergency report"));
    assertTrue(table.getCellAsText(2, 3).contains("Edit Office Visits"));
    assertTrue(table.getCellAsText(3, 3).contains("View prescription report"));
    assertTrue(table.getCellAsText(4, 3).contains("View risk factors"));
    assertLogged(TransactionType.ACCESS_LOG_VIEW, 2L, 0L, "");
    */

  }
Пример #2
0
  @Test
  public void testCopyFileOverwrite() throws Exception {
    String directoryPath = "/testCopyFile/directory/path" + System.currentTimeMillis();
    String sourcePath = directoryPath + "/source.txt";
    String destName = "destination.txt";
    String destPath = directoryPath + "/" + destName;
    createDirectory(directoryPath);
    createFile(sourcePath, "This is the contents");
    createFile(destPath, "Original file");

    // with no-overwrite, copy should fail
    JSONObject requestObject = new JSONObject();
    addSourceLocation(requestObject, sourcePath);
    WebRequest request =
        getPostFilesRequest(directoryPath, requestObject.toString(), "destination.txt");
    request.setHeaderField("X-Create-Options", "copy,no-overwrite");
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_PRECON_FAILED, response.getResponseCode());

    // now omit no-overwrite and copy should succeed and return 200 instead of 201
    request = getPostFilesRequest(directoryPath, requestObject.toString(), "destination.txt");
    request.setHeaderField("X-Create-Options", "copy");
    response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    JSONObject responseObject = new JSONObject(response.getText());
    checkFileMetadata(responseObject, destName, null, null, null, null, null, null, null);
    assertTrue(checkFileExists(sourcePath));
    assertTrue(checkFileExists(destPath));
  }
Пример #3
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, "");
  }
Пример #4
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, "");
  }
Пример #5
0
  public void testViewAccessLogByRole() throws Exception {
    gen.transactionLog3();
    WebConversation wc = login("1", "pw");
    WebResponse wr = wc.getCurrentPage();
    assertEquals("iTrust - Patient Home", wr.getTitle());
    assertLogged(TransactionType.HOME_VIEW, 1L, 0L, "");

    wr = wr.getLinkWith("Access Log").click();
    assertFalse(wr.getText().contains("Exception"));

    WebForm form = wr.getForms()[0];
    form.setParameter("startDate", "02/01/2008");
    form.setParameter("endDate", "09/22/2009");
    form.getSubmitButtons()[0].click();
    form.getScriptableObject().setParameterValue("sortBy", "role");
    wr = form.submit();

    WebTable table = wr.getTableStartingWithPrefix("Date");
    assertTrue(table.getCellAsText(1, 2).contains("Emergency Responder"));
    assertTrue(table.getCellAsText(2, 2).contains("LHCP"));
    assertTrue(table.getCellAsText(3, 2).contains("LHCP"));
    assertTrue(table.getCellAsText(4, 2).contains("LHCP"));
    assertTrue(table.getCellAsText(5, 2).contains("Personal Health Representative"));
    assertTrue(table.getCellAsText(6, 2).contains("UAP"));

    assertLogged(TransactionType.ACCESS_LOG_VIEW, 1L, 0L, "");
  }
Пример #6
0
  @SuppressWarnings("unchecked")
  public List<Group> getAllGroups() throws Exception {
    // {"vfwebqq":"3e99140e076c4dc3c8a774f1e3a37518055f3f39f94428a8eaa07c1f7c0ebfea3a18792878f2c061"}

    String url = "http://s.web2.qq.com/api/get_group_name_list_mask2";
    String content = "{\"vfwebqq\":\"" + vfwebqq + "\"}";
    PostMethodWebRequest post = new PostMethodWebRequest(url);
    post.setParameter("r", content);

    wc.setHeaderField("Referer", "http://s.web2.qq.com/proxy.html?v=20110412001&callback=1&id=2");

    WebResponse rs = wc.getResponse(post);
    log.info("sendMsg response:" + rs.getText());

    List<Group> groups = new ArrayList<Group>();

    JSONObject retJson = new JSONObject(rs.getText());
    if (retJson.getInt("retcode") == 0) {
      JSONArray infos = retJson.getJSONObject("result").getJSONArray("gnamelist");
      for (int i = 0; i < infos.length(); i++) {
        JSONObject obj = infos.getJSONObject(i);
        Group group = new Group();
        group.setGid(obj.getString("gid"));
        group.setName(obj.getString("name"));
        group.setCode(obj.getString("code"));
        groups.add(group);
      }
    }
    return groups;
  }
Пример #7
0
  @Test
  public void testCreateDirectory() throws CoreException, IOException, SAXException, JSONException {
    String directoryPath = "sample/directory/path" + System.currentTimeMillis();
    createDirectory(directoryPath);

    String dirName = "testdir";
    webConversation.setExceptionsThrownOnErrorStatus(false);

    WebRequest request =
        getPostFilesRequest(directoryPath, getNewDirJSON(dirName).toString(), dirName);
    WebResponse response = webConversation.getResponse(request);

    assertEquals(HttpURLConnection.HTTP_CREATED, response.getResponseCode());
    assertTrue(
        "Create directory response was OK, but the directory does not exist",
        checkDirectoryExists(directoryPath + "/" + dirName));
    assertEquals(
        "Response should contain directory metadata in JSON, but was " + response.getText(),
        "application/json",
        response.getContentType());
    JSONObject responseObject = new JSONObject(response.getText());
    assertNotNull("No directory information in response", responseObject);
    checkDirectoryMetadata(responseObject, dirName, null, null, null, null, null);

    // should be able to perform GET on location header to obtain metadata
    String location = response.getHeaderField(ProtocolConstants.HEADER_LOCATION);
    request = getGetFilesRequest(location);
    response = webConversation.getResource(request);
    assertNotNull(location);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    responseObject = new JSONObject(response.getText());
    assertNotNull("No direcory information in responce", responseObject);
    checkDirectoryMetadata(responseObject, dirName, null, null, null, null, null);
  }
Пример #8
0
  @Test
  public void testCreateTopLevelFile()
      throws CoreException, IOException, SAXException, JSONException {
    String directoryPath = "sample" + System.currentTimeMillis();
    createDirectory(directoryPath);
    String fileName = "testfile.txt";

    WebRequest request =
        getPostFilesRequest(directoryPath, getNewFileJSON(fileName).toString(), fileName);
    WebResponse response = webConversation.getResponse(request);

    assertEquals(HttpURLConnection.HTTP_CREATED, response.getResponseCode());
    assertTrue(
        "Create file response was OK, but the file does not exist",
        checkFileExists(directoryPath + "/" + fileName));
    assertEquals(
        "Response should contain file metadata in JSON, but was " + response.getText(),
        "application/json",
        response.getContentType());
    JSONObject responseObject = new JSONObject(response.getText());
    assertNotNull("No file information in responce", responseObject);
    checkFileMetadata(responseObject, fileName, null, null, null, null, null, null, null);

    // should be able to perform GET on location header to obtain metadata
    String location = response.getHeaderField("Location");
    request = getGetFilesRequest(location + "?parts=meta");
    response = webConversation.getResource(request);
    assertNotNull(location);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    responseObject = new JSONObject(response.getText());
    assertNotNull("No direcory information in responce", responseObject);
    checkFileMetadata(responseObject, fileName, null, null, null, null, null, null, null);
  }
  public void testChangePassword_Invalid_Length() throws Exception {
    // Patient1 logs into iTrust
    WebConversation wc = login("1", "pw");
    WebResponse wr = wc.getCurrentPage();
    assertEquals("iTrust - Patient Home", wr.getTitle());

    // User goes to change password
    wr = wr.getLinkWith("Change Password").click();

    // User types in their current, new, and confirm passwords
    WebForm wf = wr.getFormWithID("mainForm");
    wf.setParameter("oldPass", "pw");
    wf.setParameter("newPass", "pas1");
    wf.setParameter("confirmPass", "pas1");

    // User submits password change. Change logged
    wf.submit(wf.getSubmitButtons()[0]);
    wr = wc.getCurrentPage();
    assertTrue(wr.getText().contains("Invalid password"));
    assertLogged(TransactionType.PASSWORD_CHANGE_FAILED, 1L, 0, "");

    // User logs out
    wr = wr.getLinkWith("Logout").click();

    // User can log in with old password, but can't with new one
    wc = login("1", "pas1");
    assertEquals("iTrust - Login", wc.getCurrentPage().getTitle());
    wc = login("1", "pw");
    assertEquals("iTrust - Patient Home", wc.getCurrentPage().getTitle());
  }
Пример #10
0
  public void testDeleteUserWithLoan() throws Exception {
    logger.info("Entered TC18 testDeleteUserWithLoan");
    User user;
    String parameterUserName = "******" + System.currentTimeMillis();
    String IsbnName = "testISBN" + System.currentTimeMillis();
    user = new User("TestFirstName", "TestLastName", parameterUserName, "password", Role.STUDENT);
    String parameterBookName = "MyBook" + System.currentTimeMillis();
    userService.saveOrUpdate(user);
    Book book = new Book(parameterBookName, IsbnName, 2);
    bookService.saveOrUpdate(book);
    session.refresh(book);
    logger.info("User added" + user.getUsername());
    // now create loan for this user
    Calendar now = Calendar.getInstance();
    now.add(Calendar.MINUTE, 5);
    logger.info("Book " + book.getBookid() + " user " + user.getUserId());

    Loan loan = new Loan(user.getUserId(), book.getBookid(), now.getTime(), 0, 10, false);
    loandao.saveOrUpdate(loan);
    loanId = loan.getLoanId();
    bookId = book.getBookid();
    userId = user.getUserId();
    logger.debug("Loan " + loan.getLoanId() + " created for user " + user.getUserId());
    logger.info("Loan created: " + loan.getLoanId());
    logger.info("trying to delete userID: " + user.getUserId());
    WebConversation conversation = new WebConversation();
    WebRequest requestDeleteUser =
        new GetMethodWebRequest(Constant.DELETE_USER_URL + user.getUserId());
    WebResponse responseGetUser = conversation.getResponse(requestDeleteUser);
    WebTable bookListUpdatedTable = responseGetUser.getTableWithID("userListTable");
    TableCell tableUpdatedCell = bookListUpdatedTable.getTableCellWithID(user.getUserId());
    assertEquals(tableUpdatedCell.getText(), user.getUserId());
    logger.info("Exited TC18 testDeleteUserWithLoan");
  }
Пример #11
0
  /**
   * Tests adding a lab procedure with no lab tech selected. Verifies that an error message is
   * displayed.
   *
   * @throws Exception
   */
  public void testAddLabProcedureWithoutLabTech() throws Exception {
    gen.clearAllTables();
    gen.standardData();

    WebConversation wc = login("9000000000", "pw");
    WebResponse wr = wc.getCurrentPage();
    assertEquals("iTrust - HCP Home", wr.getTitle());
    // click Document Office Visit
    wr = wr.getLinkWith("Document Office Visit").click();

    // select the patient
    WebForm form = wr.getForms()[0];
    form.getScriptableObject().setParameterValue("UID_PATIENTID", "2");
    form.getButtons()[1].click();
    wr = wc.getCurrentPage();
    assertEquals(ADDRESS + "auth/hcp-uap/documentOfficeVisit.jsp", wr.getURL().toString());
    // Select the office visit from specific date
    wr.getLinkWith("6/10/2007").click();

    wr = wc.getCurrentPage();
    assertEquals("iTrust - Document Office Visit", wr.getTitle());

    form = wr.getFormWithID("labProcedureForm");
    form.setParameter("loinc", "10666-6");
    form.setParameter("labProcPriority", "1");
    form.getButtonWithID("add_labProcedure").click();

    // check updated page
    wr = wc.getCurrentPage();
    assertTrue(
        wr.getText().contains("A lab tech must be selected before adding a laboratory procedure."));
  }
Пример #12
0
  @Test
  public void testDeleteNonEmptyDirectory() throws CoreException, IOException, SAXException {
    String dirPath1 = "sample/directory/path/sample1" + System.currentTimeMillis();
    String dirPath2 = "sample/directory/path/sample2" + System.currentTimeMillis();
    String fileName = "subfile.txt";
    String subDirectory = "subdirectory";

    createDirectory(dirPath1);
    createFile(dirPath1 + "/" + fileName, "Sample file content");
    createDirectory(dirPath2 + "/" + subDirectory);

    WebRequest request = getDeleteFilesRequest(dirPath1);
    WebResponse response = webConversation.getResponse(request);
    assertEquals(
        "Could not delete directory with file",
        HttpURLConnection.HTTP_OK,
        response.getResponseCode());

    assertFalse(
        "Delete directory with file request returned OK, but the file still exists",
        checkDirectoryExists(dirPath1));

    request = getDeleteFilesRequest(dirPath2);
    response = webConversation.getResponse(request);
    assertEquals(
        "Could not delete directory with subdirectory",
        HttpURLConnection.HTTP_OK,
        response.getResponseCode());

    assertFalse(
        "Delete directory with subdirectory request returned OK, but the file still exists",
        checkDirectoryExists(dirPath2));
  }
Пример #13
0
  /**
   * Verifies that a representative is able to view the access log of a representee.
   *
   * @throws Exception
   */
  public void testViewAccessLogRepresentativeView() throws Exception {
    gen.clearAllTables();
    gen.standardData();

    WebConversation wc = login("24", "pw");
    WebResponse wr = wc.getCurrentPage();
    assertEquals("iTrust - Patient Home", wr.getTitle());

    wr = wr.getLinkWith("Access Log").click();
    assertEquals("iTrust - View My Access Log", wr.getTitle());

    // select Dare Devil from the dropdown menu
    WebForm representeeSelectForm = wr.getFormWithID("logMIDSelectionForm");
    representeeSelectForm.setParameter("logMID", "23");
    representeeSelectForm.submit();

    wr = wc.getCurrentPage();

    assertFalse(wr.getText().contains("Beaker Beaker"));
    assertTrue(wr.getText().contains("<td >2007-06-23 06:55:59.0</td>"));

    wr = wr.getLinkWith("Role").click();
    assertEquals("iTrust - View My Access Log", wr.getTitle());
    assertFalse(wr.getText().contains("Beaker Beaker"));
    assertTrue(wr.getText().contains("<td >2007-06-23 06:55:59.0</td>"));

    wr = wr.getLinkWith("Access Log").click();
    assertEquals("iTrust - View My Access Log", wr.getTitle());

    assertFalse(wr.getText().contains("Kelly Doctor"));
    assertTrue(wr.getText().contains("<td >2007-06-25 06:54:59.0</td>"));
  }
Пример #14
0
  /*
   * @author Jay Patel
   * HCP 9000000000 has viewed PHR of patient 2 on 11/11/2007.
   * Authenticate Patient
   * MID: 2
   * Password: pw
   * Choose option View Access Log
   * Choose date range 11/12/2015 through 11/11/2015
   * Invalid format in use yyyy/mm/dd
   */
  public void testViewAccessLogDateOrder() throws Exception {
    // clear operational profile
    gen.transactionLog();
    // login patient 2
    WebConversation wc = login("2", "pw");
    WebResponse wr = wc.getCurrentPage();
    assertEquals("iTrust - Patient Home", wr.getTitle());
    assertLogged(TransactionType.HOME_VIEW, 2L, 0L, "");

    // click on View Access Log
    wr = wr.getLinkWith("Access Log").click();
    // select the date range and submit
    WebForm form = wr.getForms()[0];
    form.setParameter("startDate", "11/12/2015");
    form.setParameter("endDate", "11/11/2015");
    form.getSubmitButtons()[0].click();
    WebResponse add = wc.getCurrentPage();

    // Since we are using a invalid format for dates putting
    // the format yyyy/mm/dd should return an "Information not valid"
    // response on the page

    assertFalse(add.getText().contains("Exception"));
    assertTrue(add.getText().contains("Information not valid"));
  }
Пример #15
0
  public void testSubmitAndEditConsultation() throws Exception {

    WebConversation wc = login("9000000000", "pw");
    WebResponse wr = wc.getCurrentPage();
    assertEquals("iTrust - HCP Home", wr.getTitle());

    wr = wr.getLinkWith("Consultations").click();
    assertTrue(wr.getText().contains("HCP Consultations"));

    wr.getForms()[0].getButtons()[0].click();

    wr = wc.getCurrentPage();

    assertTrue(wr.getText().contains("Send a Consultation"));

    wr.getForms()[0].setParameter("patient", "5");
    wr.getForms()[0].setParameter("hcp", "9000000003");
    wr = wr.getForms()[0].submit();

    assertTrue(wr.getText().contains("Consultation Form"));

    wr.getForms()[0].setParameter("msg", "Test1");
    wr = wr.getForms()[0].submit();

    assertTrue(wr.getText().contains("Thank you, your Consultation Request was sent."));

    assertTrue(wr.getText().contains("Test1"));

    wr = wr.getLinkWith("Consultations").click();
    assertTrue(wr.getText().contains("HCP Consultations"));

    wr.getForms()[0].getButtons()[1].click();

    wr = wc.getCurrentPage();

    assertTrue(wr.getText().contains("View Pending Consultations"));

    assertTrue(wr.getText().contains("Baby Programmer (5)"));

    wr = wr.getLinkWith("edit").click();

    WebTable wt = wr.getTableStartingWith("Patient:");

    assertEquals("Baby Programmer", wt.getCellAsText(0, 1));
    assertEquals("Kelly Doctor", wt.getCellAsText(1, 1));
    assertEquals("Gandalf Stormcrow", wt.getCellAsText(2, 1));

    wr.getForms()[0].setParameter("refDetails", "Test2");
    wr = wr.getForms()[0].submit();

    assertTrue(wr.getText().contains("Consultation updated"));

    wr = wr.getLinkWith("Consultations").click();
    wr.getForms()[0].getButtons()[1].click();
    wr = wc.getCurrentPage();
    wr = wr.getLinkWith("edit").click();

    assertTrue(wr.getText().contains("Test2"));
  }
  @Test
  public void testRoom() throws Exception {
    // create room
    WebRequest request =
        new PostMethodWebRequest(
            getCreateUrl(),
            new ByteArrayInputStream(objectMapper.writeValueAsString(baseRoom).getBytes()),
            MediaType.APPLICATION_JSON_VALUE);
    WebResponse response = conversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_CREATED, response.getResponseCode());
    assertEquals(MediaType.APPLICATION_JSON_VALUE, response.getContentType());
    Room room = objectMapper.readValue(response.getText(), Room.class);
    assertNotNull(room);
    assertTrue(room.getId() != 0);
    assertTrue(compare(baseRoom, room, "id"));

    // update room
    baseRoom = room;
    baseRoom.setName("New name");
    request =
        new PutMethodWebRequest(
            getUpdateUrl(),
            new ByteArrayInputStream(objectMapper.writeValueAsString(baseRoom).getBytes()),
            MediaType.APPLICATION_JSON_VALUE);
    response = conversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    assertEquals(MediaType.APPLICATION_JSON_VALUE, response.getContentType());
    room = objectMapper.readValue(response.getText(), Room.class);
    assertNotNull(room);
    assertEquals(room, baseRoom);

    // get room
    request = new GetMethodWebRequest(getViewUrl(baseRoom.getId()));
    response = conversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());
    assertEquals(MediaType.APPLICATION_JSON_VALUE, response.getContentType());
    room = objectMapper.readValue(response.getText(), Room.class);
    assertNotNull(room);
    assertEquals(room, baseRoom);

    // remove room
    request =
        new WebRequest(getDeleteUrl(baseRoom.getId())) {

          @Override
          public String getMethod() {
            return RequestMethod.DELETE.toString();
          }
        };
    response = conversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    // check removed
    URL url = new URL(getViewUrl(baseRoom.getId()));
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.connect();
    assertEquals(HttpURLConnection.HTTP_NO_CONTENT, connection.getResponseCode());
  }
Пример #17
0
  /**
   * testPatientViewLabResults
   *
   * @throws Exception
   */
  public void testPatientViewLabResults() throws Exception {
    WebConversation wc = login("2", "pw");
    WebResponse wr = wc.getCurrentPage();
    assertEquals("iTrust - Patient Home", wr.getTitle());
    assertLogged(TransactionType.HOME_VIEW, 2L, 0L, "");

    wr = wr.getLinkWith("View My Records").click();
    assertEquals("iTrust - View My Records", wr.getTitle());
    assertLogged(TransactionType.MEDICAL_RECORD_VIEW, 2L, 2L, "");
  }
Пример #18
0
 /** Verifies that the HTTP header of a diagram incites the browser to cache it. */
 public void testInvalidUrl() throws Exception {
   WebConversation conversation = new WebConversation();
   // Try to proxify an invalid address
   WebRequest request = new GetMethodWebRequest(getServerUrl() + "proxy/invalidURL");
   WebResponse response = conversation.getResource(request);
   // Analyze response, it must be the empty form
   // Verifies the Content-Type header
   assertEquals("Response content type is not HTML", "text/html", response.getContentType());
   WebForm[] forms = response.getForms();
   assertEquals(2, forms.length);
 }
Пример #19
0
  /**
   * Verifies that a non-representative is not shown a representee to select.
   *
   * @throws Exception
   */
  public void testViewAccessLogNonRepresentativeView1() throws Exception {
    gen.clearAllTables();
    gen.standardData();

    WebConversation wc = login("23", "pw");
    WebResponse wr = wc.getCurrentPage();
    assertEquals("iTrust - Patient Home", wr.getTitle());

    wr = wr.getLinkWith("Access Log").click();
    assertEquals("iTrust - View My Access Log", wr.getTitle());
    assertFalse(wr.getText().contains("Devils Advocate"));
  }
Пример #20
0
  public void testAddLabProcedureWithLabTech() throws Exception {
    gen.clearAllTables();
    gen.standardData();

    WebConversation wc = login("9000000000", "pw");
    WebResponse wr = wc.getCurrentPage();
    assertEquals("iTrust - HCP Home", wr.getTitle());
    // click Document Office Visit
    wr = wr.getLinkWith("Document Office Visit").click();

    // select the patient
    WebForm form = wr.getForms()[0];
    form.getScriptableObject().setParameterValue("UID_PATIENTID", "2");
    form.getButtons()[1].click();
    wr = wc.getCurrentPage();
    assertEquals(ADDRESS + "auth/hcp-uap/documentOfficeVisit.jsp", wr.getURL().toString());
    // Select the office visit from specific date
    wr.getLinkWith("6/10/2007").click();

    wr = wc.getCurrentPage();
    assertEquals("iTrust - Document Office Visit", wr.getTitle());

    form = wr.getFormWithID("labProcedureForm");
    form.setParameter("loinc", "10666-6");
    form.setParameter("labTech", "5000000001");
    form.setParameter("labProcPriority", "1");
    form.getButtonWithID("add_labProcedure").click();

    // check updated page
    wr = wc.getCurrentPage();
    assertTrue(wr.getText().contains("Lab Procedure information successfully updated."));
    assertLogged(TransactionType.LAB_PROCEDURE_ADD, 9000000000L, 2L, "");

    // Get row containing procedure.
    WebTable tbl = wr.getTableWithID("labProceduresTable");
    TableRow[] rows = tbl.getRows();
    int rowi = 0;
    for (; rowi < rows.length; rowi++) {
      if (rows[rowi].getText().startsWith("| 10666-6")) {
        break;
      }
    }
    assertTrue(rowi < rows.length);
    // Verify data in table
    assertEquals("Lab Dude", tbl.getCellAsText(rowi, 1));
    assertEquals("In Transit", tbl.getCellAsText(rowi, 2)); // status
    assertEquals("", tbl.getCellAsText(rowi, 5)); // commentary
    assertEquals("", tbl.getCellAsText(rowi, 6)); // numerical results
    assertEquals("", tbl.getCellAsText(rowi, 7)); // lower bound
    assertEquals("", tbl.getCellAsText(rowi, 8)); // upper bound
    assertTrue(tbl.getCellAsText(rowi, 10).contains("Remove")); // action
    assertTrue(tbl.getCellAsText(rowi, 10).contains("Reassign")); // action
  }
Пример #21
0
 private void setCookie(WebResponse rs) {
   String[] cookies = rs.getHeaderFields("set-cookie");
   for (String cookie : cookies) {
     String firstCookie = cookie.split(";")[0];
     String[] cookieStr = firstCookie.split("=");
     if (cookieStr.length == 2) {
       wc.putCookie(cookieStr[0], cookieStr[1]);
     } else {
       wc.putCookie(cookieStr[0], "");
     }
   }
 }
Пример #22
0
  private static String useGoogleTranslator(String text, TranslationType type) {

    String response = "";
    String urlString =
        "http://translate.google.com/translate_t?text=" + text + "&langpair=" + type.getID();
    // disable scripting to avoid requiring js.jar
    HttpUnitOptions.setScriptingEnabled(false);

    // create the conversation object which will maintain state for us
    WebConversation wc = new WebConversation();

    // Obtain the google translation page
    WebRequest webRequest = new GetMethodWebRequest(urlString);
    // required to prevent a 403 forbidden error from google
    webRequest.setHeaderField("User-agent", "Mozilla/4.0");

    try {
      WebResponse webResponse = wc.getResponse(webRequest);
      // NodeList list = webResponse.getDOM().getDocumentElement().getElementsByTagName("div");
      try {
        NodeList list2 =
            XPathAPI.selectNodeList(webResponse.getDOM(), "//span[@id='result_box']/span/text()");

        for (int i = 0; i < list2.getLength(); ++i) {
          response = response + list2.item(i).getNodeValue() + " ";
        }

      } catch (TransformerException e) {
        Log.warning("Translator error", e);
      }

      //            int length = list.getLength();
      //            for (int i = 0; i < length; i++) {
      //                Element element = (Element)list.item(i);
      //                if ("result_box".equals(element.getAttribute("id"))) {
      //                    Node translation = element.getFirstChild();
      //                    if (translation != null) {
      //                        response = translation.getNodeValue();
      //                    }
      //                }
      //            }
    } catch (MalformedURLException e) {
      Log.error("Could not for url: " + e);
    } catch (IOException e) {
      Log.error("Could not get response: " + e);
    } catch (SAXException e) {
      Log.error("Could not parse response content: " + e);
    }

    return response;
  }
Пример #23
0
  /*
   * Authenticate Patient
   * MID: 1
   * Password: pw
   * Choose option View Access Log
   */
  public void testViewAccessLog3() throws Exception {
    // clear operational profile
    gen.transactionLog();
    // make sure that no exceptions are thrown even though patient 1 has nothing in the view
    // access log
    WebConversation wc = login("1", "pw");
    WebResponse wr = wc.getCurrentPage();
    assertEquals("iTrust - Patient Home", wr.getTitle());
    assertLogged(TransactionType.HOME_VIEW, 1L, 0L, "");

    wr = wr.getLinkWith("Access Log").click();
    assertFalse(wr.getText().contains("Exception"));
    assertLogged(TransactionType.ACCESS_LOG_VIEW, 1L, 0L, "");
  }
Пример #24
0
  public WebResponse loginForm(String username, String password) throws Exception {
    WebConversation conversation = new WebConversation();
    HttpUnitOptions.setScriptingEnabled(false);
    HttpUnitOptions.setExceptionsThrownOnScriptError(false);
    WebRequest request = new GetMethodWebRequest("http://localhost:8084/LeaveApp/index.jsp");
    WebResponse response = conversation.getResponse(request);
    WebForm loginform = response.getForms()[0];
    loginform.setParameter("username", username);
    loginform.setParameter("password", password);
    request = loginform.getRequest("submitbutton");
    response = conversation.getResponse(request);

    return response;
  }
Пример #25
0
  /**
   * Verifies that the access log correctly handle bad date inputs
   *
   * @throws Exception
   */
  public void testViewAccessLogBadDateHandling() throws Exception {
    gen.clearAllTables();
    gen.standardData();

    WebConversation wc = login("23", "pw");
    WebResponse wr = wc.getCurrentPage();
    assertEquals("iTrust - Patient Home", wr.getTitle());

    wr = wr.getLinkWith("Access Log").click();
    assertEquals("iTrust - View My Access Log", wr.getTitle());

    WebForm dateForm = wr.getForms()[0];
    dateForm.setParameter("startDate", "6/22/2007");
    dateForm.setParameter("endDate", "6/21/2007");
    dateForm.submit();

    wr = wc.getCurrentPage();
    assertEquals("iTrust - View My Access Log", wr.getTitle());
    assertTrue(
        wr.getText()
            .contains(
                "<h2>Information not valid</h2><div class=\"errorList\">Start date must be before end date!<br /></div>"));

    dateForm = wr.getForms()[0];
    dateForm.setParameter("startDate", "June 22nd, 2007");
    dateForm.setParameter("endDate", "6/23/2007");
    dateForm.submit();

    wr = wc.getCurrentPage();
    assertEquals("iTrust - View My Access Log", wr.getTitle());
    assertTrue(
        wr.getText()
            .contains(
                "<h2>Information not valid</h2><div class=\"errorList\">Enter dates in MM/dd/yyyy<br /></div>"));

    // This test is currently commented out because the bug is due to "functionality" in the
    // SimpleDataFormat class which assumes that month 13 === 1
    /*
    dateForm = wr.getForms()[0];
    dateForm.setParameter("startDate", "13/01/2010");
    dateForm.setParameter("endDate", "6/24/2011");
    dateForm.submit();

    wr = wc.getCurrentPage();
    assertEquals("iTrust - View My Access Log", wr.getTitle());
    assertTrue(wr.getText().contains("<h2>Information not valid</h2><div class=\"errorList\">Enter dates in MM/dd/yyyy<br /></div>"));
    */
  }
Пример #26
0
  public void addRepository(
      final Project project,
      final RedmineRepositoryConfig config,
      final SCMConnectorConfig scmConfig,
      final String username,
      final String password)
      throws MalformedURLException, IOException, SAXException {
    login(config);
    LOGGER.info("Redmine add Repository: " + scmConfig.getScmUrl());

    // Check if Repository should be added
    if (!config.isAddRepositoryConfiguration()) {
      LOGGER.debug("Redmine Repository config is disabled.");
      return;
    }

    List<Cookie> cookies = (List<Cookie>) _wt.getDialog().getCookies();
    for (Cookie cookie : cookies) {
      _wc.putCookie(cookie.getName(), cookie.getValue());
    }
    String token = getAuthenticityToken(_wt.getPageSource());
    LOGGER.debug("Token: {}", token);

    String scm = getScmType(scmConfig);
    LOGGER.debug("SCM CONFIG: {}", scm);

    postData(config, project, scmConfig, username, password, scm);
  }
Пример #27
0
  @Test
  public void testReadDirectoryChildren()
      throws CoreException, IOException, SAXException, JSONException {
    String dirName = "path" + System.currentTimeMillis();
    String directoryPath = "sample/directory/" + dirName;
    createDirectory(directoryPath);

    String subDirectory = "subdirectory";
    createDirectory(directoryPath + "/" + subDirectory);

    String subFile = "subfile.txt";
    createFile(directoryPath + "/" + subFile, "Sample file");

    WebRequest request = getGetFilesRequest(directoryPath + "?depth=1");
    WebResponse response = webConversation.getResponse(request);
    assertEquals(HttpURLConnection.HTTP_OK, response.getResponseCode());

    List<JSONObject> children = getDirectoryChildren(new JSONObject(response.getText()));

    assertEquals("Wrong number of directory children", 2, children.size());

    for (JSONObject child : children) {
      if (child.getBoolean("Directory")) {
        checkDirectoryMetadata(child, subDirectory, null, null, null, null, null);
      } else {
        checkFileMetadata(child, subFile, null, null, null, null, null, null, null);
      }
    }
  }
Пример #28
0
 public void testProxyWithFormat() throws Exception {
   WebConversation conversation = new WebConversation();
   WebRequest request =
       new GetMethodWebRequest(
           getServerUrl() + "proxy/svg/" + getServerUrl() + "resource/test2diagrams.txt");
   WebResponse response = conversation.getResource(request);
   // Analyze response
   // Verifies the Content-Type header
   // TODO assertEquals( "Response content type is not SVG", "image/svg+xml",
   // response.getContentType());
   // Get the content and verify its size
   String diagram = response.getText();
   int diagramLen = diagram.length();
   assertTrue(diagramLen > 1000);
   assertTrue(diagramLen < 3000);
 }
Пример #29
0
  /**
   * testPatientViewLabProcedureResults
   *
   * @throws Exception
   */
  public void testPatientViewLabProcedureResults() throws Exception {
    gen.clearAllTables();
    gen.standardData();

    WebConversation wc = login("22", "pw");
    WebResponse wr = wc.getCurrentPage();
    assertEquals("iTrust - Patient Home", wr.getTitle());
    wr = wr.getLinkWith("My Lab Procedures").click();

    assertEquals("iTrust - View Lab Procedures", wr.getTitle());
    WebTable tbl = wr.getTableWithID("labProceduresTable");
    assertEquals(51, tbl.getRowCount());

    int numericalColumn = 5;
    assertEquals("", tbl.getCellAsText(13, numericalColumn));
    assertEquals("", tbl.getCellAsText(12, numericalColumn));
    assertEquals("", tbl.getCellAsText(11, numericalColumn));

    assertEquals("7", tbl.getCellAsText(10, numericalColumn));
    assertEquals("", tbl.getCellAsText(9, numericalColumn));
    assertEquals("", tbl.getCellAsText(8, numericalColumn));

    assertEquals("", tbl.getCellAsText(7, numericalColumn));
    assertEquals("5.23", tbl.getCellAsText(6, numericalColumn));
    assertEquals("", tbl.getCellAsText(5, numericalColumn));

    assertEquals("", tbl.getCellAsText(4, numericalColumn));
    assertEquals("", tbl.getCellAsText(3, numericalColumn));
    assertEquals("18", tbl.getCellAsText(2, numericalColumn));

    int statusColumn = 3;
    assertEquals("In Transit", tbl.getCellAsText(13, statusColumn));
    assertEquals("Received", tbl.getCellAsText(12, statusColumn));
    assertEquals("Pending", tbl.getCellAsText(11, statusColumn));

    assertEquals("Completed", tbl.getCellAsText(10, statusColumn));
    assertEquals("In Transit", tbl.getCellAsText(9, statusColumn));
    assertEquals("Received", tbl.getCellAsText(8, statusColumn));

    assertEquals("Pending", tbl.getCellAsText(7, statusColumn));
    assertEquals("Completed", tbl.getCellAsText(6, statusColumn));
    assertEquals("In Transit", tbl.getCellAsText(5, statusColumn));

    assertEquals("Received", tbl.getCellAsText(4, statusColumn));
    assertEquals("Pending", tbl.getCellAsText(3, statusColumn));
    assertEquals("Completed", tbl.getCellAsText(2, statusColumn));
  }
Пример #30
0
  public void testWSDL() throws Exception {
    WebConversation conversation = new WebConversation();
    String destination = testProps.getProperty("destination");
    if (destination != null && destination.length() > 0) {
      WebRequest request = new GetMethodWebRequest(destination + "?WSDL");

      WebResponse response = conversation.getResponse(request);

      int i = response.getContentLength();
      InputSource is = new InputSource(response.getInputStream());

      Document doc = builder.parse(is);

      doc.getDocumentElement();
      System.out.println("My test");
    }
  }