Exemplo n.º 1
0
  /** Tests that the e-mail address is properly escaped and set. */
  public void testEmailAddress() {
    assertEquals("*****@*****.**", comment.getEmail());

    // blank or null e-mail defaults to null
    comment.setEmail("");
    assertEquals("", comment.getEmail()); // FIXME should be null
    comment.setEmail(null);
    assertEquals("", comment.getEmail()); // FIXME should be null

    // for security, special HTML characters are removed
    comment.setEmail("<*****@*****.**>");
    assertEquals("&lt;[email protected]&gt;", comment.getEmail());
  }
  private List<Comment> readComments(Content websiteNode) throws RepositoryException {

    List<Comment> list = new ArrayList<Comment>();

    if (websiteNode.hasContent("comments")) {
      Content commentsNode = websiteNode.getContent("comments");
      Collection<Content> children = commentsNode.getChildren();
      for (Content commentNode : children) {
        Comment comment = new Comment();
        comment.setName(commentNode.getNodeData("name").getString());
        comment.setEmail(commentNode.getNodeData("email").getString());
        comment.setText(commentNode.getNodeData("text").getString());
        comment.setCreated(commentNode.getNodeData("created").getDate().getTime());
        comment.setId(commentNode.getName());
        list.add(comment);
      }
    }

    return list;
  }