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.webservice; |
33 |
|
|
34 |
|
import net.sourceforge.pebble.Constants; |
35 |
|
import net.sourceforge.pebble.domain.*; |
36 |
|
import org.acegisecurity.GrantedAuthority; |
37 |
|
import org.acegisecurity.GrantedAuthorityImpl; |
38 |
|
import org.acegisecurity.MockAuthenticationManager; |
39 |
|
import org.apache.xmlrpc.XmlRpcException; |
40 |
|
|
41 |
|
import java.util.Calendar; |
42 |
|
import java.util.Hashtable; |
43 |
|
import java.util.Vector; |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
@author |
49 |
|
|
|
|
| 81,5% |
Uncovered Elements: 51 (276) |
Complexity: 71 |
Complexity Density: 0,28 |
|
50 |
|
public class SingleBlogBloggerAPIHandlerTest extends SingleBlogTestCase { |
51 |
|
|
52 |
|
private BloggerAPIHandler handler = new BloggerAPIHandler(); |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
|
54 |
48
|
protected void setUp() throws Exception {... |
55 |
48
|
super.setUp(); |
56 |
|
|
57 |
48
|
handler.setAuthenticationManager(new net.sourceforge.pebble.mock.MockAuthenticationManager(true, new GrantedAuthority[] {new GrantedAuthorityImpl(Constants.BLOG_CONTRIBUTOR_ROLE)})); |
58 |
48
|
blog.setProperty(Blog.BLOG_CONTRIBUTORS_KEY, "username"); |
59 |
|
} |
60 |
|
|
|
|
| 52% |
Uncovered Elements: 12 (25) |
Complexity: 13 |
Complexity Density: 0,52 |
1
PASS
|
|
61 |
2
|
public void testAuthenticationFailure() {... |
62 |
2
|
handler.setAuthenticationManager(new MockAuthenticationManager(false)); |
63 |
2
|
try { |
64 |
2
|
handler.getUserInfo("", "username", "password"); |
65 |
0
|
fail(); |
66 |
|
} catch (XmlRpcAuthenticationException xmlrpcae) { |
67 |
|
} catch (XmlRpcException xmlrpce) { |
68 |
0
|
fail(); |
69 |
|
} |
70 |
2
|
try { |
71 |
2
|
handler.deletePost("", "default/123", "username", "password", true); |
72 |
0
|
fail(); |
73 |
|
} catch (XmlRpcAuthenticationException xmlrpcae) { |
74 |
|
} catch (XmlRpcException xmlrpce) { |
75 |
0
|
fail(); |
76 |
|
} |
77 |
2
|
try { |
78 |
2
|
handler.editPost("", "default/123", "username", "password", "content", true); |
79 |
0
|
fail(); |
80 |
|
} catch (XmlRpcAuthenticationException xmlrpcae) { |
81 |
|
} catch (XmlRpcException xmlrpce) { |
82 |
0
|
fail(); |
83 |
|
} |
84 |
2
|
try { |
85 |
2
|
handler.getPost("", "default/123", "username", "password"); |
86 |
0
|
fail(); |
87 |
|
} catch (XmlRpcAuthenticationException xmlrpcae) { |
88 |
|
} catch (XmlRpcException xmlrpce) { |
89 |
0
|
fail(); |
90 |
|
} |
91 |
2
|
try { |
92 |
2
|
handler.getRecentPosts("", "default", "username", "password", 10); |
93 |
0
|
fail(); |
94 |
|
} catch (XmlRpcAuthenticationException xmlrpcae) { |
95 |
|
} catch (XmlRpcException xmlrpce) { |
96 |
0
|
fail(); |
97 |
|
} |
98 |
2
|
try { |
99 |
2
|
handler.newPost("", "default", "username", "password", "content", true); |
100 |
0
|
fail(); |
101 |
|
} catch (XmlRpcAuthenticationException xmlrpcae) { |
102 |
|
} catch (XmlRpcException xmlrpce) { |
103 |
0
|
fail(); |
104 |
|
} |
105 |
|
} |
106 |
|
|
|
|
| 66,7% |
Uncovered Elements: 6 (18) |
Complexity: 13 |
Complexity Density: 0,72 |
1
PASS
|
|
107 |
2
|
public void testAuthenticationSuccess() {... |
108 |
2
|
try { |
109 |
2
|
handler.deletePost("", "123", "username", "password", true); |
110 |
|
} catch (XmlRpcAuthenticationException xmlrpcae) { |
111 |
0
|
fail(); |
112 |
|
} catch (XmlRpcException xmlrpce) { |
113 |
|
} |
114 |
2
|
try { |
115 |
2
|
handler.editPost("", "123", "username", "password", "content", true); |
116 |
|
} catch (XmlRpcAuthenticationException xmlrpcae) { |
117 |
0
|
fail(); |
118 |
|
} catch (XmlRpcException xmlrpce) { |
119 |
|
} |
120 |
2
|
try { |
121 |
2
|
handler.getPost("", "123", "username", "password"); |
122 |
|
} catch (XmlRpcAuthenticationException xmlrpcae) { |
123 |
0
|
fail(); |
124 |
|
} catch (XmlRpcException xmlrpce) { |
125 |
|
} |
126 |
2
|
try { |
127 |
2
|
handler.getRecentPosts("", "", "username", "password", 10); |
128 |
|
} catch (XmlRpcAuthenticationException xmlrpcae) { |
129 |
0
|
fail(); |
130 |
|
} catch (XmlRpcException xmlrpce) { |
131 |
|
} |
132 |
2
|
try { |
133 |
2
|
handler.getUsersBlogs("", "username", "password"); |
134 |
|
} catch (XmlRpcAuthenticationException xmlrpcae) { |
135 |
0
|
fail(); |
136 |
|
} catch (XmlRpcException xmlrpce) { |
137 |
|
} |
138 |
2
|
try { |
139 |
2
|
handler.newPost("", "", "username", "password", "<title>title</title>content", true); |
140 |
|
} catch (XmlRpcAuthenticationException xmlrpcae) { |
141 |
0
|
fail(); |
142 |
|
} catch (XmlRpcException xmlrpce) { |
143 |
|
} |
144 |
|
} |
145 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
146 |
2
|
public void testGetRecentPostsFromEmptyBlog() {... |
147 |
2
|
try { |
148 |
2
|
Vector posts = handler.getRecentPosts("appkey", "default", "username", "password", 3); |
149 |
2
|
assertTrue(posts.isEmpty()); |
150 |
|
} catch (Exception e) { |
151 |
0
|
fail(); |
152 |
|
} |
153 |
|
} |
154 |
|
|
|
|
| 93,8% |
Uncovered Elements: 2 (32) |
Complexity: 2 |
Complexity Density: 0,06 |
1
PASS
|
|
155 |
2
|
public void testGetRecentPosts() {... |
156 |
2
|
try { |
157 |
2
|
BlogService service = new BlogService(); |
158 |
|
|
159 |
2
|
BlogEntry entry1 = new BlogEntry(blog); |
160 |
2
|
entry1.setTitle("title1"); |
161 |
2
|
entry1.setBody("body1"); |
162 |
2
|
service.putBlogEntry(entry1); |
163 |
|
|
164 |
2
|
BlogEntry entry2 = new BlogEntry(blog); |
165 |
2
|
entry2.setTitle("title2"); |
166 |
2
|
entry2.setBody("body2"); |
167 |
2
|
service.putBlogEntry(entry2); |
168 |
|
|
169 |
2
|
BlogEntry entry3 = new BlogEntry(blog); |
170 |
2
|
entry3.setTitle("title3"); |
171 |
2
|
entry3.setBody("body3"); |
172 |
2
|
service.putBlogEntry(entry3); |
173 |
|
|
174 |
2
|
BlogEntry entry4 = new BlogEntry(blog); |
175 |
2
|
entry4.setTitle("title4"); |
176 |
2
|
entry4.setBody("body4"); |
177 |
2
|
service.putBlogEntry(entry4); |
178 |
|
|
179 |
2
|
Vector posts = handler.getRecentPosts("appkey", "default", "username", "password", 3); |
180 |
|
|
181 |
2
|
assertFalse(posts.isEmpty()); |
182 |
2
|
assertEquals(3, posts.size()); |
183 |
2
|
Hashtable ht = (Hashtable)posts.get(0); |
184 |
2
|
assertEquals("default/" + entry4.getId(), ht.get(BloggerAPIHandler.POST_ID)); |
185 |
2
|
assertEquals("<title>title4</title><category></category>body4", ht.get(BloggerAPIHandler.CONTENT)); |
186 |
2
|
ht = (Hashtable)posts.get(1); |
187 |
2
|
assertEquals("default/" + entry3.getId(), ht.get(BloggerAPIHandler.POST_ID)); |
188 |
2
|
assertEquals("<title>title3</title><category></category>body3", ht.get(BloggerAPIHandler.CONTENT)); |
189 |
2
|
ht = (Hashtable)posts.get(2); |
190 |
2
|
assertEquals("default/" + entry2.getId(), ht.get(BloggerAPIHandler.POST_ID)); |
191 |
2
|
assertEquals("<title>title2</title><category></category>body2", ht.get(BloggerAPIHandler.CONTENT)); |
192 |
|
} catch (Exception e) { |
193 |
0
|
e.printStackTrace(); |
194 |
0
|
fail(); |
195 |
|
} |
196 |
|
} |
197 |
|
|
|
|
| 85,7% |
Uncovered Elements: 2 (14) |
Complexity: 2 |
Complexity Density: 0,14 |
1
PASS
|
|
198 |
2
|
public void testGetPost() {... |
199 |
2
|
try { |
200 |
2
|
BlogService service = new BlogService(); |
201 |
2
|
BlogEntry entry = new BlogEntry(blog); |
202 |
2
|
entry.setTitle("title"); |
203 |
2
|
entry.setBody("body"); |
204 |
2
|
entry.setAuthor("simon"); |
205 |
2
|
service.putBlogEntry(entry); |
206 |
|
|
207 |
2
|
Hashtable post = handler.getPost("appkey", "default/" + entry.getId(), "username", "password"); |
208 |
2
|
assertEquals("<title>title</title><category></category>body", post.get(BloggerAPIHandler.CONTENT)); |
209 |
2
|
assertEquals(entry.getAuthor(), post.get(BloggerAPIHandler.USER_ID)); |
210 |
2
|
assertEquals(entry.getDate(), post.get(BloggerAPIHandler.DATE_CREATED)); |
211 |
2
|
assertEquals("default/" + entry.getId(), post.get(BloggerAPIHandler.POST_ID)); |
212 |
|
} catch (Exception e) { |
213 |
0
|
e.printStackTrace(); |
214 |
0
|
fail(); |
215 |
|
} |
216 |
|
} |
217 |
|
|
|
|
| 86,7% |
Uncovered Elements: 2 (15) |
Complexity: 2 |
Complexity Density: 0,13 |
1
PASS
|
|
218 |
2
|
public void testGetPostWithCategory() {... |
219 |
2
|
try { |
220 |
2
|
BlogService service = new BlogService(); |
221 |
2
|
BlogEntry entry = new BlogEntry(blog); |
222 |
2
|
entry.setTitle("title"); |
223 |
2
|
entry.setBody("body"); |
224 |
2
|
entry.setAuthor("simon"); |
225 |
2
|
entry.addCategory(new Category("java", "Java")); |
226 |
2
|
service.putBlogEntry(entry); |
227 |
|
|
228 |
2
|
Hashtable post = handler.getPost("appkey", "default/" + entry.getId(), "username", "password"); |
229 |
2
|
assertEquals("<title>title</title><category>/java</category>body", post.get(BloggerAPIHandler.CONTENT)); |
230 |
2
|
assertEquals(entry.getAuthor(), post.get(BloggerAPIHandler.USER_ID)); |
231 |
2
|
assertEquals(entry.getDate(), post.get(BloggerAPIHandler.DATE_CREATED)); |
232 |
2
|
assertEquals("default/" + entry.getId(), post.get(BloggerAPIHandler.POST_ID)); |
233 |
|
} catch (Exception e) { |
234 |
0
|
e.printStackTrace(); |
235 |
0
|
fail(); |
236 |
|
} |
237 |
|
} |
238 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
239 |
2
|
public void testGetPostWithIdThatDoesntExist() {... |
240 |
2
|
String postid = "1234567890123"; |
241 |
2
|
try { |
242 |
2
|
handler.getPost("appkey", "default/" + postid, "username", "password"); |
243 |
0
|
fail(); |
244 |
|
} catch (XmlRpcException xmlrpce) { |
245 |
2
|
assertEquals("Blog entry with ID of " + postid + " was not found.", xmlrpce.getMessage()); |
246 |
|
} |
247 |
|
} |
248 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
249 |
2
|
public void testGetPostWithNullId() {... |
250 |
2
|
String postid = null; |
251 |
2
|
try { |
252 |
2
|
handler.getPost("appkey", postid, "username", "password"); |
253 |
0
|
fail(); |
254 |
|
} catch (XmlRpcException xmlrpce) { |
255 |
2
|
assertEquals("Blog with ID of " + null + " not found.", xmlrpce.getMessage()); |
256 |
|
} |
257 |
|
} |
258 |
|
|
|
|
| 84,6% |
Uncovered Elements: 2 (13) |
Complexity: 2 |
Complexity Density: 0,15 |
1
PASS
|
|
259 |
2
|
public void testNewPostWithTitleAndCategory() {... |
260 |
2
|
try { |
261 |
2
|
Category category = new Category("/aCategory", "A Category"); |
262 |
2
|
blog.addCategory(category); |
263 |
|
|
264 |
2
|
String postid = handler.newPost("appkey", "default", "username", "password", "<title>Title</title><category>/aCategory</category><p>Content</p>", true); |
265 |
|
|
266 |
2
|
BlogService service = new BlogService(); |
267 |
2
|
BlogEntry entry = service.getBlogEntry(blog, postid.substring("default".length()+1)); |
268 |
|
|
269 |
2
|
assertEquals("default/" + entry.getId(), postid); |
270 |
2
|
assertEquals("Title", entry.getTitle()); |
271 |
2
|
assertTrue(entry.inCategory(category)); |
272 |
2
|
assertEquals("<p>Content</p>", entry.getBody()); |
273 |
2
|
assertEquals("username", entry.getAuthor()); |
274 |
|
|
275 |
|
} catch (Exception e) { |
276 |
0
|
e.printStackTrace(); |
277 |
0
|
fail(); |
278 |
|
} |
279 |
|
} |
280 |
|
|
|
|
| 87,5% |
Uncovered Elements: 2 (16) |
Complexity: 2 |
Complexity Density: 0,12 |
1
PASS
|
|
281 |
2
|
public void testNewPostWithTitleAndCategories() {... |
282 |
2
|
try { |
283 |
2
|
Category category1 = new Category("/category1", "Category 1"); |
284 |
2
|
blog.addCategory(category1); |
285 |
2
|
Category category2 = new Category("/category2", "Category 2"); |
286 |
2
|
blog.addCategory(category2); |
287 |
|
|
288 |
2
|
String postid = handler.newPost("appkey", "default", "username", "password", "<title>Title</title><category>/category1, /category2</category><p>Content</p>", true); |
289 |
|
|
290 |
2
|
BlogService service = new BlogService(); |
291 |
2
|
BlogEntry entry = service.getBlogEntry(blog, postid.substring("default".length()+1)); |
292 |
|
|
293 |
2
|
assertEquals("default/" + entry.getId(), postid); |
294 |
2
|
assertEquals("Title", entry.getTitle()); |
295 |
2
|
assertTrue(entry.inCategory(category1)); |
296 |
2
|
assertTrue(entry.inCategory(category2)); |
297 |
2
|
assertEquals("<p>Content</p>", entry.getBody()); |
298 |
2
|
assertEquals("username", entry.getAuthor()); |
299 |
|
|
300 |
|
} catch (Exception e) { |
301 |
0
|
e.printStackTrace(); |
302 |
0
|
fail(); |
303 |
|
} |
304 |
|
} |
305 |
|
|
|
|
| 80% |
Uncovered Elements: 2 (10) |
Complexity: 2 |
Complexity Density: 0,2 |
1
PASS
|
|
306 |
2
|
public void testNewPostWithoutTitle() {... |
307 |
2
|
try { |
308 |
2
|
String postid = handler.newPost("appkey", "default", "username", "password", "<p>Content</p>", true); |
309 |
|
|
310 |
2
|
BlogService service = new BlogService(); |
311 |
2
|
BlogEntry entry = service.getBlogEntry(blog, postid.substring("default".length()+1)); |
312 |
2
|
assertEquals("default/" + entry.getId(), postid); |
313 |
2
|
assertEquals("", entry.getTitle()); |
314 |
2
|
assertEquals("<p>Content</p>", entry.getBody()); |
315 |
2
|
assertEquals("username", entry.getAuthor()); |
316 |
|
|
317 |
|
} catch (Exception e) { |
318 |
0
|
e.printStackTrace(); |
319 |
0
|
fail(); |
320 |
|
} |
321 |
|
} |
322 |
|
|
|
|
| 85,7% |
Uncovered Elements: 2 (14) |
Complexity: 2 |
Complexity Density: 0,14 |
1
PASS
|
|
323 |
2
|
public void testEditPost() {... |
324 |
2
|
try { |
325 |
2
|
BlogService service = new BlogService(); |
326 |
2
|
BlogEntry entry = new BlogEntry(blog); |
327 |
2
|
entry.setTitle("title"); |
328 |
2
|
entry.setBody("body"); |
329 |
2
|
service.putBlogEntry(entry); |
330 |
|
|
331 |
2
|
boolean result = handler.editPost("appkey", "default/" + entry.getId(), "username", "password", "<title>Title</title><p>Content</p>", true); |
332 |
|
|
333 |
2
|
entry = service.getBlogEntry(blog, entry.getId()); |
334 |
2
|
assertTrue(result); |
335 |
2
|
assertEquals("Title", entry.getTitle()); |
336 |
2
|
assertEquals("<p>Content</p>", entry.getBody()); |
337 |
2
|
assertEquals("username", entry.getAuthor()); |
338 |
|
|
339 |
|
} catch (Exception e) { |
340 |
0
|
e.printStackTrace(); |
341 |
0
|
fail(); |
342 |
|
} |
343 |
|
} |
344 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
345 |
2
|
public void testEditPostWithNullId() {... |
346 |
2
|
String postid = null; |
347 |
2
|
try { |
348 |
2
|
handler.editPost("appkey", postid, "username", "password", "<title>Title</title><p>Content</p>", true); |
349 |
0
|
fail(); |
350 |
|
} catch (XmlRpcException xmlrpce) { |
351 |
2
|
assertEquals("Blog with ID of " + postid + " not found.", xmlrpce.getMessage()); |
352 |
|
} |
353 |
|
} |
354 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
355 |
2
|
public void testEditPostWithIdThatDoesntExist() {... |
356 |
2
|
String postid = "1234567890123"; |
357 |
2
|
try { |
358 |
2
|
handler.editPost("appkey", "default/" + postid, "username", "password", "<title>Title</title><p>Content</p>", true); |
359 |
0
|
fail(); |
360 |
|
} catch (XmlRpcException xmlrpce) { |
361 |
2
|
assertEquals("Blog entry with ID of " + postid + " was not found.", xmlrpce.getMessage()); |
362 |
|
} |
363 |
|
} |
364 |
|
|
|
|
| 83,3% |
Uncovered Elements: 2 (12) |
Complexity: 2 |
Complexity Density: 0,17 |
1
PASS
|
|
365 |
2
|
public void testDeletePost() {... |
366 |
2
|
try { |
367 |
2
|
BlogService service = new BlogService(); |
368 |
2
|
BlogEntry entry = new BlogEntry(blog); |
369 |
2
|
entry.setTitle("title"); |
370 |
2
|
entry.setBody("body"); |
371 |
2
|
entry.setAuthor("simon"); |
372 |
2
|
service.putBlogEntry(entry); |
373 |
|
|
374 |
2
|
boolean result = handler.deletePost("appkey", "default/" + entry.getId(), "username", "password", true); |
375 |
2
|
assertTrue("deletePost() returned false instead of true", result); |
376 |
2
|
assertNull(service.getBlogEntry(blog, entry.getId())); |
377 |
|
} catch (Exception e) { |
378 |
0
|
e.printStackTrace(); |
379 |
0
|
fail(); |
380 |
|
} |
381 |
|
} |
382 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
383 |
2
|
public void testDeletePostWithIdThatDoesntExist() {... |
384 |
2
|
String postid = "1234567890123"; |
385 |
2
|
try { |
386 |
2
|
handler.deletePost("appkey", "default/" + postid, "username", "password", true); |
387 |
0
|
fail(); |
388 |
|
} catch (XmlRpcException xmlrpce) { |
389 |
2
|
assertEquals("Blog entry with ID of " + postid + " was not found.", xmlrpce.getMessage()); |
390 |
|
} |
391 |
|
} |
392 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
393 |
2
|
public void testDeletePostWithNullId() {... |
394 |
2
|
String postid = null; |
395 |
2
|
try { |
396 |
2
|
handler.deletePost("appkey", postid, "username", "password", true); |
397 |
0
|
fail(); |
398 |
|
} catch (XmlRpcException xmlrpce) { |
399 |
2
|
assertEquals("Blog with ID of " + null + " not found.", xmlrpce.getMessage()); |
400 |
|
} |
401 |
|
} |
402 |
|
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
403 |
2
|
public void testGetUserInfo() {... |
404 |
2
|
try { |
405 |
2
|
Hashtable userInfo = handler.getUserInfo("appkey", "username", "password"); |
406 |
2
|
assertEquals("username", userInfo.get("userid")); |
407 |
|
} catch (Exception e) { |
408 |
0
|
e.printStackTrace(); |
409 |
0
|
fail(); |
410 |
|
} |
411 |
|
} |
412 |
|
|
|
|
| 77,8% |
Uncovered Elements: 2 (9) |
Complexity: 2 |
Complexity Density: 0,22 |
1
PASS
|
|
413 |
2
|
public void testGetUsersBlogs() {... |
414 |
2
|
try { |
415 |
2
|
Vector blogs = handler.getUsersBlogs("appkey", "username", "password"); |
416 |
2
|
assertEquals(1, blogs.size()); |
417 |
|
|
418 |
2
|
Hashtable blog = (Hashtable)blogs.get(0); |
419 |
2
|
assertEquals("http://www.yourdomain.com/blog/", blog.get("url")); |
420 |
2
|
assertEquals("default", blog.get("blogid")); |
421 |
2
|
assertEquals("My blog", blog.get("blogName")); |
422 |
|
} catch (Exception e) { |
423 |
0
|
e.printStackTrace(); |
424 |
0
|
fail(); |
425 |
|
} |
426 |
|
} |
427 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
428 |
2
|
public void testGetTemplate() {... |
429 |
2
|
try { |
430 |
2
|
handler.getTemplate("appkey", "blogid", "username", "password", "templateType"); |
431 |
0
|
fail(); |
432 |
|
} catch (XmlRpcException xmlrpce) { |
433 |
2
|
assertEquals("getTemplate is not supported by Pebble.", xmlrpce.getMessage()); |
434 |
|
} |
435 |
|
} |
436 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 0,5 |
1
PASS
|
|
437 |
2
|
public void testSetTemplate() {... |
438 |
2
|
try { |
439 |
2
|
handler.setTemplate("appkey", "blogid", "username", "password", "template", "templateType"); |
440 |
0
|
fail(); |
441 |
|
} catch (XmlRpcException xmlrpce) { |
442 |
2
|
assertEquals("setTemplate is not supported by Pebble.", xmlrpce.getMessage()); |
443 |
|
} |
444 |
|
} |
445 |
|
|
|
|
| 84,6% |
Uncovered Elements: 2 (13) |
Complexity: 2 |
Complexity Density: 0,15 |
1
PASS
|
|
446 |
2
|
public void testAddCategory() {... |
447 |
2
|
try { |
448 |
2
|
BlogService service = new BlogService(); |
449 |
2
|
BlogEntry entry = new BlogEntry(blog); |
450 |
2
|
service.putBlogEntry(entry); |
451 |
2
|
blog.addCategory(new Category("/aCategory", "A Category")); |
452 |
|
|
453 |
2
|
boolean result = handler.addCategory("appkey", "default/" + entry.getId(), "username", "password", "/aCategory"); |
454 |
|
|
455 |
2
|
entry = service.getBlogEntry(blog, entry.getId()); |
456 |
2
|
assertTrue("Category wasn't added", result); |
457 |
2
|
assertTrue(entry.inCategory(blog.getCategory("aCategory"))); |
458 |
|
|
459 |
2
|
result = handler.addCategory("appkey", "default/" + entry.getId(), "username", "password", "/aNonExistentCategory"); |
460 |
2
|
assertFalse("Category was added", result); |
461 |
|
|
462 |
|
} catch (Exception e) { |
463 |
0
|
e.printStackTrace(); |
464 |
0
|
fail(); |
465 |
|
} |
466 |
|
} |
467 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
468 |
2
|
public void testAddCategoryWithIdThatDoesntExist() {... |
469 |
2
|
String postid = "1234567890123"; |
470 |
2
|
try { |
471 |
2
|
handler.addCategory("appkey", "default/" + postid, "username", "password", "aCategory"); |
472 |
0
|
fail(); |
473 |
|
} catch (XmlRpcException xmlrpce) { |
474 |
2
|
assertEquals("Blog entry with ID of " + postid + " was not found.", xmlrpce.getMessage()); |
475 |
|
} |
476 |
|
} |
477 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0,4 |
1
PASS
|
|
478 |
2
|
public void testAddCategoryWithNullId() {... |
479 |
2
|
String postid = null; |
480 |
2
|
try { |
481 |
2
|
handler.addCategory("appkey", postid, "username", "password", "aCategory"); |
482 |
0
|
fail(); |
483 |
|
} catch (XmlRpcException xmlrpce) { |
484 |
2
|
assertEquals("Blog with ID of " + null + " not found.", xmlrpce.getMessage()); |
485 |
|
} |
486 |
|
} |
487 |
|
|
488 |
|
} |