Clover Coverage Report - Pebble 2.5-SNAPSHOT
Coverage timestamp: Sat Jun 12 2010 09:39:29 EST
30   96   2   15
0   46   0,07   2
2     1  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  SocialBookmarksDecoratorTest       Line # 46 30 0% 2 0 100% 1.0
 
  (2)
 
1    /*
2    * Copyright (c) 2003-2006, Simon Brown
3    * All rights reserved.
4    *
5    * Redistribution and use in source and binary forms, with or without
6    * modification, are permitted provided that the following conditions are met:
7    *
8    * - Redistributions of source code must retain the above copyright
9    * notice, this list of conditions and the following disclaimer.
10    *
11    * - Redistributions in binary form must reproduce the above copyright
12    * notice, this list of conditions and the following disclaimer in
13    * the documentation and/or other materials provided with the
14    * distribution.
15    *
16    * - Neither the name of Pebble nor the names of its contributors may
17    * be used to endorse or promote products derived from this software
18    * without specific prior written permission.
19    *
20    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22    * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23    * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24    * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25    * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26    * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27    * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28    * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30    * POSSIBILITY OF SUCH DAMAGE.
31    */
32    package net.sourceforge.pebble.decorator;
33   
34    import java.util.Date;
35    import net.sourceforge.pebble.domain.BlogEntry;
36    import net.sourceforge.pebble.domain.Category;
37    import net.sourceforge.pebble.domain.SingleBlogTestCase;
38    import net.sourceforge.pebble.api.decorator.ContentDecorator;
39    import net.sourceforge.pebble.api.decorator.ContentDecoratorContext;
40   
41    /**
42    * Tests for the SocialBookmarksDecorator class.
43    *
44    * @author Alexander Zagniotov
45    */
 
46    public class SocialBookmarksDecoratorTest extends SingleBlogTestCase {
47   
48    private ContentDecorator decorator;
49    private BlogEntry blogEntry;
50    private ContentDecoratorContext context;
51   
 
52  2 toggle protected void setUp() throws Exception {
53  2 super.setUp();
54   
55  2 blogEntry = new BlogEntry(blog);
56  2 decorator = new SocialBookmarksDecorator();
57  2 context = new ContentDecoratorContext();
58    }
59   
60    /**
61    * Tests that a blog entry with bookmarks gets modified, when output to a HTML page.
62    */
 
63  2 toggle public void testBlogEntryHasBookmarksAndMediaIsHtml() throws Exception {
64  2 Date date = new Date();
65  2 long now = 1;
66  2 date.setTime(now);
67   
68  2 blogEntry.setDate(date);
69  2 blogEntry.setTitle("Bombastic Post Title");
70  2 blogEntry.setExcerpt("Excerpt - here is some text");
71  2 blogEntry.setBody("Body - here is some text");
72   
73  2 context.setMedia(ContentDecoratorContext.HTML_PAGE);
74  2 decorator.decorate(context, blogEntry);
75   
76  2 StringBuffer bookmarks = new StringBuffer();
77  2 bookmarks.append("<div class=\"tags\"><span>Social Bookmarks : </span>&nbsp;");
78  2 bookmarks.append("<a href=\"http://slashdot.org/bookmark.pl?url=http://www.yourdomain.com/blog/1970/01/01/1.html&amp;title=Bombastic+Post+Title\" target=\"_blank\" title=\"Add this post to Slash Dot\"><img src=\"common/images/slashdot.png\" alt=\"Add this post to Slashdot\" border=\"0\" /></a>&nbsp;&nbsp;&nbsp;&nbsp;");
79  2 bookmarks.append("<a href=\"http://digg.com/submit?url=http://www.yourdomain.com/blog/1970/01/01/1.html&amp;title=Bombastic+Post+Title\" target=\"_blank\" title=\"Digg this post\"><img src=\"common/images/digg.png\" alt=\"Add this post to Digg\" border=\"0\" /></a>&nbsp;&nbsp;&nbsp;&nbsp;");
80  2 bookmarks.append("<a href=\"http://reddit.com/submit?url=http://www.yourdomain.com/blog/1970/01/01/1.html&amp;title=Bombastic+Post+Title\" target=\"_blank\" title=\"Add this post to Reddit\"><img src=\"common/images/reddit.png\" alt=\"Add this post to Reddit\" border=\"0\" /></a>&nbsp;&nbsp;&nbsp;&nbsp;");
81  2 bookmarks.append("<a href=\"http://del.icio.us/post?url=http://www.yourdomain.com/blog/1970/01/01/1.html&amp;title=Bombastic+Post+Title\" target=\"_blank\" title=\"Save this post to Del.icio.us\"><img src=\"common/images/delicious.png\" alt=\"Add this post to Delicious\" border=\"0\" /></a>&nbsp;&nbsp;&nbsp;&nbsp;");
82  2 bookmarks.append("<a href=\"http://www.stumbleupon.com/submit?url=http://www.yourdomain.com/blog/1970/01/01/1.html&amp;title=Bombastic+Post+Title\" target=\"_blank\" title=\"Stumble this post\"><img src=\"common/images/stumbleupon.png\" alt=\"Add this post to Stumble it\" border=\"0\" /></a>&nbsp;&nbsp;&nbsp;&nbsp;");
83  2 bookmarks.append("<a href=\"http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http://www.yourdomain.com/blog/1970/01/01/1.html&amp;title=Bombastic+Post+Title\" target=\"_blank\" title=\"Add this post to Google\"><img src=\"common/images/google.png\" alt=\"Add this post to Google\" border=\"0\" /></a>&nbsp;&nbsp;&nbsp;&nbsp;");
84  2 bookmarks.append("<a href=\"http://technorati.com/faves?add=http://www.yourdomain.com/blog/1970/01/01/1.html\" target=\"_blank\" title=\"Add this post to Technorati\"><img src=\"common/images/technorati.png\" alt=\"Add this post to Technorati\" border=\"0\" /></a>&nbsp;&nbsp;&nbsp;&nbsp;");
85  2 bookmarks.append("<a href=\"http://www.bloglines.com/sub/http://www.yourdomain.com/blog/1970/01/01/1.html\" target=\"_blank\" title=\"Add this post to Bloglines\"><img src=\"common/images/bloglines.png\" alt=\"Add this post to Bloglines\" border=\"0\" /></a>&nbsp;&nbsp;&nbsp;&nbsp;");
86  2 bookmarks.append("<a href=\"http://www.facebook.com/share.php?u=http://www.yourdomain.com/blog/1970/01/01/1.html\" target=\"_blank\" title=\"Add this post to Facebook\"><img src=\"common/images/facebook.png\" alt=\"Add this post to Facebook\" border=\"0\" /></a>&nbsp;&nbsp;&nbsp;&nbsp;");
87  2 bookmarks.append("<a href=\"http://www.furl.net/storeIt.jsp?u=http://www.yourdomain.com/blog/1970/01/01/1.html&amp;t=Bombastic+Post+Title\" target=\"_blank\" title=\"Add this post to Furl\"><img src=\"common/images/furl.png\" alt=\"Add this post to Furl\" border=\"0\" /></a>&nbsp;&nbsp;&nbsp;&nbsp;");
88  2 bookmarks.append("<a href=\"https://favorites.live.com/quickadd.aspx?mkt=en-us&amp;url=http://www.yourdomain.com/blog/1970/01/01/1.html&amp;title=Bombastic+Post+Title\" target=\"_blank\" title=\"Add this post to Windows Live\"><img src=\"common/images/windowslive.png\" alt=\"Add this post to Windows Live\" border=\"0\" /></a>&nbsp;&nbsp;&nbsp;&nbsp;");
89  2 bookmarks.append("<a href=\"http://bookmarks.yahoo.com/toolbar/savebm?opener=tb&amp;u=http://www.yourdomain.com/blog/1970/01/01/1.html&amp;t=Bombastic+Post+Title\" target=\"_blank\" title=\"Add this post to Yahoo!\"><img src=\"common/images/yahoo.png\" alt=\"Add this post to Yahoo!\" border=\"0\" /></a>");
90  2 bookmarks.append("</div>");
91   
92  2 assertEquals("Excerpt - here is some text" + bookmarks, blogEntry.getExcerpt());
93  2 assertEquals("Body - here is some text" + bookmarks, blogEntry.getBody());
94    }
95   
96    }