Clover Coverage Report - Pebble 2.5-SNAPSHOT
Coverage timestamp: Sat Jun 12 2010 09:39:29 EST
37   82   6   6,17
0   59   0,16   6
6     1  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  ViewBlogEntryActionTest       Line # 16 37 0% 6 0 100% 1.0
 
  (10)
 
1    package net.sourceforge.pebble.web.action;
2   
3    import net.sourceforge.pebble.web.view.View;
4    import net.sourceforge.pebble.web.view.NotFoundView;
5    import net.sourceforge.pebble.web.view.impl.BlogEntryView;
6    import net.sourceforge.pebble.Constants;
7    import net.sourceforge.pebble.util.SecurityUtils;
8    import net.sourceforge.pebble.domain.BlogEntry;
9    import net.sourceforge.pebble.domain.BlogService;
10   
11    /**
12    * Tests for the ViewBlogEntryAction class.
13    *
14    * @author Simon Brown
15    */
 
16    public class ViewBlogEntryActionTest extends SingleBlogActionTestCase {
17   
 
18  10 toggle protected void setUp() throws Exception {
19  10 action = new ViewBlogEntryAction();
20   
21  10 super.setUp();
22    }
23   
 
24  2 toggle public void testViewBlogEntryWithNullId() throws Exception {
25  2 View view = action.process(request, response);
26   
27  2 assertTrue(view instanceof NotFoundView);
28    }
29   
 
30  2 toggle public void testViewNonExistentBlogEntry() throws Exception {
31  2 request.setParameter("entry", "1234567890123");
32  2 View view = action.process(request, response);
33   
34  2 assertTrue(view instanceof NotFoundView);
35    }
36   
 
37  2 toggle public void testPublishedViewBlogEntry() throws Exception {
38  2 BlogEntry blogEntry1 = new BlogEntry(blog);
39  2 blogEntry1.setPublished(true);
40  2 BlogService service = new BlogService();
41  2 service.putBlogEntry(blogEntry1);
42   
43  2 SecurityUtils.runAsUnauthenticated();
44  2 request.setParameter("entry", blogEntry1.getId());
45  2 View view = action.process(request, response);
46   
47  2 BlogEntry blogEntry2 = (BlogEntry)action.getModel().get(Constants.BLOG_ENTRY_KEY);
48  2 assertEquals(blogEntry1.getId(), blogEntry2.getId());
49  2 assertTrue(view instanceof BlogEntryView);
50    }
51   
 
52  2 toggle public void testUnpublishedViewBlogEntryAsAnonymousUser() throws Exception {
53  2 BlogEntry blogEntry1 = new BlogEntry(blog);
54  2 blogEntry1.setPublished(false);
55  2 BlogService service = new BlogService();
56  2 service.putBlogEntry(blogEntry1);
57   
58  2 SecurityUtils.runAsAnonymous();
59  2 request.setParameter("entry", blogEntry1.getId());
60  2 View view = action.process(request, response);
61   
62  2 BlogEntry blogEntry2 = (BlogEntry)action.getModel().get(Constants.BLOG_ENTRY_KEY);
63  2 assertNull(blogEntry2);
64  2 assertTrue(view instanceof NotFoundView);
65    }
66   
 
67  2 toggle public void testUnpublishedViewBlogEntryAsUserThatIsAuthorisedForBlog() throws Exception {
68  2 BlogEntry blogEntry1 = new BlogEntry(blog);
69  2 blogEntry1.setPublished(false);
70  2 BlogService service = new BlogService();
71  2 service.putBlogEntry(blogEntry1);
72   
73  2 SecurityUtils.runAsBlogContributor();
74  2 request.setParameter("entry", blogEntry1.getId());
75  2 View view = action.process(request, response);
76   
77  2 BlogEntry blogEntry2 = (BlogEntry)action.getModel().get(Constants.BLOG_ENTRY_KEY);
78  2 assertEquals(blogEntry1.getId(), blogEntry2.getId());
79  2 assertTrue(view instanceof BlogEntryView);
80    }
81   
82    }