Examples of BlogEntry


Examples of net.sourceforge.pebble.domain.BlogEntry

    assertTrue(view instanceof NotFoundView);
  }

  public void testPublishedViewBlogEntry() throws Exception {
    BlogEntry blogEntry1 = new BlogEntry(blog);
    blogEntry1.setPublished(true);
    BlogService service = new BlogService();
    service.putBlogEntry(blogEntry1);

    SecurityUtils.runAsUnauthenticated();
    request.setParameter("entry", blogEntry1.getId());
    View view = action.process(request, response);

    BlogEntry blogEntry2 = (BlogEntry)action.getModel().get(Constants.BLOG_ENTRY_KEY);
    assertEquals(blogEntry1.getId(), blogEntry2.getId());
    assertTrue(view instanceof BlogEntryView);
  }
View Full Code Here

Examples of net.sourceforge.pebble.domain.BlogEntry

    assertEquals(blogEntry1.getId(), blogEntry2.getId());
    assertTrue(view instanceof BlogEntryView);
  }

  public void testUnpublishedViewBlogEntryAsAnonymousUser() throws Exception {
    BlogEntry blogEntry1 = new BlogEntry(blog);
    blogEntry1.setPublished(false);
    BlogService service = new BlogService();
    service.putBlogEntry(blogEntry1);

    SecurityUtils.runAsAnonymous();
    request.setParameter("entry", blogEntry1.getId());
    View view = action.process(request, response);

    BlogEntry blogEntry2 = (BlogEntry)action.getModel().get(Constants.BLOG_ENTRY_KEY);
    assertNull(blogEntry2);
    assertTrue(view instanceof NotFoundView);
  }
View Full Code Here

Examples of net.sourceforge.pebble.domain.BlogEntry

    assertNull(blogEntry2);
    assertTrue(view instanceof NotFoundView);
  }

  public void testUnpublishedViewBlogEntryAsUserThatIsAuthorisedForBlog() throws Exception {
    BlogEntry blogEntry1 = new BlogEntry(blog);
    blogEntry1.setPublished(false);
    BlogService service = new BlogService();
    service.putBlogEntry(blogEntry1);

    SecurityUtils.runAsBlogContributor();
    request.setParameter("entry", blogEntry1.getId());
    View view = action.process(request, response);

    BlogEntry blogEntry2 = (BlogEntry)action.getModel().get(Constants.BLOG_ENTRY_KEY);
    assertEquals(blogEntry1.getId(), blogEntry2.getId());
    assertTrue(view instanceof BlogEntryView);
  }
View Full Code Here

Examples of net.sourceforge.pebble.domain.BlogEntry

    super.setUp();
  }

  public void testPublishBlogEntryNow() throws Exception {
    BlogService service = new BlogService();
    BlogEntry blogEntry = new BlogEntry(blog);
    blogEntry.setDate(new Date(100000));
    blogEntry.setPublished(false);
    service.putBlogEntry(blogEntry);

    // now execute the action
    request.setParameter("entry", blogEntry.getId());
    request.setParameter("publishDate", "now");
    request.setParameter("submit", "Publish");
    View view = action.process(request, response);

    blogEntry = (BlogEntry)blog.getRecentBlogEntries(1).get(0);
    assertTrue(blogEntry.isPublished());
    assertEquals(new Date().getTime(), blogEntry.getDate().getTime(), 1000);
    assertTrue(view instanceof RedirectView);
  }
View Full Code Here

Examples of net.sourceforge.pebble.domain.BlogEntry

  }

  public void testPublishBlogEntryAsIsAndCheckCommentsStaysIndexed() throws Exception {
    blog.getPluginProperties().setProperty(IpAddressListener.WHITELIST_KEY, "127.0.0.1");
    BlogService service = new BlogService();
    BlogEntry blogEntry = new BlogEntry(blog);
    blogEntry.setDate(new Date(100000));
    blogEntry.setPublished(false);
    service.putBlogEntry(blogEntry);

    Comment comment = blogEntry.createComment("title", "body", "author", "email", "website", "avatar", "127.0.0.1");
    blogEntry.addComment(comment);
    service.putBlogEntry(blogEntry);

    String commentId = comment.getGuid();
    assertTrue(blog.getResponseIndex().getApprovedResponses().contains(commentId));

    // now execute the action
    request.setParameter("entry", blogEntry.getId());
    request.setParameter("publishDate", "as-is");
    request.setParameter("submit", "Publish");
    View view = action.process(request, response);

    blogEntry = service.getBlogEntry(blog, blogEntry.getId());
    assertTrue(blogEntry.isPublished());
    assertEquals(new Date(100000), blogEntry.getDate());

    // check that the original comment remains intact
    assertTrue(blog.getResponseIndex().getApprovedResponses().contains(commentId));
  }
View Full Code Here

Examples of net.sourceforge.pebble.domain.BlogEntry

  }

  public void testPublishBlogEntryNowAndCheckCommentsReindexed() throws Exception {
    blog.getPluginProperties().setProperty(IpAddressListener.WHITELIST_KEY, "127.0.0.1");
    BlogService service = new BlogService();
    BlogEntry blogEntry = new BlogEntry(blog);
    blogEntry.setDate(new Date(100000));
    blogEntry.setPublished(false);
    service.putBlogEntry(blogEntry);

    Comment comment = blogEntry.createComment("title", "body", "author", "email", "website", "avatar", "127.0.0.1");
    blogEntry.addComment(comment);
    service.putBlogEntry(blogEntry);

    String commentId = comment.getGuid();
    assertTrue(blog.getResponseIndex().getApprovedResponses().contains(commentId));

    // now execute the action
    request.setParameter("entry", blogEntry.getId());
    request.setParameter("publishDate", "now");
    request.setParameter("submit", "Publish");
    View view = action.process(request, response);

    blogEntry = (BlogEntry)blog.getRecentBlogEntries(1).get(0);
    assertTrue(blogEntry.isPublished());
    assertEquals(new Date().getTime(), blogEntry.getDate().getTime(), 1000);

    // check that the original comment has been unindexed
    assertFalse(blog.getResponseIndex().getApprovedResponses().contains(commentId));
    assertTrue(blog.getResponseIndex().getApprovedResponses().contains(blogEntry.getComments().get(0).getGuid()));
  }
View Full Code Here

Examples of net.sourceforge.pebble.domain.BlogEntry

    assertTrue(blog.getResponseIndex().getApprovedResponses().contains(blogEntry.getComments().get(0).getGuid()));
  }

  public void testUnpublishBlogEntry() throws Exception {
    BlogService service = new BlogService();
    BlogEntry blogEntry = new BlogEntry(blog);
    blogEntry.setPublished(true);
    service.putBlogEntry(blogEntry);

    // now execute the action
    request.setParameter("entry", blogEntry.getId());
    request.setParameter("submit", "Unpublish");
    View view = action.process(request, response);

    blogEntry = service.getBlogEntry(blog, blogEntry.getId());
    assertTrue(blogEntry.isUnpublished());
    assertTrue(view instanceof RedirectView);
  }
View Full Code Here

Examples of net.sourceforge.pebble.domain.BlogEntry

   * @param response the HttpServletResponse instance
   * @return the name of the next view
   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    BlogEntry blogEntry;
    Comment comment;

    String entry = request.getParameter("entry");
    String rememberMe = request.getParameter("rememberMe");
    String submitType = request.getParameter("submit");

    BlogService service = new BlogService();
    try {
      blogEntry = service.getBlogEntry(blog, entry);
    } catch (BlogServiceException e) {
      throw new ServletException(e);
    }
    if (blogEntry == null) {
      // just send back a 404 - this is probably somebody looking for a way
      // to send comment spam ;-)
      log.info("ignoring saveComment with no related blog entry (spam) from " + request.getRemoteAddr());
      return new NotFoundView();
    } else if (!blogEntry.isCommentsEnabled()) {
      return new CommentConfirmationView();
    }

    comment = createComment(request, blogEntry);
    ValidationContext context = validateComment(comment);
View Full Code Here

Examples of net.sourceforge.pebble.domain.BlogEntry

   */
  public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
    Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
    String entryId = request.getParameter("entry");

    BlogEntry blogEntry = null;
    if (entryId != null) {
      BlogService service = new BlogService();
      try {
        blogEntry = service.getBlogEntry(blog, entryId);
      } catch (BlogServiceException e) {
View Full Code Here

Examples of net.sourceforge.pebble.domain.BlogEntry

   * Gets the title of this view.
   *
   * @return the title as a String
   */
  public String getTitle() {
    BlogEntry blogEntry = (BlogEntry)getModel().get(Constants.BLOG_ENTRY_KEY);
    return blogEntry.getTitle();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.