|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| This report was generated with an evaluation server license. Purchase Clover or configure your license. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ManageBlogEntryActionTest | Line # 46 | 27 | 0% | 5 | 0 | 100% |
1.0
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| (8) | |||
| Result | |||
|
0.3125
|
net.sourceforge.pebble.web.action.ManageBlogEntryActionTest.testPublishBlogEntry
net.sourceforge.pebble.web.action.ManageBlogEntryActionTest.testPublishBlogEntry
|
1 PASS | |
|
0.3125
|
net.sourceforge.pebble.web.action.ManageBlogEntryActionTest.testUnpublishBlogEntry
net.sourceforge.pebble.web.action.ManageBlogEntryActionTest.testUnpublishBlogEntry
|
1 PASS | |
|
0.3125
|
net.sourceforge.pebble.web.action.ManageBlogEntryActionTest.testUnpublishBlogEntry
net.sourceforge.pebble.web.action.ManageBlogEntryActionTest.testUnpublishBlogEntry
|
1 PASS | |
|
0.3125
|
net.sourceforge.pebble.web.action.ManageBlogEntryActionTest.testPublishBlogEntry
net.sourceforge.pebble.web.action.ManageBlogEntryActionTest.testPublishBlogEntry
|
1 PASS | |
|
0.15625
|
net.sourceforge.pebble.web.action.ManageBlogEntryActionTest.testOnlyBlogOwnersHaveAccessToApprove
net.sourceforge.pebble.web.action.ManageBlogEntryActionTest.testOnlyBlogOwnersHaveAccessToApprove
|
1 PASS | |
|
0.15625
|
net.sourceforge.pebble.web.action.ManageBlogEntryActionTest.testOnlyBlogOwnersHaveAccessToApprove
net.sourceforge.pebble.web.action.ManageBlogEntryActionTest.testOnlyBlogOwnersHaveAccessToApprove
|
1 PASS | |
|
0.125
|
net.sourceforge.pebble.web.action.ManageBlogEntryActionTest.testDefaultRoleIsBlogOwner
net.sourceforge.pebble.web.action.ManageBlogEntryActionTest.testDefaultRoleIsBlogOwner
|
1 PASS | |
|
0.125
|
net.sourceforge.pebble.web.action.ManageBlogEntryActionTest.testDefaultRoleIsBlogOwner
net.sourceforge.pebble.web.action.ManageBlogEntryActionTest.testDefaultRoleIsBlogOwner
|
1 PASS | |
| 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.web.action; | |
| 33 | ||
| 34 | import net.sourceforge.pebble.Constants; | |
| 35 | import net.sourceforge.pebble.domain.BlogEntry; | |
| 36 | import net.sourceforge.pebble.domain.BlogService; | |
| 37 | import net.sourceforge.pebble.domain.State; | |
| 38 | import net.sourceforge.pebble.web.view.View; | |
| 39 | import net.sourceforge.pebble.web.view.impl.PublishBlogEntryView; | |
| 40 | ||
| 41 | /** | |
| 42 | * Tests for the ManageBlogEntryAction class. | |
| 43 | * | |
| 44 | * @author Simon Brown | |
| 45 | */ | |
| 46 | public class ManageBlogEntryActionTest extends SecureActionTestCase { | |
| 47 | ||
| 48 | 8 |
protected void setUp() throws Exception { |
| 49 | 8 | action = new ManageBlogEntryAction(); |
| 50 | ||
| 51 | 8 | super.setUp(); |
| 52 | } | |
| 53 | ||
| 54 | 2 |
public void testPublishBlogEntry() throws Exception { |
| 55 | 2 | BlogService service = new BlogService(); |
| 56 | 2 | BlogEntry blogEntry = new BlogEntry(blog); |
| 57 | 2 | blogEntry.setPublished(false); |
| 58 | 2 | service.putBlogEntry(blogEntry); |
| 59 | ||
| 60 | // now execute the action | |
| 61 | 2 | request.setParameter("entry", blogEntry.getId()); |
| 62 | 2 | request.setParameter("submit", "Publish"); |
| 63 | 2 | View view = action.process(request, response); |
| 64 | ||
| 65 | 2 | assertTrue(blogEntry.isUnpublished()); |
| 66 | 2 | assertTrue(view instanceof PublishBlogEntryView); |
| 67 | } | |
| 68 | ||
| 69 | 2 |
public void testUnpublishBlogEntry() throws Exception { |
| 70 | 2 | BlogService service = new BlogService(); |
| 71 | 2 | BlogEntry blogEntry = new BlogEntry(blog); |
| 72 | 2 | blogEntry.setPublished(true); |
| 73 | 2 | service.putBlogEntry(blogEntry); |
| 74 | ||
| 75 | // now execute the action | |
| 76 | 2 | request.setParameter("entry", blogEntry.getId()); |
| 77 | 2 | request.setParameter("submit", "Unpublish"); |
| 78 | 2 | View view = action.process(request, response); |
| 79 | ||
| 80 | 2 | assertTrue(blogEntry.isPublished()); |
| 81 | 2 | assertTrue(view instanceof PublishBlogEntryView); |
| 82 | } | |
| 83 | ||
| 84 | /** | |
| 85 | * Test that only blog owners can approve comments. | |
| 86 | */ | |
| 87 | 2 |
public void testDefaultRoleIsBlogOwner() { |
| 88 | 2 | String roles[] = action.getRoles(request); |
| 89 | 2 | assertEquals(1, roles.length); |
| 90 | 2 | assertEquals(Constants.BLOG_OWNER_ROLE, roles[0]); |
| 91 | } | |
| 92 | ||
| 93 | /** | |
| 94 | * Test that only blog owners can approve comments. | |
| 95 | */ | |
| 96 | 2 |
public void testOnlyBlogOwnersHaveAccessToApprove() { |
| 97 | 2 | request.setParameter("submit", "Approve"); |
| 98 | 2 | String roles[] = action.getRoles(request); |
| 99 | 2 | assertEquals(1, roles.length); |
| 100 | 2 | assertEquals(Constants.BLOG_OWNER_ROLE, roles[0]); |
| 101 | } | |
| 102 | ||
| 103 | } | |
|
||||||||||||