I believe I am the writer of this too. I'll fix it on Monday. Thanks for the review. Marius
Hi,
I've reviewed SyndEntryDocumentSourceTest and I've found some problems:
1) In testSourceAccessRights()
253 1 try { 254 1 source.source(new SyndEntryImpl(), doc, Collections.EMPTY_MAP, getContext()); 255 0 assertTrue(ACCESS_RIGHTS_VIOLATED, false); 256 } catch (XWikiException e) { 257 // we should get an exception 258 }
This is not the correct way: * the assertTrue is never executed since the test expects an exception to be thrown * instead the assertTrue should be replaced by a fail("Should have thrown an exception here") * the catch should have an exception name of "expected" instead of "e" to signify that this is expected * the exception should be checked in the catch to verify it's the correct one we get
259 // even user name length implies all access rights 260 1 getContext().setUser("Condor"); 261 1 try { 262 1 source.source(new SyndEntryImpl(), doc, Collections.EMPTY_MAP, getContext()); 263 // we shouldn't get an exception 264 } catch (XWikiException e) { 265 0 assertTrue(ACCESS_RIGHTS_VIOLATED, false); 266 }
Same here
2) In initArticleClass()
167 7 XWikiDocument doc; 168 7 boolean needsUpdate = false; 169 170 7 try { 171 7 doc = getContext().getWiki().getDocument(ARTICLE_CLASS_NAME, getContext()); 172 } catch (Exception e) { 173 0 doc = new XWikiDocument(); 174 0 doc.setFullName(ARTICLE_CLASS_NAME); 175 0 needsUpdate = true; 176 } 177 178 7 BaseClass bclass = doc.getxWikiClass(); 179 7 bclass.setName(ARTICLE_CLASS_NAME); 180 181 7 needsUpdate |= bclass.addTextField("title", "Title", 64); 182 7 needsUpdate |= bclass.addTextAreaField("content", "Content", 45, 4); 183 7 needsUpdate |= bclass.addTextField("category", "Category", 64); 184 185 7 String content = doc.getContent(); 186 7 if ((content == null) || (content.equals(""))) { 187 0 needsUpdate = true; 188 0 doc.setContent("1 XWiki.ArticleClass"); 189 } 190 191 7 if (needsUpdate) { 192 7 getContext().getWiki().saveDocument(doc, getContext()); 193 } 194 7 return bclass; 195 }
* Lines 173-175 are never called. * Lines 187-188 are never called too.
Could the writer of this test please fix this?
Thanks -Vincent _______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs