Esempio n. 1
0
  /** Tests that listeners are fired when a comment is rejected. */
  public void testListenersFiredWhenCommentRejected() throws Exception {
    final StringBuffer buf = new StringBuffer("123");
    final Comment comment =
        blogEntry.createComment(
            "title", "body", "author", "email", "website", "avatar", "127.0.0.1");
    blogEntry.addComment(comment);
    comment.setPending();
    service.putBlogEntry(blogEntry);

    CommentListener listener =
        new CommentListener() {
          public void commentAdded(CommentEvent event) {}

          public void commentRemoved(CommentEvent event) {}

          public void commentApproved(CommentEvent event) {}

          public void commentRejected(CommentEvent event) {
            assertEquals(comment, event.getSource());
            buf.reverse();
          }
        };

    blog.getEventListenerList().addCommentListener(listener);
    comment.setRejected();
    service.putBlogEntry(blogEntry);
    assertEquals("321", buf.toString());
  }
Esempio n. 2
0
  /** Tests the various states for a comment. */
  public void testStates() {
    // the default is approved
    assertEquals(State.APPROVED, comment.getState());
    assertTrue(comment.isApproved());
    assertFalse(comment.isPending());
    assertFalse(comment.isRejected());

    comment.setPending();
    assertEquals(State.PENDING, comment.getState());
    assertFalse(comment.isApproved());
    assertTrue(comment.isPending());
    assertFalse(comment.isRejected());

    comment.setRejected();
    assertEquals(State.REJECTED, comment.getState());
    assertFalse(comment.isApproved());
    assertFalse(comment.isPending());
    assertTrue(comment.isRejected());
  }