|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| This report was generated with an evaluation server license. Purchase Clover or configure your license. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MarkUnpublishedListenerTest | Line # 48 | 63 | 0% | 9 | 0 | 100% |
1.0
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| (16) | |||
| Result | |||
|
0.1388889
|
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryAdded
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryAdded
|
1 PASS | |
|
0.1388889
|
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryAdded
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryAdded
|
1 PASS | |
|
0.125
|
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedByBlogPublisher
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedByBlogPublisher
|
1 PASS | |
|
0.125
|
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedByBlogPublisher
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedByBlogPublisher
|
1 PASS | |
|
0.11111111
|
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedForTitleProperty
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedForTitleProperty
|
1 PASS | |
|
0.11111111
|
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedForBodyProperty
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedForBodyProperty
|
1 PASS | |
|
0.11111111
|
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedForOriginalPermalinkProperty
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedForOriginalPermalinkProperty
|
1 PASS | |
|
0.11111111
|
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedForExcerptProperty
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedForExcerptProperty
|
1 PASS | |
|
0.11111111
|
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedByBlogContributor
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedByBlogContributor
|
1 PASS | |
|
0.11111111
|
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedForTitleProperty
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedForTitleProperty
|
1 PASS | |
|
0.11111111
|
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedForCommentsEnabledProperty
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedForCommentsEnabledProperty
|
1 PASS | |
|
0.11111111
|
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedForCommentsEnabledProperty
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedForCommentsEnabledProperty
|
1 PASS | |
|
0.11111111
|
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedByBlogContributor
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedByBlogContributor
|
1 PASS | |
|
0.11111111
|
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedForExcerptProperty
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedForExcerptProperty
|
1 PASS | |
|
0.11111111
|
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedForBodyProperty
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedForBodyProperty
|
1 PASS | |
|
0.11111111
|
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedForOriginalPermalinkProperty
net.sourceforge.pebble.event.blogentry.MarkUnpublishedListenerTest.testBlogEntryChangedForOriginalPermalinkProperty
|
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.event.blogentry; | |
| 33 | ||
| 34 | import net.sourceforge.pebble.domain.BlogEntry; | |
| 35 | import net.sourceforge.pebble.domain.SingleBlogTestCase; | |
| 36 | import net.sourceforge.pebble.util.SecurityUtils; | |
| 37 | import net.sourceforge.pebble.api.event.blogentry.BlogEntryEvent; | |
| 38 | ||
| 39 | import java.beans.PropertyChangeEvent; | |
| 40 | import java.util.ArrayList; | |
| 41 | import java.util.List; | |
| 42 | ||
| 43 | /** | |
| 44 | * Tests for the MarkUnpublishedListener class. | |
| 45 | * | |
| 46 | * @author Simon Brown | |
| 47 | */ | |
| 48 | public class MarkUnpublishedListenerTest extends SingleBlogTestCase { | |
| 49 | ||
| 50 | private MarkUnpublishedListener listener; | |
| 51 | private BlogEntry blogEntry; | |
| 52 | private BlogEntryEvent blogEntryEvent; | |
| 53 | ||
| 54 | /** | |
| 55 | * Common setup code. | |
| 56 | */ | |
| 57 | 16 |
protected void setUp() throws Exception { |
| 58 | 16 | super.setUp(); |
| 59 | ||
| 60 | 16 | listener = new MarkUnpublishedListener(); |
| 61 | 16 | blogEntry = new BlogEntry(blog); |
| 62 | 16 | SecurityUtils.runAsBlogContributor(); |
| 63 | } | |
| 64 | ||
| 65 | /** | |
| 66 | * Tests the blogEntryAdded() method. | |
| 67 | */ | |
| 68 | 2 |
public void testBlogEntryAdded() { |
| 69 | 2 | SecurityUtils.runAsBlogOwner(); |
| 70 | ||
| 71 | 2 | assertTrue(blogEntry.isUnpublished()); |
| 72 | 2 | blogEntryEvent = new BlogEntryEvent(blogEntry, BlogEntryEvent.BLOG_ENTRY_ADDED); |
| 73 | 2 | listener.blogEntryAdded(blogEntryEvent); |
| 74 | 2 | assertTrue(blogEntry.isUnpublished()); |
| 75 | ||
| 76 | 2 | SecurityUtils.runAsBlogContributor(); |
| 77 | 2 | blogEntryEvent = new BlogEntryEvent(blogEntry, BlogEntryEvent.BLOG_ENTRY_ADDED); |
| 78 | 2 | listener.blogEntryAdded(blogEntryEvent); |
| 79 | 2 | assertTrue(blogEntry.isUnpublished()); |
| 80 | } | |
| 81 | ||
| 82 | /** | |
| 83 | * Tests the blogEntryChanged() method, when a blog publisher changes | |
| 84 | * the blog entry. | |
| 85 | */ | |
| 86 | 2 |
public void testBlogEntryChangedByBlogPublisher() { |
| 87 | 2 | blogEntry.setPublished(true); |
| 88 | 2 | SecurityUtils.runAsBlogPublisher(); |
| 89 | ||
| 90 | 2 | List propertyChangeEvents = new ArrayList(); |
| 91 | 2 | PropertyChangeEvent pce = new PropertyChangeEvent(blogEntry, BlogEntry.TITLE_PROPERTY, null, null); |
| 92 | 2 | propertyChangeEvents.add(pce); |
| 93 | 2 | blogEntryEvent = new BlogEntryEvent(blogEntry, propertyChangeEvents); |
| 94 | 2 | listener.blogEntryChanged(blogEntryEvent); |
| 95 | 2 | assertTrue(blogEntry.isPublished()); |
| 96 | } | |
| 97 | ||
| 98 | /** | |
| 99 | * Tests the blogEntryChanged() method, when a blog contributor changes | |
| 100 | * the blog entry. | |
| 101 | */ | |
| 102 | 2 |
public void testBlogEntryChangedByBlogContributor() { |
| 103 | 2 | blogEntry.setPublished(true); |
| 104 | 2 | List propertyChangeEvents = new ArrayList(); |
| 105 | 2 | PropertyChangeEvent pce = new PropertyChangeEvent(blogEntry, BlogEntry.TITLE_PROPERTY, null, null); |
| 106 | 2 | propertyChangeEvents.add(pce); |
| 107 | 2 | blogEntryEvent = new BlogEntryEvent(blogEntry, propertyChangeEvents); |
| 108 | 2 | listener.blogEntryChanged(blogEntryEvent); |
| 109 | 2 | assertTrue(blogEntry.isUnpublished()); |
| 110 | } | |
| 111 | ||
| 112 | /** | |
| 113 | * Tests the blogEntryChanged() method when the title is changed. | |
| 114 | */ | |
| 115 | 2 |
public void testBlogEntryChangedForTitleProperty() { |
| 116 | 2 | blogEntry.setPublished(true); |
| 117 | 2 | List propertyChangeEvents = new ArrayList(); |
| 118 | 2 | PropertyChangeEvent pce = new PropertyChangeEvent(blogEntry, BlogEntry.TITLE_PROPERTY, null, null); |
| 119 | 2 | propertyChangeEvents.add(pce); |
| 120 | 2 | blogEntryEvent = new BlogEntryEvent(blogEntry, propertyChangeEvents); |
| 121 | 2 | listener.blogEntryChanged(blogEntryEvent); |
| 122 | 2 | assertTrue(blogEntry.isUnpublished()); |
| 123 | } | |
| 124 | ||
| 125 | /** | |
| 126 | * Tests the blogEntryChanged() method when the excerpt is changed. | |
| 127 | */ | |
| 128 | 2 |
public void testBlogEntryChangedForExcerptProperty() { |
| 129 | 2 | blogEntry.setPublished(true); |
| 130 | 2 | List propertyChangeEvents = new ArrayList(); |
| 131 | 2 | PropertyChangeEvent pce = new PropertyChangeEvent(blogEntry, BlogEntry.EXCERPT_PROPERTY, null, null); |
| 132 | 2 | propertyChangeEvents.add(pce); |
| 133 | 2 | blogEntryEvent = new BlogEntryEvent(blogEntry, propertyChangeEvents); |
| 134 | 2 | listener.blogEntryChanged(blogEntryEvent); |
| 135 | 2 | assertTrue(blogEntry.isUnpublished()); |
| 136 | } | |
| 137 | ||
| 138 | /** | |
| 139 | * Tests the blogEntryChanged() method when the body is changed. | |
| 140 | */ | |
| 141 | 2 |
public void testBlogEntryChangedForBodyProperty() { |
| 142 | 2 | blogEntry.setPublished(true); |
| 143 | 2 | List propertyChangeEvents = new ArrayList(); |
| 144 | 2 | PropertyChangeEvent pce = new PropertyChangeEvent(blogEntry, BlogEntry.BODY_PROPERTY, null, null); |
| 145 | 2 | propertyChangeEvents.add(pce); |
| 146 | 2 | blogEntryEvent = new BlogEntryEvent(blogEntry, propertyChangeEvents); |
| 147 | 2 | listener.blogEntryChanged(blogEntryEvent); |
| 148 | 2 | assertTrue(blogEntry.isUnpublished()); |
| 149 | } | |
| 150 | ||
| 151 | /** | |
| 152 | * Tests the blogEntryChanged() method when the original permalink is changed. | |
| 153 | */ | |
| 154 | 2 |
public void testBlogEntryChangedForOriginalPermalinkProperty() { |
| 155 | 2 | blogEntry.setPublished(true); |
| 156 | 2 | List propertyChangeEvents = new ArrayList(); |
| 157 | 2 | PropertyChangeEvent pce = new PropertyChangeEvent(blogEntry, BlogEntry.ORIGINAL_PERMALINK_PROPERTY, null, null); |
| 158 | 2 | propertyChangeEvents.add(pce); |
| 159 | 2 | blogEntryEvent = new BlogEntryEvent(blogEntry, propertyChangeEvents); |
| 160 | 2 | listener.blogEntryChanged(blogEntryEvent); |
| 161 | 2 | assertTrue(blogEntry.isUnpublished()); |
| 162 | } | |
| 163 | ||
| 164 | /** | |
| 165 | * Tests the blogEntryChanged() method when the comments enabled is changed. | |
| 166 | */ | |
| 167 | 2 |
public void testBlogEntryChangedForCommentsEnabledProperty() { |
| 168 | 2 | blogEntry.setPublished(true); |
| 169 | 2 | List propertyChangeEvents = new ArrayList(); |
| 170 | 2 | PropertyChangeEvent pce = new PropertyChangeEvent(blogEntry, BlogEntry.COMMENTS_ENABLED_PROPERTY, null, null); |
| 171 | 2 | propertyChangeEvents.add(pce); |
| 172 | 2 | blogEntryEvent = new BlogEntryEvent(blogEntry, propertyChangeEvents); |
| 173 | 2 | listener.blogEntryChanged(blogEntryEvent); |
| 174 | 2 | assertTrue(blogEntry.isPublished()); |
| 175 | } | |
| 176 | ||
| 177 | } | |
|
||||||||||||