|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| This report was generated with an evaluation server license. Purchase Clover or configure your license. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ContentSpamListenerTest | Line # 46 | 140 | 0% | 17 | 0 | 100% |
1.0
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| (32) | |||
| Result | |||
|
0.07643312
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpamInAllField
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpamInAllField
|
1 PASS | |
|
0.07643312
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpamInAllFields
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpamInAllFields
|
1 PASS | |
|
0.07643312
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpamInAllField
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpamInAllField
|
1 PASS | |
|
0.07643312
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpamInAllFields
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpamInAllFields
|
1 PASS | |
|
0.070063695
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpamAndThreshold
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpamAndThreshold
|
1 PASS | |
|
0.070063695
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpamAndThreshold
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpamAndThreshold
|
1 PASS | |
|
0.070063695
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpamAndThreshold
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpamAndThreshold
|
1 PASS | |
|
0.070063695
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpamAndThreshold
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpamAndThreshold
|
1 PASS | |
|
0.05732484
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpaminUpperCase
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpaminUpperCase
|
1 PASS | |
|
0.05732484
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpamInTitleField
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpamInTitleField
|
1 PASS | |
|
0.05732484
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpamInUpperCase
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpamInUpperCase
|
1 PASS | |
|
0.05732484
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpamInBlogNameField
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpamInBlogNameField
|
1 PASS | |
|
0.05732484
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpamInUpperCase
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpamInUpperCase
|
1 PASS | |
|
0.05732484
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpamInWebsiteField
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpamInWebsiteField
|
1 PASS | |
|
0.05732484
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpamInAuthorField
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpamInAuthorField
|
1 PASS | |
|
0.05732484
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpamInTitleField
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpamInTitleField
|
1 PASS | |
|
0.05732484
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpaminUpperCase
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpaminUpperCase
|
1 PASS | |
|
0.05732484
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpamInBlogUrlField
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpamInBlogUrlField
|
1 PASS | |
|
0.05732484
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpamInAuthorField
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpamInAuthorField
|
1 PASS | |
|
0.05732484
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpamInWebsiteField
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpamInWebsiteField
|
1 PASS | |
|
0.05732484
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpamInBlogNameField
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpamInBlogNameField
|
1 PASS | |
|
0.05732484
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpamInTitleField
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpamInTitleField
|
1 PASS | |
|
0.05732484
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpamInBlogUrlField
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpamInBlogUrlField
|
1 PASS | |
|
0.05732484
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpamInTitleField
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpamInTitleField
|
1 PASS | |
|
0.05732484
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpam
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpam
|
1 PASS | |
|
0.05732484
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpam
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpam
|
1 PASS | |
|
0.05732484
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpam
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithSomeContentSpam
|
1 PASS | |
|
0.05732484
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpam
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithSomeContentSpam
|
1 PASS | |
|
0.03821656
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithNoContentSpam
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithNoContentSpam
|
1 PASS | |
|
0.03821656
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithNoContentSpam
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testCommentWithNoContentSpam
|
1 PASS | |
|
0.03821656
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithNoContentSpam
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithNoContentSpam
|
1 PASS | |
|
0.03821656
|
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithNoContentSpam
net.sourceforge.pebble.event.response.ContentSpamListenerTest.testTrackBackWithNoContentSpam
|
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.response; | |
| 33 | ||
| 34 | import net.sourceforge.pebble.domain.Comment; | |
| 35 | import net.sourceforge.pebble.domain.SingleBlogTestCase; | |
| 36 | import net.sourceforge.pebble.domain.TrackBack; | |
| 37 | import net.sourceforge.pebble.domain.BlogEntry; | |
| 38 | import net.sourceforge.pebble.api.event.comment.CommentEvent; | |
| 39 | import net.sourceforge.pebble.api.event.trackback.TrackBackEvent; | |
| 40 | ||
| 41 | /** | |
| 42 | * Tests for the ContentSpamListener class. | |
| 43 | * | |
| 44 | * @author Simon Brown | |
| 45 | */ | |
| 46 | public class ContentSpamListenerTest extends SingleBlogTestCase { | |
| 47 | ||
| 48 | private ContentSpamListener listener; | |
| 49 | private Comment comment; | |
| 50 | private CommentEvent commentEvent; | |
| 51 | private TrackBack trackBack; | |
| 52 | private TrackBackEvent trackBackEvent; | |
| 53 | ||
| 54 | /** | |
| 55 | * Common setup code. | |
| 56 | */ | |
| 57 | 32 |
protected void setUp() throws Exception { |
| 58 | 32 | super.setUp(); |
| 59 | ||
| 60 | 32 | blog.getPluginProperties().setProperty(ContentSpamListener.REGEX_LIST_KEY, "test"); |
| 61 | 32 | listener = new ContentSpamListener(); |
| 62 | 32 | BlogEntry blogEntry = new BlogEntry(blog); |
| 63 | 32 | comment = blogEntry.createComment("Title", "Body", "Author", "me@somedomain.com", "http://www.google.com", "127.0.0.1"); |
| 64 | 32 | commentEvent = new CommentEvent(comment, CommentEvent.COMMENT_ADDED); |
| 65 | 32 | trackBack = blogEntry.createTrackBack("Title", "Excerpt", "url", "blogName", "127.0.0.1"); |
| 66 | 32 | trackBackEvent = new TrackBackEvent(trackBack, TrackBackEvent.TRACKBACK_ADDED); |
| 67 | } | |
| 68 | ||
| 69 | /** | |
| 70 | * Tests a comment with no content spam. | |
| 71 | */ | |
| 72 | 2 |
public void testCommentWithNoContentSpam() { |
| 73 | 2 | listener.commentAdded(commentEvent); |
| 74 | 2 | assertTrue(comment.isApproved()); |
| 75 | ||
| 76 | 2 | blog.getPluginProperties().setProperty(ContentSpamListener.REGEX_LIST_KEY, "casinos, poker, drugs"); |
| 77 | 2 | listener.commentAdded(commentEvent); |
| 78 | 2 | assertTrue(comment.isApproved()); |
| 79 | } | |
| 80 | ||
| 81 | /** | |
| 82 | * Tests a comment with some content spam. | |
| 83 | */ | |
| 84 | 2 |
public void testCommentWithSomeContentSpam() { |
| 85 | 2 | comment.setBody("Here is some junk about poker and online casinos."); |
| 86 | 2 | listener.commentAdded(commentEvent); |
| 87 | 2 | assertTrue(comment.isApproved()); |
| 88 | 2 | assertEquals(0, comment.getSpamScore()); |
| 89 | ||
| 90 | 2 | blog.getPluginProperties().setProperty(ContentSpamListener.REGEX_LIST_KEY, "casinos, poker, drugs"); |
| 91 | 2 | listener.commentAdded(commentEvent); |
| 92 | 2 | assertTrue(comment.isPending()); |
| 93 | 2 | assertEquals(1, comment.getSpamScore()); |
| 94 | } | |
| 95 | ||
| 96 | /** | |
| 97 | * Tests a comment with some content spam in upper case. | |
| 98 | */ | |
| 99 | 2 |
public void testCommentWithSomeContentSpamInUpperCase() { |
| 100 | 2 | comment.setBody("Here is some junk about POKER and ONLINE CASINOS."); |
| 101 | 2 | listener.commentAdded(commentEvent); |
| 102 | 2 | assertTrue(comment.isApproved()); |
| 103 | 2 | assertEquals(0, comment.getSpamScore()); |
| 104 | ||
| 105 | 2 | blog.getPluginProperties().setProperty(ContentSpamListener.REGEX_LIST_KEY, "casinos, poker, drugs"); |
| 106 | 2 | listener.commentAdded(commentEvent); |
| 107 | 2 | assertTrue(comment.isPending()); |
| 108 | 2 | assertEquals(1, comment.getSpamScore()); |
| 109 | } | |
| 110 | ||
| 111 | /** | |
| 112 | * Tests a comment with some content spam and a custom threshold. | |
| 113 | */ | |
| 114 | 2 |
public void testCommentWithSomeContentSpamAndThreshold() { |
| 115 | 2 | blog.getPluginProperties().setProperty(ContentSpamListener.REGEX_LIST_KEY, "poker"); |
| 116 | 2 | blog.getPluginProperties().setProperty(ContentSpamListener.THRESHOLD_KEY, "1"); |
| 117 | 2 | comment.setBody("Here is some junk about poker and online casinos."); |
| 118 | 2 | listener.commentAdded(commentEvent); |
| 119 | 2 | assertTrue(comment.isApproved()); |
| 120 | 2 | assertEquals(0, comment.getSpamScore()); |
| 121 | ||
| 122 | 2 | blog.getPluginProperties().setProperty(ContentSpamListener.REGEX_LIST_KEY, "casinos, poker, drugs"); |
| 123 | 2 | listener.commentAdded(commentEvent); |
| 124 | 2 | assertTrue(comment.isPending()); |
| 125 | 2 | assertEquals(1, comment.getSpamScore()); |
| 126 | } | |
| 127 | ||
| 128 | /** | |
| 129 | * Tests a comment with some content spam in the author field. | |
| 130 | */ | |
| 131 | 2 |
public void testCommentWithSomeContentSpamInAuthorField() { |
| 132 | 2 | comment.setAuthor("online casinos"); |
| 133 | 2 | listener.commentAdded(commentEvent); |
| 134 | 2 | assertTrue(comment.isApproved()); |
| 135 | 2 | assertEquals(0, comment.getSpamScore()); |
| 136 | ||
| 137 | 2 | blog.getPluginProperties().setProperty(ContentSpamListener.REGEX_LIST_KEY, "casinos, poker, drugs"); |
| 138 | 2 | listener.commentAdded(commentEvent); |
| 139 | 2 | assertTrue(comment.isPending()); |
| 140 | 2 | assertEquals(1, comment.getSpamScore()); |
| 141 | } | |
| 142 | ||
| 143 | /** | |
| 144 | * Tests a comment with some content spam in the title field. | |
| 145 | */ | |
| 146 | 2 |
public void testCommentWithSomeContentSpamInTitleField() { |
| 147 | 2 | comment.setTitle("online casinos"); |
| 148 | 2 | listener.commentAdded(commentEvent); |
| 149 | 2 | assertTrue(comment.isApproved()); |
| 150 | 2 | assertEquals(0, comment.getSpamScore()); |
| 151 | ||
| 152 | 2 | blog.getPluginProperties().setProperty(ContentSpamListener.REGEX_LIST_KEY, "casinos, poker, drugs"); |
| 153 | 2 | listener.commentAdded(commentEvent); |
| 154 | 2 | assertTrue(comment.isPending()); |
| 155 | 2 | assertEquals(1, comment.getSpamScore()); |
| 156 | } | |
| 157 | ||
| 158 | /** | |
| 159 | * Tests a comment with some content spam in the title field. | |
| 160 | */ | |
| 161 | 2 |
public void testCommentWithSomeContentSpamInWebsiteField() { |
| 162 | 2 | comment.setWebsite("http://online.casinos.com"); |
| 163 | 2 | listener.commentAdded(commentEvent); |
| 164 | 2 | assertTrue(comment.isApproved()); |
| 165 | 2 | assertEquals(0, comment.getSpamScore()); |
| 166 | ||
| 167 | 2 | blog.getPluginProperties().setProperty(ContentSpamListener.REGEX_LIST_KEY, "casinos, poker, drugs"); |
| 168 | 2 | listener.commentAdded(commentEvent); |
| 169 | 2 | assertTrue(comment.isPending()); |
| 170 | 2 | assertEquals(1, comment.getSpamScore()); |
| 171 | } | |
| 172 | ||
| 173 | /** | |
| 174 | * Tests a comment with some content spam in all fields. | |
| 175 | */ | |
| 176 | 2 |
public void testCommentWithSomeContentSpamInAllFields() { |
| 177 | 2 | comment.setAuthor("online casinos"); |
| 178 | 2 | comment.setTitle("online casinos"); |
| 179 | 2 | comment.setWebsite("http://online.casinos.com"); |
| 180 | 2 | comment.setBody("Here is some junk about poker and online casinos."); |
| 181 | 2 | listener.commentAdded(commentEvent); |
| 182 | 2 | assertTrue(comment.isApproved()); |
| 183 | 2 | assertEquals(0, comment.getSpamScore()); |
| 184 | ||
| 185 | 2 | blog.getPluginProperties().setProperty(ContentSpamListener.REGEX_LIST_KEY, "casinos, poker, drugs"); |
| 186 | 2 | listener.commentAdded(commentEvent); |
| 187 | 2 | assertTrue(comment.isPending()); |
| 188 | 2 | assertEquals(4, comment.getSpamScore()); |
| 189 | } | |
| 190 | ||
| 191 | /** | |
| 192 | * Tests a TrackBack with no content spam. | |
| 193 | */ | |
| 194 | 2 |
public void testTrackBackWithNoContentSpam() { |
| 195 | 2 | listener.trackBackAdded(trackBackEvent); |
| 196 | 2 | assertTrue(trackBack.isApproved()); |
| 197 | ||
| 198 | 2 | blog.getPluginProperties().setProperty(ContentSpamListener.REGEX_LIST_KEY, "casinos, poker, drugs"); |
| 199 | 2 | listener.trackBackAdded(trackBackEvent); |
| 200 | 2 | assertTrue(trackBack.isApproved()); |
| 201 | } | |
| 202 | ||
| 203 | /** | |
| 204 | * Tests a TrackBack with some content spam. | |
| 205 | */ | |
| 206 | 2 |
public void testTrackBackWithSomeContentSpam() { |
| 207 | 2 | trackBack.setExcerpt("Here is some junk about poker and online casinos."); |
| 208 | 2 | listener.trackBackAdded(trackBackEvent); |
| 209 | 2 | assertTrue(trackBack.isApproved()); |
| 210 | 2 | assertEquals(0, trackBack.getSpamScore()); |
| 211 | ||
| 212 | 2 | blog.getPluginProperties().setProperty(ContentSpamListener.REGEX_LIST_KEY, "casinos, poker, drugs"); |
| 213 | 2 | listener.trackBackAdded(trackBackEvent); |
| 214 | 2 | assertTrue(trackBack.isPending()); |
| 215 | 2 | assertEquals(1, trackBack.getSpamScore()); |
| 216 | } | |
| 217 | ||
| 218 | /** | |
| 219 | * Tests a TrackBack with some content spam in upper case. | |
| 220 | */ | |
| 221 | 2 |
public void testTrackBackWithSomeContentSpaminUpperCase() { |
| 222 | 2 | trackBack.setExcerpt("Here is some junk about POKER and ONLINE CASINOS."); |
| 223 | 2 | listener.trackBackAdded(trackBackEvent); |
| 224 | 2 | assertTrue(trackBack.isApproved()); |
| 225 | 2 | assertEquals(0, trackBack.getSpamScore()); |
| 226 | ||
| 227 | 2 | blog.getPluginProperties().setProperty(ContentSpamListener.REGEX_LIST_KEY, "casinos, poker, drugs"); |
| 228 | 2 | listener.trackBackAdded(trackBackEvent); |
| 229 | 2 | assertTrue(trackBack.isPending()); |
| 230 | 2 | assertEquals(1, trackBack.getSpamScore()); |
| 231 | } | |
| 232 | ||
| 233 | /** | |
| 234 | * Tests a TrackBack with some content spam and a custom threshold. | |
| 235 | */ | |
| 236 | 2 |
public void testTrackBackWithSomeContentSpamAndThreshold() { |
| 237 | 2 | blog.getPluginProperties().setProperty(ContentSpamListener.REGEX_LIST_KEY, "poker"); |
| 238 | 2 | blog.getPluginProperties().setProperty(ContentSpamListener.THRESHOLD_KEY, "1"); |
| 239 | 2 | trackBack.setExcerpt("Here is some junk about poker and online casinos."); |
| 240 | 2 | listener.trackBackAdded(trackBackEvent); |
| 241 | 2 | assertTrue(trackBack.isApproved()); |
| 242 | 2 | assertEquals(0, trackBack.getSpamScore()); |
| 243 | ||
| 244 | 2 | blog.getPluginProperties().setProperty(ContentSpamListener.REGEX_LIST_KEY, "casinos, poker, drugs"); |
| 245 | 2 | listener.trackBackAdded(trackBackEvent); |
| 246 | 2 | assertTrue(trackBack.isPending()); |
| 247 | 2 | assertEquals(1, trackBack.getSpamScore()); |
| 248 | } | |
| 249 | ||
| 250 | /** | |
| 251 | * Tests a TrackBack with some content spam in the blog name field. | |
| 252 | */ | |
| 253 | 2 |
public void testTrackBackWithSomeContentSpamInBlogNameField() { |
| 254 | 2 | trackBack.setBlogName("online casinos"); |
| 255 | 2 | listener.trackBackAdded(trackBackEvent); |
| 256 | 2 | assertTrue(trackBack.isApproved()); |
| 257 | 2 | assertEquals(0, trackBack.getSpamScore()); |
| 258 | ||
| 259 | 2 | blog.getPluginProperties().setProperty(ContentSpamListener.REGEX_LIST_KEY, "casinos, poker, drugs"); |
| 260 | 2 | listener.trackBackAdded(trackBackEvent); |
| 261 | 2 | assertTrue(trackBack.isPending()); |
| 262 | 2 | assertEquals(1, trackBack.getSpamScore()); |
| 263 | } | |
| 264 | ||
| 265 | /** | |
| 266 | * Tests a TrackBack with some content spam in the title field. | |
| 267 | */ | |
| 268 | 2 |
public void testTrackBackWithSomeContentSpamInTitleField() { |
| 269 | 2 | trackBack.setTitle("online casinos"); |
| 270 | 2 | listener.trackBackAdded(trackBackEvent); |
| 271 | 2 | assertTrue(trackBack.isApproved()); |
| 272 | 2 | assertEquals(0, trackBack.getSpamScore()); |
| 273 | ||
| 274 | 2 | blog.getPluginProperties().setProperty(ContentSpamListener.REGEX_LIST_KEY, "casinos, poker, drugs"); |
| 275 | 2 | listener.trackBackAdded(trackBackEvent); |
| 276 | 2 | assertTrue(trackBack.isPending()); |
| 277 | 2 | assertEquals(1, trackBack.getSpamScore()); |
| 278 | } | |
| 279 | ||
| 280 | /** | |
| 281 | * Tests a TrackBack with some content spam in the blog URL field. | |
| 282 | */ | |
| 283 | 2 |
public void testTrackBackWithSomeContentSpamInBlogUrlField() { |
| 284 | 2 | trackBack.setUrl("http://online.casinos.com"); |
| 285 | 2 | listener.trackBackAdded(trackBackEvent); |
| 286 | 2 | assertTrue(trackBack.isApproved()); |
| 287 | 2 | assertEquals(0, trackBack.getSpamScore()); |
| 288 | ||
| 289 | 2 | blog.getPluginProperties().setProperty(ContentSpamListener.REGEX_LIST_KEY, "casinos, poker, drugs"); |
| 290 | 2 | listener.trackBackAdded(trackBackEvent); |
| 291 | 2 | assertTrue(trackBack.isPending()); |
| 292 | 2 | assertEquals(1, trackBack.getSpamScore()); |
| 293 | } | |
| 294 | ||
| 295 | /** | |
| 296 | * Tests a TrackBack with some content spam in all fields. | |
| 297 | */ | |
| 298 | 2 |
public void testTrackBackWithSomeContentSpamInAllField() { |
| 299 | 2 | trackBack.setTitle("online casinos"); |
| 300 | 2 | trackBack.setBlogName("online casinos"); |
| 301 | 2 | trackBack.setUrl("http://online.casinos.com"); |
| 302 | 2 | trackBack.setExcerpt("Here is some junk about poker and online casinos."); |
| 303 | 2 | listener.trackBackAdded(trackBackEvent); |
| 304 | 2 | assertTrue(trackBack.isApproved()); |
| 305 | 2 | assertEquals(0, trackBack.getSpamScore()); |
| 306 | ||
| 307 | 2 | blog.getPluginProperties().setProperty(ContentSpamListener.REGEX_LIST_KEY, "casinos, poker, drugs"); |
| 308 | 2 | listener.trackBackAdded(trackBackEvent); |
| 309 | 2 | assertTrue(trackBack.isPending()); |
| 310 | 2 | assertEquals(4, trackBack.getSpamScore()); |
| 311 | } | |
| 312 | ||
| 313 | } | |
|
||||||||||||