|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
This report was generated with an evaluation server license. Purchase Clover or configure your license. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DayTest | Line # 43 | 24 | 0% | 7 | 0 | 100% |
1.0
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
(12) | |||
Result | |||
0.38709676
|
net.sourceforge.pebble.domain.DayTest.testGetDate
![]() |
1 PASS | |
0.38709676
|
net.sourceforge.pebble.domain.DayTest.testGetDate
![]() |
1 PASS | |
0.22580644
|
net.sourceforge.pebble.domain.DayTest.testGetPermalink
![]() |
1 PASS | |
0.22580644
|
net.sourceforge.pebble.domain.DayTest.testGetPermalink
![]() |
1 PASS | |
0.09677419
|
net.sourceforge.pebble.domain.DayTest.testGetDay
![]() |
1 PASS | |
0.09677419
|
net.sourceforge.pebble.domain.DayTest.testGetDay
![]() |
1 PASS | |
0.06451613
|
net.sourceforge.pebble.domain.DayTest.testGetRootBlog
![]() |
1 PASS | |
0.06451613
|
net.sourceforge.pebble.domain.DayTest.testGetMonth
![]() |
1 PASS | |
0.06451613
|
net.sourceforge.pebble.domain.DayTest.testIntrospection
![]() |
1 PASS | |
0.06451613
|
net.sourceforge.pebble.domain.DayTest.testIntrospection
![]() |
1 PASS | |
0.06451613
|
net.sourceforge.pebble.domain.DayTest.testGetMonth
![]() |
1 PASS | |
0.06451613
|
net.sourceforge.pebble.domain.DayTest.testGetRootBlog
![]() |
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.domain; | |
33 | ||
34 | import java.beans.Introspector; | |
35 | import java.util.Calendar; | |
36 | import java.util.Date; | |
37 | ||
38 | /** | |
39 | * Tests for the Day class. | |
40 | * | |
41 | * @author Simon Brown | |
42 | */ | |
43 | public class DayTest extends SingleBlogTestCase { | |
44 | ||
45 | private Day day; | |
46 | ||
47 | 12 |
![]() |
48 | 12 | super.setUp(); |
49 | 12 | day = blog.getBlogForToday(); |
50 | } | |
51 | ||
52 | /** | |
53 | * Tests that the root blog is setup correctly. | |
54 | */ | |
55 | 2 |
![]() |
56 | 2 | assertEquals(blog, day.getBlog()); |
57 | } | |
58 | ||
59 | /** | |
60 | * Tests the getter for the day property. | |
61 | */ | |
62 | 2 |
![]() |
63 | 2 | Calendar cal = blog.getCalendar(); |
64 | 2 | assertEquals(cal.get(Calendar.DAY_OF_MONTH), day.getDay()); |
65 | } | |
66 | ||
67 | /** | |
68 | * Tests the getter for the monthly blog. | |
69 | */ | |
70 | 2 |
![]() |
71 | 2 | assertEquals(blog.getBlogForThisMonth(), day.getMonth()); |
72 | } | |
73 | ||
74 | /** | |
75 | * Tests the getter for the date property. | |
76 | */ | |
77 | 2 |
![]() |
78 | 2 | day = blog.getBlogForDay(2003, 4, 7); |
79 | 2 | Date date = day.getDate(); |
80 | 2 | Calendar cal = blog.getCalendar(); |
81 | 2 | cal.setTime(date); |
82 | 2 | assertEquals(2003, cal.get(Calendar.YEAR)); |
83 | 2 | assertEquals(4, cal.get(Calendar.MONTH) + 1); |
84 | 2 | assertEquals(7, cal.get(Calendar.DAY_OF_MONTH)); |
85 | 2 | assertEquals(0, cal.get(Calendar.HOUR)); |
86 | 2 | assertEquals(0, cal.get(Calendar.MINUTE)); |
87 | 2 | assertEquals(0, cal.get(Calendar.SECOND)); |
88 | 2 | assertEquals(0, cal.get(Calendar.MILLISECOND)); |
89 | } | |
90 | ||
91 | /** | |
92 | * Tests the permalink. | |
93 | */ | |
94 | 2 |
![]() |
95 | 2 | String permalink = blog.getUrl() + "2003/04/01.html"; |
96 | 2 | day = blog.getBlogForDay(2003, 4, 1); |
97 | 2 | assertEquals(permalink, day.getPermalink()); |
98 | ||
99 | 2 | permalink = blog.getUrl() + "2003/04/10.html"; |
100 | 2 | day = blog.getBlogForDay(2003, 4, 10); |
101 | 2 | assertEquals(permalink, day.getPermalink()); |
102 | } | |
103 | ||
104 | // /** | |
105 | // * Tests the ability to check for entries. | |
106 | // */ | |
107 | // public void testHasEntries() { | |
108 | // assertFalse(day.hasBlogEntries()); | |
109 | // | |
110 | // BlogEntry entry = day.createBlogEntry(); | |
111 | // day.addEntry(entry); | |
112 | // assertTrue(day.hasBlogEntries()); | |
113 | // } | |
114 | ||
115 | // /** | |
116 | // * Tests the ability to check for entries in a specific category. | |
117 | // */ | |
118 | // public void testHasEntriesInCategory() { | |
119 | // Category cat = new Category("testCategory1", "Test Category 1"); | |
120 | // assertFalse(day.hasBlogEntries(cat)); | |
121 | // | |
122 | // BlogEntry entry = day.createBlogEntry(); | |
123 | // day.addEntry(entry); | |
124 | // assertFalse(day.hasBlogEntries(cat)); | |
125 | // | |
126 | // entry.addCategory(cat); | |
127 | // assertTrue(day.hasBlogEntries(cat)); | |
128 | // } | |
129 | ||
130 | // /** | |
131 | // * Tests the ability to get all day entries. | |
132 | // */ | |
133 | // public void testGetEntries() { | |
134 | // assertNotNull(day.getEntries()); | |
135 | // assertTrue(day.getEntries().isEmpty()); | |
136 | // | |
137 | // BlogEntry entry = day.createBlogEntry(); | |
138 | // day.addEntry(entry); | |
139 | // assertNotNull(day.getEntries()); | |
140 | // assertTrue(day.getEntries().size() == 1); | |
141 | // assertTrue(day.getEntries().contains(entry)); | |
142 | // } | |
143 | ||
144 | // /** | |
145 | // * Tests the ability to create a new blog entry. | |
146 | // */ | |
147 | // public void testCreateBlogEntry() { | |
148 | // BlogEntry entry = day.createBlogEntry(); | |
149 | // assertNotNull(entry); | |
150 | // | |
151 | // // and check it's not yet been added to the Day instance | |
152 | // assertFalse(day.hasBlogEntries()); | |
153 | // } | |
154 | ||
155 | // /** | |
156 | // * Tests that the previous blog entry can be obtained. | |
157 | // */ | |
158 | // public void testPreviousBlogEntry() { | |
159 | // Calendar cal = blog.getCalendar(); | |
160 | // cal.set(Calendar.HOUR_OF_DAY, 2); | |
161 | // BlogEntry entry1 = day.createBlogEntry("Title", "Body", cal.getTime()); | |
162 | // day.addEntry(entry1); | |
163 | // cal.set(Calendar.HOUR_OF_DAY, 3); | |
164 | // BlogEntry entry2 = day.createBlogEntry("Title", "Body", cal.getTime()); | |
165 | // day.addEntry(entry2); | |
166 | // cal.set(Calendar.HOUR_OF_DAY, 4); | |
167 | // BlogEntry entry3 = day.createBlogEntry("Title", "Body", cal.getTime()); | |
168 | // day.addEntry(entry3); | |
169 | // | |
170 | // assertNull(day.getPreviousBlogEntry(null)); | |
171 | // assertNull(day.getPreviousBlogEntry(entry1)); | |
172 | // assertEquals(entry1, day.getPreviousBlogEntry(entry2)); | |
173 | // assertEquals(entry2, day.getPreviousBlogEntry(entry3)); | |
174 | // } | |
175 | ||
176 | // /** | |
177 | // * Tests that the next blog entry can be obtained. | |
178 | // */ | |
179 | // public void testNextBlogEntry() { | |
180 | // Calendar cal = blog.getCalendar(); | |
181 | // cal.set(Calendar.HOUR_OF_DAY, 2); | |
182 | // BlogEntry entry1 = day.createBlogEntry("Title", "Body", cal.getTime()); | |
183 | // day.addEntry(entry1); | |
184 | // cal.set(Calendar.HOUR_OF_DAY, 3); | |
185 | // BlogEntry entry2 = day.createBlogEntry("Title", "Body", cal.getTime()); | |
186 | // day.addEntry(entry2); | |
187 | // cal.set(Calendar.HOUR_OF_DAY, 4); | |
188 | // BlogEntry entry3 = day.createBlogEntry("Title", "Body", cal.getTime()); | |
189 | // day.addEntry(entry3); | |
190 | // | |
191 | // assertNull(day.getNextBlogEntry(null)); | |
192 | // assertNull(day.getNextBlogEntry(entry3)); | |
193 | // assertEquals(entry2, day.getNextBlogEntry(entry1)); | |
194 | // assertEquals(entry3, day.getNextBlogEntry(entry2)); | |
195 | // } | |
196 | ||
197 | // /** | |
198 | // * Tests that blog entries can't be added with the same ID. | |
199 | // */ | |
200 | // public void testAddingBlogEntriesWithTheSameId() { | |
201 | // Day today = blog.getBlogForToday(); | |
202 | // BlogEntry blogEntry1 = today.createBlogEntry(); | |
203 | // BlogEntry blogEntry2 = today.createBlogEntry(); | |
204 | // BlogEntry blogEntry3 = today.createBlogEntry(); | |
205 | // today.addEntry(blogEntry1); | |
206 | // today.addEntry(blogEntry2); | |
207 | // today.addEntry(blogEntry3); | |
208 | // | |
209 | // assertFalse("IDs are the same", blogEntry1.getId().equals(blogEntry2.getId())); | |
210 | // assertFalse("IDs are the same", blogEntry2.getId().equals(blogEntry3.getId())); | |
211 | // assertFalse("IDs are the same", blogEntry1.getId().equals(blogEntry3.getId())); | |
212 | // } | |
213 | ||
214 | // /** | |
215 | // * Tests that listeners are fired when a blog entry is added. | |
216 | // */ | |
217 | // public void testListenersFiredWhenBlogEntryAdded() { | |
218 | // final StringBuffer buf = new StringBuffer("123"); | |
219 | // final BlogEntry blogEntry = day.createBlogEntry(); | |
220 | // | |
221 | // BlogEntryListener listener = new BlogEntryListener() { | |
222 | // public void blogEntryAdded(BlogEntryEvent event) { | |
223 | // assertEquals(blogEntry, event.getSource()); | |
224 | // buf.reverse(); | |
225 | // } | |
226 | // | |
227 | // public void blogEntryRemoved(BlogEntryEvent event) { | |
228 | // fail(); | |
229 | // } | |
230 | // | |
231 | // public void blogEntryChanged(BlogEntryEvent event) { | |
232 | // fail(); | |
233 | // } | |
234 | // | |
235 | // public void blogEntryApproved(BlogEntryEvent event) { | |
236 | // fail(); | |
237 | // } | |
238 | // | |
239 | // public void blogEntryRejected(BlogEntryEvent event) { | |
240 | // fail(); | |
241 | // } | |
242 | // }; | |
243 | // | |
244 | // blog.getEventListenerList().addBlogEntryListener(listener); | |
245 | // day.addEntry(blogEntry); | |
246 | // assertEquals("321", buf.toString()); | |
247 | // } | |
248 | ||
249 | // /** | |
250 | // * Tests that listeners are fired when a blog entry is removed. | |
251 | // */ | |
252 | // public void testListenersFiredWhenBlogEntryRemoved() { | |
253 | // final StringBuffer buf = new StringBuffer("123"); | |
254 | // final BlogEntry blogEntry = day.createBlogEntry(); | |
255 | // day.addEntry(blogEntry); | |
256 | // | |
257 | // BlogEntryListener listener = new BlogEntryListener() { | |
258 | // public void blogEntryAdded(BlogEntryEvent event) { | |
259 | // fail(); | |
260 | // } | |
261 | // | |
262 | // public void blogEntryRemoved(BlogEntryEvent event) { | |
263 | // assertEquals(blogEntry, event.getSource()); | |
264 | // buf.reverse(); | |
265 | // } | |
266 | // | |
267 | // public void blogEntryChanged(BlogEntryEvent event) { | |
268 | // fail(); | |
269 | // } | |
270 | // | |
271 | // public void blogEntryApproved(BlogEntryEvent event) { | |
272 | // fail(); | |
273 | // } | |
274 | // | |
275 | // public void blogEntryRejected(BlogEntryEvent event) { | |
276 | // fail(); | |
277 | // } | |
278 | // }; | |
279 | // | |
280 | // blog.getEventListenerList().addBlogEntryListener(listener); | |
281 | // day.removeEntry(blogEntry); | |
282 | // assertEquals("321", buf.toString()); | |
283 | // } | |
284 | ||
285 | // /** | |
286 | // * Tests that event listeners are enabled after an entry has been added. | |
287 | // */ | |
288 | // public void testBlogEntryEventListenersEnabledAfterAddition() { | |
289 | // final BlogEntry blogEntry = day.createBlogEntry(); | |
290 | // assertFalse(blogEntry.areEventsEnabled()); | |
291 | // day.addEntry(blogEntry); | |
292 | // assertTrue(blogEntry.areEventsEnabled()); | |
293 | // } | |
294 | ||
295 | 2 |
![]() |
296 | 2 | Introspector.getBeanInfo(Day.class); |
297 | } | |
298 | ||
299 | } |
|