1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
package net.sourceforge.pebble.domain; |
33 |
|
|
34 |
|
import net.sourceforge.pebble.Constants; |
35 |
|
import net.sourceforge.pebble.PebbleContext; |
36 |
|
import net.sourceforge.pebble.event.DefaultEventDispatcher; |
37 |
|
import net.sourceforge.pebble.api.event.blog.BlogEvent; |
38 |
|
import net.sourceforge.pebble.api.event.blog.BlogListener; |
39 |
|
import net.sourceforge.pebble.logging.CombinedLogFormatLogger; |
40 |
|
import net.sourceforge.pebble.permalink.DefaultPermalinkProvider; |
41 |
|
|
42 |
|
import java.io.File; |
43 |
|
import java.util.*; |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
@author |
49 |
|
|
|
|
| 98,5% |
Uncovered Elements: 4 (266) |
Complexity: 43 |
Complexity Density: 0,19 |
|
50 |
|
public class BlogTest extends SingleBlogTestCase { |
51 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0,05 |
1
PASS
|
|
52 |
2
|
public void testConstructionOfDefaultInstance() {... |
53 |
2
|
assertEquals(new File(TEST_BLOG_LOCATION, "blogs/default").getAbsolutePath(), blog.getRoot()); |
54 |
2
|
assertNull(blog.getBlog()); |
55 |
2
|
assertEquals("My blog", blog.getName()); |
56 |
2
|
assertEquals("", blog.getDescription()); |
57 |
2
|
assertEquals("Blog Owner", blog.getAuthor()); |
58 |
2
|
assertEquals("blog@yourdomain.com", blog.getEmail()); |
59 |
2
|
assertEquals(TimeZone.getTimeZone("Europe/London"), blog.getTimeZone()); |
60 |
2
|
assertEquals("en", blog.getLanguage()); |
61 |
2
|
assertEquals("GB", blog.getCountry()); |
62 |
2
|
assertEquals("UTF-8", blog.getCharacterEncoding()); |
63 |
2
|
assertEquals(3, blog.getRecentBlogEntriesOnHomePage()); |
64 |
2
|
assertEquals(3, blog.getRecentResponsesOnHomePage()); |
65 |
2
|
assertTrue(blog.isPublic()); |
66 |
2
|
assertFalse(blog.isPrivate()); |
67 |
2
|
assertEquals("net.sourceforge.pebble.permalink.DefaultPermalinkProvider", blog.getPermalinkProviderName()); |
68 |
2
|
assertTrue(blog.getPermalinkProvider() instanceof DefaultPermalinkProvider); |
69 |
2
|
assertEquals("net.sourceforge.pebble.event.DefaultEventDispatcher", blog.getEventDispatcherName()); |
70 |
2
|
assertTrue(blog.getEventDispatcher() instanceof DefaultEventDispatcher); |
71 |
2
|
assertEquals("net.sourceforge.pebble.logging.CombinedLogFormatLogger", blog.getLoggerName()); |
72 |
2
|
assertTrue(blog.getLogger() instanceof CombinedLogFormatLogger); |
73 |
|
} |
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1
PASS
|
|
78 |
2
|
public void testGetProperty() {... |
79 |
2
|
assertEquals(blog.getName(), blog.getProperty(Blog.NAME_KEY)); |
80 |
|
} |
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
1
PASS
|
|
85 |
2
|
public void testGetProperties() {... |
86 |
2
|
Properties props = blog.getProperties(); |
87 |
2
|
assertNotNull(props); |
88 |
2
|
assertEquals(blog.getName(), props.getProperty(Blog.NAME_KEY)); |
89 |
|
} |
90 |
|
|
91 |
|
|
92 |
|
|
93 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
94 |
2
|
public void testSetProperty() {... |
95 |
2
|
blog.setProperty(Blog.NAME_KEY, "New name"); |
96 |
2
|
assertEquals("New name", blog.getProperty(Blog.NAME_KEY)); |
97 |
2
|
assertEquals("New name", blog.getName()); |
98 |
|
|
99 |
|
|
100 |
2
|
blog.setProperty("aNewPropertyKey", "A new property value"); |
101 |
2
|
assertEquals("A new property value", blog.getProperty("aNewPropertyKey")); |
102 |
|
} |
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1
PASS
|
|
126 |
2
|
public void testRemoveProperty() {... |
127 |
2
|
blog.setProperty("aNewPropertyKey", "A new property value"); |
128 |
2
|
assertEquals("A new property value", blog.getProperty("aNewPropertyKey")); |
129 |
2
|
blog.removeProperty("aNewPropertyKey"); |
130 |
2
|
assertNull(blog.getProperty("aNewPropertyKey")); |
131 |
|
} |
132 |
|
|
133 |
|
|
134 |
|
|
135 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
1
PASS
|
|
136 |
2
|
public void testCalendar() {... |
137 |
2
|
Calendar cal = blog.getCalendar(); |
138 |
2
|
assertEquals(blog.getTimeZone(), cal.getTimeZone()); |
139 |
|
} |
140 |
|
|
141 |
|
|
142 |
|
|
143 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1
PASS
|
|
144 |
2
|
public void testGetBlogForYear() {... |
145 |
2
|
Calendar cal = blog.getCalendar(); |
146 |
2
|
Year year = blog.getBlogForYear(cal.get(Calendar.YEAR)); |
147 |
2
|
assertNotNull(year); |
148 |
2
|
assertEquals(cal.get(Calendar.YEAR), year.getYear()); |
149 |
|
} |
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
154 |
2
|
public void testGetBlogForPreviousYear() {... |
155 |
2
|
Calendar cal = blog.getCalendar(); |
156 |
2
|
Year year = blog.getBlogForYear(cal.get(Calendar.YEAR)); |
157 |
2
|
year = blog.getBlogForPreviousYear(year); |
158 |
2
|
assertNotNull(year); |
159 |
2
|
assertEquals(cal.get(Calendar.YEAR)-1, year.getYear()); |
160 |
|
} |
161 |
|
|
162 |
|
|
163 |
|
|
164 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
165 |
2
|
public void testGetBlogForNextYear() {... |
166 |
2
|
Calendar cal = blog.getCalendar(); |
167 |
2
|
Year year = blog.getBlogForYear(cal.get(Calendar.YEAR)); |
168 |
2
|
year = blog.getBlogForNextYear(year); |
169 |
2
|
assertNotNull(year); |
170 |
2
|
assertEquals(cal.get(Calendar.YEAR)+1, year.getYear()); |
171 |
|
} |
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1
PASS
|
|
176 |
2
|
public void testGetBlogForFirstMonth() {... |
177 |
2
|
Month month = blog.getBlogForFirstMonth(); |
178 |
2
|
assertNotNull(month); |
179 |
|
|
180 |
2
|
Calendar cal = blog.getCalendar(); |
181 |
2
|
assertEquals(cal.get(Calendar.MONTH)+1, month.getMonth()); |
182 |
|
} |
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1
PASS
|
|
187 |
2
|
public void testGetBlogForMonth() {... |
188 |
2
|
Month month = blog.getBlogForMonth(2003, 4); |
189 |
2
|
assertNotNull(month); |
190 |
2
|
assertEquals(2003, month.getYear().getYear()); |
191 |
2
|
assertEquals(4, month.getMonth()); |
192 |
|
} |
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
197 |
2
|
public void testGetBlogForThisMonth() {... |
198 |
2
|
Calendar cal = blog.getCalendar(); |
199 |
2
|
Month month = blog.getBlogForThisMonth(); |
200 |
2
|
assertNotNull(month); |
201 |
2
|
assertEquals(cal.get(Calendar.YEAR), month.getYear().getYear()); |
202 |
2
|
assertEquals(cal.get(Calendar.MONTH) + 1, month.getMonth()); |
203 |
|
} |
204 |
|
|
205 |
|
|
206 |
|
|
207 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
208 |
2
|
public void testGetBlogForDay() {... |
209 |
2
|
Day day = blog.getBlogForDay(2003, 7, 14); |
210 |
2
|
assertNotNull(day); |
211 |
2
|
assertEquals(2003, day.getMonth().getYear().getYear()); |
212 |
2
|
assertEquals(7, day.getMonth().getMonth()); |
213 |
2
|
assertEquals(14, day.getDay()); |
214 |
|
} |
215 |
|
|
216 |
|
|
217 |
|
|
218 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0,11 |
1
PASS
|
|
219 |
2
|
public void testGetBlogForDate() {... |
220 |
2
|
Calendar cal = blog.getCalendar(); |
221 |
2
|
cal.set(Calendar.YEAR, 2003); |
222 |
2
|
cal.set(Calendar.MONTH, 6); |
223 |
2
|
cal.set(Calendar.DAY_OF_MONTH, 14); |
224 |
2
|
Day day = blog.getBlogForDay(cal.getTime()); |
225 |
2
|
assertNotNull(day); |
226 |
2
|
assertEquals(2003, day.getMonth().getYear().getYear()); |
227 |
2
|
assertEquals(7, day.getMonth().getMonth()); |
228 |
2
|
assertEquals(14, day.getDay()); |
229 |
|
} |
230 |
|
|
231 |
|
|
232 |
|
|
233 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1
PASS
|
|
234 |
2
|
public void testGetBlogForToday() {... |
235 |
2
|
Calendar cal = blog.getCalendar(); |
236 |
2
|
Day day = blog.getBlogForToday(); |
237 |
2
|
assertNotNull(day); |
238 |
2
|
assertEquals(cal.get(Calendar.YEAR), day.getMonth().getYear().getYear()); |
239 |
2
|
assertEquals(cal.get(Calendar.MONTH) + 1, day.getMonth().getMonth()); |
240 |
2
|
assertEquals(cal.get(Calendar.DAY_OF_MONTH), day.getDay()); |
241 |
|
} |
242 |
|
|
243 |
|
|
244 |
|
|
245 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0,08 |
1
PASS
|
|
246 |
2
|
public void testAssignBlogOwners() {... |
247 |
2
|
blog.setProperty(Blog.BLOG_OWNERS_KEY, "user1"); |
248 |
2
|
assertEquals("user1", blog.getProperty(Blog.BLOG_OWNERS_KEY)); |
249 |
2
|
assertEquals("user1", blog.getBlogOwnersAsString()); |
250 |
|
|
251 |
2
|
Collection users = blog.getUsersInRole(Constants.BLOG_OWNER_ROLE); |
252 |
2
|
assertEquals(1, users.size()); |
253 |
2
|
assertTrue(users.contains("user1")); |
254 |
|
|
255 |
2
|
blog.setProperty(Blog.BLOG_OWNERS_KEY, "user1,user2"); |
256 |
2
|
assertEquals("user1,user2", blog.getProperty(Blog.BLOG_OWNERS_KEY)); |
257 |
2
|
assertEquals("user1,user2", blog.getBlogOwnersAsString()); |
258 |
|
|
259 |
2
|
users = blog.getUsersInRole(Constants.BLOG_OWNER_ROLE); |
260 |
2
|
assertEquals(2, users.size()); |
261 |
2
|
assertTrue(users.contains("user1")); |
262 |
2
|
assertTrue(users.contains("user2")); |
263 |
|
} |
264 |
|
|
265 |
|
|
266 |
|
|
267 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1
PASS
|
|
268 |
2
|
public void testNullBlogOwners() {... |
269 |
2
|
blog.removeProperty(Blog.BLOG_OWNERS_KEY); |
270 |
2
|
assertEquals(null, blog.getBlogOwnersAsString()); |
271 |
|
|
272 |
2
|
Collection users = blog.getUsersInRole(Constants.BLOG_OWNER_ROLE); |
273 |
2
|
assertEquals(0, users.size()); |
274 |
|
} |
275 |
|
|
276 |
|
|
277 |
|
|
278 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
1
PASS
|
|
279 |
2
|
public void testUserIsBlogOwner() {... |
280 |
2
|
blog.setProperty(Blog.BLOG_OWNERS_KEY, "user1"); |
281 |
2
|
assertTrue(blog.isUserInRole(Constants.BLOG_OWNER_ROLE, "user1")); |
282 |
2
|
assertFalse(blog.isUserInRole(Constants.BLOG_OWNER_ROLE, "user2")); |
283 |
|
} |
284 |
|
|
285 |
|
|
286 |
|
|
287 |
|
|
288 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
1
PASS
|
|
289 |
2
|
public void testUserIsBlogOwnerByDefault() {... |
290 |
2
|
blog.removeProperty(Blog.BLOG_OWNERS_KEY); |
291 |
2
|
assertTrue(blog.isUserInRole(Constants.BLOG_OWNER_ROLE, "user1")); |
292 |
2
|
assertTrue(blog.isUserInRole(Constants.BLOG_OWNER_ROLE, "usern")); |
293 |
|
} |
294 |
|
|
295 |
|
|
296 |
|
|
297 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0,05 |
1
PASS
|
|
298 |
2
|
public void testAssignBlogContributors() {... |
299 |
2
|
blog.setProperty(Blog.BLOG_CONTRIBUTORS_KEY, "user1"); |
300 |
2
|
assertEquals("user1", blog.getProperty(Blog.BLOG_CONTRIBUTORS_KEY)); |
301 |
2
|
assertEquals("user1", blog.getBlogContributorsAsString()); |
302 |
|
|
303 |
2
|
Collection users = blog.getUsersInRole(Constants.BLOG_CONTRIBUTOR_ROLE); |
304 |
2
|
assertEquals(1, users.size()); |
305 |
2
|
assertTrue(users.contains("user1")); |
306 |
|
|
307 |
2
|
blog.setProperty(Blog.BLOG_CONTRIBUTORS_KEY, "user1,user2"); |
308 |
2
|
assertEquals("user1,user2", blog.getProperty(Blog.BLOG_CONTRIBUTORS_KEY)); |
309 |
2
|
assertEquals("user1,user2", blog.getBlogContributorsAsString()); |
310 |
|
|
311 |
2
|
users = blog.getUsersInRole(Constants.BLOG_CONTRIBUTOR_ROLE); |
312 |
2
|
assertEquals(2, users.size()); |
313 |
2
|
assertTrue(users.contains("user1")); |
314 |
2
|
assertTrue(users.contains("user2")); |
315 |
|
|
316 |
2
|
blog.setProperty(Blog.BLOG_CONTRIBUTORS_KEY, "user1, user2"); |
317 |
2
|
assertEquals("user1, user2", blog.getProperty(Blog.BLOG_CONTRIBUTORS_KEY)); |
318 |
2
|
assertEquals("user1, user2", blog.getBlogContributorsAsString()); |
319 |
|
|
320 |
2
|
users = blog.getUsersInRole(Constants.BLOG_CONTRIBUTOR_ROLE); |
321 |
2
|
assertEquals(2, users.size()); |
322 |
2
|
assertTrue(users.contains("user1")); |
323 |
2
|
assertTrue(users.contains("user2")); |
324 |
|
} |
325 |
|
|
326 |
|
|
327 |
|
|
328 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1
PASS
|
|
329 |
2
|
public void testNullBlogContributors() {... |
330 |
2
|
blog.removeProperty(Blog.BLOG_CONTRIBUTORS_KEY); |
331 |
2
|
assertEquals(null, blog.getBlogContributorsAsString()); |
332 |
|
|
333 |
2
|
Collection users = blog.getUsersInRole(Constants.BLOG_CONTRIBUTOR_ROLE); |
334 |
2
|
assertEquals(0, users.size()); |
335 |
|
} |
336 |
|
|
337 |
|
|
338 |
|
|
339 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
1
PASS
|
|
340 |
2
|
public void testUserIsBlogContributor() {... |
341 |
2
|
blog.setProperty(Blog.BLOG_CONTRIBUTORS_KEY, "user1"); |
342 |
2
|
assertTrue(blog.isUserInRole(Constants.BLOG_CONTRIBUTOR_ROLE, "user1")); |
343 |
2
|
assertFalse(blog.isUserInRole(Constants.BLOG_CONTRIBUTOR_ROLE, "user2")); |
344 |
|
} |
345 |
|
|
346 |
|
|
347 |
|
|
348 |
|
|
349 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
1
PASS
|
|
350 |
2
|
public void testUserIsBlogContributorByDefault() {... |
351 |
2
|
blog.removeProperty(Blog.BLOG_CONTRIBUTORS_KEY); |
352 |
2
|
assertTrue(blog.isUserInRole(Constants.BLOG_CONTRIBUTOR_ROLE, "user1")); |
353 |
2
|
assertTrue(blog.isUserInRole(Constants.BLOG_CONTRIBUTOR_ROLE, "usern")); |
354 |
|
} |
355 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
1
PASS
|
|
356 |
2
|
public void testInvalidDayOfMonthAfterTimeZoneChanges() {... |
357 |
2
|
blog.getRecentBlogEntries(); |
358 |
2
|
blog.setProperty(Blog.TIMEZONE_KEY, "America/New_York"); |
359 |
|
|
360 |
|
|
361 |
2
|
blog.getRecentBlogEntries(); |
362 |
|
} |
363 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1
PASS
|
|
364 |
2
|
public void testGetRecentBlogEntriesFromEmptyBlog() {... |
365 |
2
|
assertTrue(blog.getRecentBlogEntries(3).isEmpty()); |
366 |
|
} |
367 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0,05 |
1
PASS
|
|
368 |
2
|
public void testGetRecentBlogEntries() throws BlogServiceException {... |
369 |
2
|
BlogService service = new BlogService(); |
370 |
|
|
371 |
2
|
BlogEntry entry1 = new BlogEntry(blog); |
372 |
2
|
entry1.setTitle("title1"); |
373 |
2
|
entry1.setBody("body1"); |
374 |
2
|
service.putBlogEntry(entry1); |
375 |
|
|
376 |
2
|
BlogEntry entry2 = new BlogEntry(blog); |
377 |
2
|
entry2.setTitle("title2"); |
378 |
2
|
entry2.setBody("body2"); |
379 |
2
|
service.putBlogEntry(entry2); |
380 |
|
|
381 |
2
|
BlogEntry entry3 = new BlogEntry(blog); |
382 |
2
|
entry3.setTitle("title3"); |
383 |
2
|
entry3.setBody("body3"); |
384 |
2
|
service.putBlogEntry(entry3); |
385 |
|
|
386 |
2
|
BlogEntry entry4 = new BlogEntry(blog); |
387 |
2
|
entry4.setTitle("title4"); |
388 |
2
|
entry4.setBody("body4"); |
389 |
2
|
service.putBlogEntry(entry4); |
390 |
|
|
391 |
2
|
List entries = blog.getRecentBlogEntries(3); |
392 |
|
|
393 |
2
|
assertEquals(3, entries.size()); |
394 |
2
|
assertEquals(entry4, entries.get(0)); |
395 |
|
} |
396 |
|
|
397 |
|
|
398 |
|
|
399 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
1
PASS
|
|
400 |
2
|
public void testImagesDirectoryAccessible() {... |
401 |
2
|
File file = new File(blog.getRoot(), "images"); |
402 |
2
|
assertEquals(file, new File(blog.getImagesDirectory())); |
403 |
2
|
assertTrue(file.exists()); |
404 |
|
} |
405 |
|
|
406 |
|
|
407 |
|
|
408 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
1
PASS
|
|
409 |
2
|
public void testFilesDirectoryAccessible() {... |
410 |
2
|
File file = new File(blog.getRoot(), "files"); |
411 |
2
|
assertEquals(file, new File(blog.getFilesDirectory())); |
412 |
2
|
assertTrue(file.exists()); |
413 |
|
} |
414 |
|
|
415 |
|
|
416 |
|
|
417 |
|
|
418 |
|
|
419 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
1
PASS
|
|
420 |
2
|
public void testThemeDirectoryAccessible() {... |
421 |
2
|
File file = new File(blog.getRoot(), "theme"); |
422 |
2
|
assertEquals(file, new File(blog.getThemeDirectory())); |
423 |
2
|
assertTrue(file.exists()); |
424 |
|
} |
425 |
|
|
426 |
|
|
427 |
|
|
428 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1
PASS
|
|
429 |
2
|
public void testSingleEmailAddress() {... |
430 |
2
|
blog.setProperty(Blog.EMAIL_KEY, "me@mydomain.com"); |
431 |
2
|
assertEquals("me@mydomain.com", blog.getEmail()); |
432 |
2
|
assertEquals(1, blog.getEmailAddresses().size()); |
433 |
2
|
assertEquals("me@mydomain.com", blog.getEmailAddresses().iterator().next()); |
434 |
|
} |
435 |
|
|
436 |
|
|
437 |
|
|
438 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1
PASS
|
|
439 |
2
|
public void testMultipleEmailAddresses() {... |
440 |
2
|
blog.setProperty(Blog.EMAIL_KEY, "me@mydomain.com,you@yourdomain.com"); |
441 |
2
|
assertEquals("me@mydomain.com,you@yourdomain.com", blog.getEmail()); |
442 |
2
|
assertEquals(2, blog.getEmailAddresses().size()); |
443 |
2
|
Iterator it = blog.getEmailAddresses().iterator(); |
444 |
2
|
assertEquals("me@mydomain.com", it.next()); |
445 |
2
|
assertEquals("you@yourdomain.com", it.next()); |
446 |
|
} |
447 |
|
|
448 |
|
|
449 |
|
|
450 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1
PASS
|
|
451 |
2
|
public void testFirstEmailAddress() {... |
452 |
2
|
blog.setProperty(Blog.EMAIL_KEY, ""); |
453 |
2
|
assertEquals("", blog.getFirstEmailAddress()); |
454 |
2
|
blog.setProperty(Blog.EMAIL_KEY, "me@mydomain.com"); |
455 |
2
|
assertEquals("me@mydomain.com", blog.getFirstEmailAddress()); |
456 |
2
|
blog.setProperty(Blog.EMAIL_KEY, "me@mydomain.com,you@yourdomain.com"); |
457 |
2
|
assertEquals("me@mydomain.com", blog.getFirstEmailAddress()); |
458 |
|
} |
459 |
|
|
460 |
|
|
461 |
|
|
462 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
1
PASS
|
|
463 |
2
|
public void testDomain() {... |
464 |
2
|
assertEquals("www.yourdomain.com", blog.getDomainName()); |
465 |
|
|
466 |
2
|
PebbleContext.getInstance().getConfiguration().setUrl("http://www.yourdomain.com:8080/blog"); |
467 |
2
|
assertEquals("www.yourdomain.com", blog.getDomainName()); |
468 |
|
} |
469 |
|
|
470 |
|
|
471 |
|
|
472 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1
PASS
|
|
473 |
2
|
public void testProtocol() {... |
474 |
2
|
assertEquals("http://", blog.getProtocol()); |
475 |
|
} |
476 |
|
|
477 |
|
|
478 |
|
|
479 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
480 |
2
|
public void testContext() {... |
481 |
2
|
assertEquals("/blog/", blog.getContext()); |
482 |
|
|
483 |
2
|
PebbleContext.getInstance().getConfiguration().setUrl("http://www.yourdomain.com:8080"); |
484 |
2
|
assertEquals("/", blog.getContext()); |
485 |
|
|
486 |
2
|
PebbleContext.getInstance().getConfiguration().setUrl("http://www.yourdomain.com:8080/"); |
487 |
2
|
assertEquals("/", blog.getContext()); |
488 |
|
} |
489 |
|
|
490 |
|
|
491 |
|
|
492 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
1
PASS
|
|
493 |
2
|
public void testLogger() {... |
494 |
2
|
assertNotNull(blog.getLogger()); |
495 |
2
|
assertTrue(blog.getLogger() instanceof CombinedLogFormatLogger); |
496 |
|
} |
497 |
|
|
498 |
|
|
499 |
|
|
500 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0,14 |
1
PASS
|
|
501 |
2
|
public void testListenersFiredWhenBlogStarted() {... |
502 |
2
|
final StringBuffer buf = new StringBuffer("123"); |
503 |
2
|
BlogListener listener = new BlogListener() { |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
504 |
2
|
public void blogStarted(BlogEvent event) {... |
505 |
2
|
assertEquals(blog, event.getSource()); |
506 |
2
|
buf.reverse(); |
507 |
|
} |
508 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
509 |
0
|
public void blogStopped(BlogEvent event) {... |
510 |
0
|
fail(); |
511 |
|
} |
512 |
|
}; |
513 |
2
|
blog.getEventListenerList().addBlogListener(listener); |
514 |
2
|
blog.start(); |
515 |
2
|
assertEquals("321", buf.toString()); |
516 |
2
|
blog.getEventListenerList().removeBlogListener(listener); |
517 |
2
|
blog.stop(); |
518 |
|
} |
519 |
|
|
520 |
|
|
521 |
|
|
522 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
523 |
2
|
public void testListenersFiredWhenBlogStopped() {... |
524 |
2
|
final StringBuffer buf = new StringBuffer("123"); |
525 |
2
|
BlogListener listener = new BlogListener() { |
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
526 |
0
|
public void blogStarted(BlogEvent event) {... |
527 |
0
|
fail(); |
528 |
|
} |
529 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
530 |
4
|
public void blogStopped(BlogEvent event) {... |
531 |
4
|
assertEquals(blog, event.getSource()); |
532 |
4
|
buf.reverse(); |
533 |
|
} |
534 |
|
}; |
535 |
2
|
blog.getEventListenerList().addBlogListener(listener); |
536 |
2
|
blog.stop(); |
537 |
2
|
assertEquals("321", buf.toString()); |
538 |
|
} |
539 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0,1 |
1
PASS
|
|
540 |
2
|
public void testApprovedCommentsForUnpublishedBlogEntriesDontShowUp() throws BlogServiceException {... |
541 |
2
|
BlogService service = new BlogService(); |
542 |
|
|
543 |
2
|
BlogEntry blogEntry = new BlogEntry(blog); |
544 |
2
|
blogEntry.setTitle("title1"); |
545 |
2
|
blogEntry.setBody("body1"); |
546 |
2
|
blogEntry.setPublished(false); |
547 |
2
|
service.putBlogEntry(blogEntry); |
548 |
|
|
549 |
2
|
Comment comment = blogEntry.createComment("title", "body", "author", "email", "website", "127.0.0.1"); |
550 |
2
|
blogEntry.addComment(comment); |
551 |
2
|
service.putBlogEntry(blogEntry); |
552 |
|
|
553 |
2
|
assertFalse(blog.getRecentApprovedResponses().contains(comment)); |
554 |
|
} |
555 |
|
|
556 |
|
} |