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/30 23:51:53 UTC
svn commit: r501622 -
/incubator/roller/trunk/tests/org/apache/roller/TestUtils.java
Author: agilliland
Date: Tue Jan 30 14:51:53 2007
New Revision: 501622
URL: http://svn.apache.org/viewvc?view=rev&rev=501622
Log:
setup and teardown methods for a weblog category.
Modified:
incubator/roller/trunk/tests/org/apache/roller/TestUtils.java
Modified: incubator/roller/trunk/tests/org/apache/roller/TestUtils.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/tests/org/apache/roller/TestUtils.java?view=diff&rev=501622&r1=501621&r2=501622
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/TestUtils.java (original)
+++ incubator/roller/trunk/tests/org/apache/roller/TestUtils.java Tue Jan 30 14:51:53 2007
@@ -183,6 +183,54 @@
/**
+ * Convenience method for creating a weblog category.
+ */
+ public static WeblogCategoryData setupWeblogCategory(WebsiteData weblog,
+ String name,
+ WeblogCategoryData parent)
+ throws Exception {
+
+ WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
+ WeblogCategoryData root = mgr.getRootWeblogCategory(weblog);
+
+ WeblogCategoryData catParent = root;
+ if(parent != null) {
+ catParent = parent;
+ }
+ WeblogCategoryData testCat = new WeblogCategoryData(weblog, catParent, name, null, null);
+ mgr.saveWeblogCategory(testCat);
+
+ // flush to db
+ RollerFactory.getRoller().flush();
+
+ // query for object
+ WeblogCategoryData cat = mgr.getWeblogCategory(testCat.getId());
+
+ if(cat == null)
+ throw new RollerException("error setting up weblog category");
+
+ return cat;
+ }
+
+
+ /**
+ * Convenience method for removing a weblog category.
+ */
+ public static void teardownWeblogCategory(String id) throws Exception {
+
+ // lookup the cat
+ WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
+ WeblogCategoryData cat = mgr.getWeblogCategory(id);
+
+ // remove the cat
+ mgr.removeWeblogCategory(cat);
+
+ // flush to db
+ RollerFactory.getRoller().flush();
+ }
+
+
+ /**
* Convenience method for creating a weblog entry.
*/
public static WeblogEntryData setupWeblogEntry(String anchor,