Package net.sourceforge.pebble.domain

Examples of net.sourceforge.pebble.domain.BlogService


  /**
   * Tests that a permalink can be generated for a blog entry.
   */
  public void testBlogEntryPermalink() throws Exception {
    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 = "/";
    prefix += sdf.format(blogEntry.getDate());
View Full Code Here


  /**
   * Tests that a permalink can be generated for a blog entry when there are
   * duplicate titles for the same day.
   */
  public void testBlogEntryPermalinkForEntriesWithSameTitle() throws Exception {
    BlogService service = new BlogService();

    BlogEntry blogEntry1 = new BlogEntry(blog);
    blogEntry1.setTitle("A Title");
    service.putBlogEntry(blogEntry1);

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy'/'MM'/'dd'/'");
    sdf.setTimeZone(blog.getTimeZone());
    String prefix = "/";
    prefix += sdf.format(blogEntry1.getDate());
    String suffix = ".html";
    assertEquals(prefix + "a_title" + suffix, permalinkProvider.getPermalink(blogEntry1));

    // now add another with the same name
    BlogEntry blogEntry2 = new BlogEntry(blog);
    blogEntry2.setTitle("A Title");
    service.putBlogEntry(blogEntry2);

    assertEquals(prefix + "a_title" + suffix, permalinkProvider.getPermalink(blogEntry1));
    assertEquals(prefix + "a_title_" + blogEntry2.getId() + suffix, permalinkProvider.getPermalink(blogEntry2));
  }
View Full Code Here

  /**
   * Tests that the correct blog entry can be found from a permalink.
   */
  public void testGetBlogEntry() throws Exception {
    BlogService service = new BlogService();

    BlogEntry blogEntry1 = new BlogEntry(blog);
    blogEntry1.setTitle("A Title");
    service.putBlogEntry(blogEntry1);

    BlogEntry blogEntry2 = new BlogEntry(blog);
    blogEntry2.setTitle("Some other title");
    service.putBlogEntry(blogEntry2);

    BlogEntry blogEntry3 = new BlogEntry(blog);
    blogEntry3.setTitle("Some other itle");
    service.putBlogEntry(blogEntry3);

    String uri = permalinkProvider.getPermalink(blogEntry1);
    assertEquals(blogEntry1, permalinkProvider.getBlogEntry(uri));
    uri = permalinkProvider.getPermalink(blogEntry2);
    assertEquals(blogEntry2, permalinkProvider.getBlogEntry(uri));
View Full Code Here

  /**
   * Tests that the correct aggregated blog entry can be found from a permalink.
   */
  public void testGetAggregatedBlogEntry() throws Exception {
    BlogService service = new BlogService();

    BlogEntry blogEntry = new BlogEntry(blog);
    blogEntry.setTitle("A Title");
    blogEntry.setOriginalPermalink("http://www.someotherdomain.com/blog/abc.html");
    service.putBlogEntry(blogEntry);

    String uri = permalinkProvider.getPermalink(blogEntry);
    assertEquals(blogEntry, permalinkProvider.getBlogEntry(uri));
  }
View Full Code Here

   * @param uri   a relative URI
   * @return  a BlogEntry instance, or null if one can't be found
   */
  public BlogEntry getBlogEntry(String uri) {
    Blog blog = getBlog();
    BlogService service = new BlogService();
    try {
      return service.getBlogEntry(blog, uri.substring(12, uri.lastIndexOf(".")));
    } catch (BlogServiceException e) {
      return null;
    }
  }
View Full Code Here

   */
  public BlogEntry getBlogEntry(String uri) {
    // uri is of the form /1234567890123.html, so extract the 13-digit ID
    // and use it to find the correct blog entry
    Blog blog = getBlog();
    BlogService service = new BlogService();
    try {
      return service.getBlogEntry(blog, uri.substring(1, 14));
    } catch (BlogServiceException e) {
      return null;
    }
  }
View Full Code Here

   * 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

    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

    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

    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

TOP

Related Classes of net.sourceforge.pebble.domain.BlogService

Copyright © 2018 www.massapicom. 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.