You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ag...@apache.org on 2007/01/29 19:38:04 UTC
svn commit: r501141 -
/incubator/roller/trunk/tests/org/apache/roller/business/CommentTest.java
Author: agilliland
Date: Mon Jan 29 10:38:03 2007
New Revision: 501141
URL: http://svn.apache.org/viewvc?view=rev&rev=501141
Log:
add a unit test for cascading deletes of comments through the delete of an entry or weblog.
Modified:
incubator/roller/trunk/tests/org/apache/roller/business/CommentTest.java
Modified: incubator/roller/trunk/tests/org/apache/roller/business/CommentTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/tests/org/apache/roller/business/CommentTest.java?view=diff&rev=501141&r1=501140&r2=501141
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/business/CommentTest.java (original)
+++ incubator/roller/trunk/tests/org/apache/roller/business/CommentTest.java Mon Jan 29 10:38:03 2007
@@ -24,6 +24,7 @@
import junit.framework.TestSuite;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.roller.RollerException;
import org.apache.roller.TestUtils;
import org.apache.roller.business.RollerFactory;
import org.apache.roller.business.WeblogManager;
@@ -193,6 +194,67 @@
TestUtils.teardownComment(comment3.getId());
TestUtils.endSession(true);
}
+
+
+ /**
+ * Test that when deleting parent objects of a comment that everything
+ * down the chain is properly deleted as well. i.e. deleting an entry
+ * should delete all comments on that entry, and deleting a weblog should
+ * delete all comments, etc.
+ */
+ public void testCommentParentDeletes() throws Exception {
+
+ log.info("BEGIN");
+
+ WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
+ UserManager umgr = RollerFactory.getRoller().getUserManager();
+
+ // first make sure we can delete an entry with comments
+ UserData user = TestUtils.setupUser("commentParentDeleteUser");
+ WebsiteData weblog = TestUtils.setupWeblog("commentParentDelete", user);
+ WeblogEntryData entry = TestUtils.setupWeblogEntry("CommentParentDeletes1", weblog.getDefaultCategory(), weblog, user);
+
+ CommentData comment1 = TestUtils.setupComment("comment1", entry);
+ CommentData comment2 = TestUtils.setupComment("comment2", entry);
+ CommentData comment3 = TestUtils.setupComment("comment3", entry);
+ TestUtils.endSession(true);
+
+ // now deleting the entry should succeed and delete all comments
+ Exception ex = null;
+ try {
+ wmgr.removeWeblogEntry(TestUtils.getManagedWeblogEntry(entry));
+ TestUtils.endSession(true);
+ } catch (RollerException e) {
+ ex = e;
+ }
+ assertNull(ex);
+
+ // now make sure we can delete a weblog with comments
+ weblog = TestUtils.getManagedWebsite(weblog);
+ entry = TestUtils.setupWeblogEntry("CommentParentDeletes2", weblog.getDefaultCategory(), weblog, user);
+
+ comment1 = TestUtils.setupComment("comment1", entry);
+ comment2 = TestUtils.setupComment("comment2", entry);
+ comment3 = TestUtils.setupComment("comment3", entry);
+ TestUtils.endSession(true);
+
+ // now deleting the entry should succeed and delete all comments
+ ex = null;
+ try {
+ umgr.removeWebsite(TestUtils.getManagedWebsite(weblog));
+ TestUtils.endSession(true);
+ } catch (RollerException e) {
+ ex = e;
+ }
+ assertNull(ex);
+
+ // and delete test user as well
+ umgr.removeUser(user);
+ TestUtils.endSession(true);
+
+ log.info("END");
+ }
+
/**
* Apparently, HSQL has "issues" with LIKE expressions,