Examples of BlogService


Examples of net.sourceforge.pebble.domain.BlogService

   * Tests that a permalink is changed when the blog entry title changes.
   */
  public void testBlogEntryPermalinkChangesWithTitle() throws Exception {
    blog.setPermalinkProvider(new TitlePermalinkProvider());

    BlogService service = new BlogService();

    BlogEntry blogEntry = new BlogEntry(blog);
    service.putBlogEntry(blogEntry);

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy'/'MM'/'dd'/'");
    sdf.setTimeZone(blog.getTimeZone());
    String prefix = blog.getUrl();
    prefix += sdf.format(blogEntry.getDate());
View Full Code Here

Examples of net.sourceforge.pebble.domain.BlogService

    String ids[] = request.getParameterValues("entry");
    String submit = request.getParameter("submit");

    if (ids != null) {
      for (String id : ids) {
        BlogService service = new BlogService();
        BlogEntry blogEntry = null;
        try {
          blogEntry = service.getBlogEntry(blog, id);
        } catch (BlogServiceException e) {
          throw new ServletException(e);
        }

        if (blogEntry != null) {
          if (submit.equalsIgnoreCase("Remove")) {
            try {
              service.removeBlogEntry(blogEntry);
              blog.info("Blog entry \"" + StringUtils.transformHTML(blogEntry.getTitle()) + "\" removed.");
            } catch (BlogServiceException be) {
              throw new ServletException(be);
            }
          } else if (submit.equals("Publish")) {
            // this publishes the entry as-is (i.e. with the same
            // date/time it already has)
            try {
              blogEntry.setPublished(true);
              service.putBlogEntry(blogEntry);
              blog.info("Blog entry <a href=\"" + blogEntry.getLocalPermalink() + "\">" + blogEntry.getTitle() + "</a> published.");
            } catch (BlogServiceException be) {
              throw new ServletException(be);
            }
          }
View Full Code Here

Examples of net.sourceforge.pebble.domain.BlogService

    assertEquals(0, pageable.getNextPage());
  }

  public void testActionCalledWithDefaultParametersAndLessThanAPageOfResponses() throws Exception {
    int numberOfComments = ViewResponsesAction.PAGE_SIZE - 1;
    BlogService service = new BlogService();
    BlogEntry blogEntry = new BlogEntry(blog);
    service.putBlogEntry(blogEntry);
    blogEntry = service.getBlogEntry(blog, blogEntry.getId());

    for (int i = 0; i < numberOfComments; i++) {
      Comment comment = blogEntry.createComment("title", "body"+i, "author", "email", "website", "avatar", "127.0.0.1");
      blogEntry.addComment(comment);
    }
    service.putBlogEntry(blogEntry);

    for (Comment comment : blogEntry.getComments()) {
      comment.setApproved();
    }
    service.putBlogEntry(blogEntry);
   

    View view = action.process(request, response);
    assertTrue(view instanceof ResponsesView);
View Full Code Here

Examples of net.sourceforge.pebble.domain.BlogService

    super.setUp();
  }

  public void testProcess() throws Exception {
    // first of all add a blog entry to be edited
    BlogService service = new BlogService();
    BlogEntry newBlogEntry = new BlogEntry(blog);
    service.putBlogEntry(newBlogEntry);

    // now execute the action
    request.setParameter("entry", newBlogEntry.getId());
    View view = action.process(request, response);
View Full Code Here

Examples of net.sourceforge.pebble.domain.BlogService

    super.setUp();
  }

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

    request.setParameter("entry", "" + blogEntry.getId());
    request.setParameter("comment", "");
    request.setParameter("title", "Test Title");
    request.setParameter("commentBody", "Test Body");
    request.setParameter("author", "Test Author");
    request.setParameter("website", "http://www.somedomain.com");
    request.setParameter("avatar", "http://www.somedomain.com/avatar");
    request.setParameter("submit", "Add Comment");

    SecurityUtils.runAsBlogContributor();

    View view = action.process(request, response);
    assertTrue(view instanceof CommentConfirmationView);

    blogEntry = service.getBlogEntry(blog, blogEntry.getId());
    assertEquals(1, blogEntry.getComments().size());

    Comment comment = blogEntry.getComments().get(0);
    assertEquals("Test Title", comment.getTitle());
    assertEquals("Test Body", comment.getBody());
View Full Code Here

Examples of net.sourceforge.pebble.domain.BlogService

    assertEquals("http://www.somedomain.com", comment.getWebsite());
    assertEquals("http://www.somedomain.com/avatar", comment.getAvatar());
  }

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

    Comment comment1 = blogEntry.createComment("Title", "Body", "Author", "me@somedomain.com", "http://www.google.com", "http://graph.facebook.com/user/picture", "127.0.0.1");
    blogEntry.addComment(comment1);
    service.putBlogEntry(blogEntry);

    request.setParameter("entry", "" + blogEntry.getId());
    request.setParameter("comment", "" + comment1.getId());
    request.setParameter("title", "Test Title");
    request.setParameter("commentBody", "Test Body");
    request.setParameter("author", "Test Author");
    request.setParameter("website", "http://www.somedomain.com");
    request.setParameter("avatar", "http://www.somedomain.com/avatar");
    request.setParameter("submit", "Add Comment");

    SecurityUtils.runAsBlogContributor();

    View view = action.process(request, response);
    assertTrue(view instanceof CommentConfirmationView);

    blogEntry = service.getBlogEntry(blog, blogEntry.getId());
    assertEquals(2, blogEntry.getComments().size());

    Comment comment2 = blogEntry.getComments().get(1);
    assertEquals("Test Title", comment2.getTitle());
    assertEquals("Test Body", comment2.getBody());
View Full Code Here

Examples of net.sourceforge.pebble.domain.BlogService

    assertEquals("http://www.somedomain.com/avatar", comment2.getAvatar());
    assertEquals(comment1.getId(), comment2.getParent().getId());
  }

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

    request.setParameter("entry", "" + blogEntry.getId());
    request.setParameter("comment", "123456789");
    request.setParameter("title", "Test Title");
    request.setParameter("commentBody", "Test Body");
    request.setParameter("author", "Test Author");
    request.setParameter("website", "http://www.somedomain.com");
    request.setParameter("avatar", "http://www.somedomain.com/avatar");
    request.setParameter("submit", "Add Comment");

    SecurityUtils.runAsBlogContributor();

    View view = action.process(request, response);
    assertTrue(view instanceof CommentConfirmationView);

    blogEntry = service.getBlogEntry(blog, blogEntry.getId());
    assertEquals(1, blogEntry.getComments().size());

    Comment comment = blogEntry.getComments().get(0);
    assertEquals("Test Title", comment.getTitle());
    assertEquals("Test Body", comment.getBody());
View Full Code Here

Examples of net.sourceforge.pebble.domain.BlogService

    assertEquals("http://www.somedomain.com/avatar", comment.getAvatar());   
    assertNull(comment.getParent());
  }

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

    request.setParameter("entry", "" + blogEntry.getId());
    request.setParameter("comment", "");
    request.setParameter("title", "Test Title");
    request.setParameter("commentBody", "Test Body");
View Full Code Here

Examples of net.sourceforge.pebble.domain.BlogService

    assertTrue(view instanceof ConfirmCommentView);
    assertEquals(0, blogEntry.getComments().size());
  }

  public void testProcessWhenCommentsDisabled() throws Exception {
    BlogService service = new BlogService();
    BlogEntry blogEntry = new BlogEntry(blog);
    blogEntry.setCommentsEnabled(false);
    service.putBlogEntry(blogEntry);

    request.setParameter("entry", "" + blogEntry.getId());
    request.setParameter("comment", "");
    request.setParameter("title", "Test Title");
    request.setParameter("commentBody", "Test Body");
View Full Code Here

Examples of net.sourceforge.pebble.domain.BlogService

    super.setUp();
  }

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

    // now execute the action
    request.setParameter("entry", blogEntry.getId());
    request.setParameter("submit", "Publish");
    View view = action.process(request, response);
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.