roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r501623 - in /incubator/roller/trunk/tests/org/apache/roller/business: CoreWeblogServicesTestSuite.java WeblogCategoryCRUDTest.java WeblogCategoryParentDeletesTest.java WeblogCategoryTest.java
Date Tue, 30 Jan 2007 22:52:34 GMT
Author: agilliland
Date: Tue Jan 30 14:52:34 2007
New Revision: 501623

URL: http://svn.apache.org/viewvc?view=rev&rev=501623
Log:
flushing out weblog category tests to provide better testing coverage.


Added:
    incubator/roller/trunk/tests/org/apache/roller/business/WeblogCategoryCRUDTest.java
    incubator/roller/trunk/tests/org/apache/roller/business/WeblogCategoryParentDeletesTest.java
Modified:
    incubator/roller/trunk/tests/org/apache/roller/business/CoreWeblogServicesTestSuite.java
    incubator/roller/trunk/tests/org/apache/roller/business/WeblogCategoryTest.java

Modified: incubator/roller/trunk/tests/org/apache/roller/business/CoreWeblogServicesTestSuite.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/tests/org/apache/roller/business/CoreWeblogServicesTestSuite.java?view=diff&rev=501623&r1=501622&r2=501623
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/business/CoreWeblogServicesTestSuite.java
(original)
+++ incubator/roller/trunk/tests/org/apache/roller/business/CoreWeblogServicesTestSuite.java
Tue Jan 30 14:52:34 2007
@@ -35,14 +35,16 @@
 
         TestSuite suite = new TestSuite();
 	
-        // test entries
-        suite.addTestSuite(WeblogEntryTest.class);
-
         // test categories
+        suite.addTestSuite(WeblogCategoryCRUDTest.class);
+        suite.addTestSuite(WeblogCategoryParentDeletesTest.class);
         suite.addTestSuite(WeblogCategoryTest.class);
-
+        
         // test templates
         suite.addTestSuite(WeblogPageTest.class);
+        
+        // test entries
+        suite.addTestSuite(WeblogEntryTest.class);
         
         // test comments
         suite.addTestSuite(CommentTest.class);

Added: incubator/roller/trunk/tests/org/apache/roller/business/WeblogCategoryCRUDTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/tests/org/apache/roller/business/WeblogCategoryCRUDTest.java?view=auto&rev=501623
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/business/WeblogCategoryCRUDTest.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/business/WeblogCategoryCRUDTest.java Tue
Jan 30 14:52:34 2007
@@ -0,0 +1,200 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.business;
+
+import java.util.List;
+import junit.framework.TestCase;
+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.pojos.UserData;
+import org.apache.roller.pojos.WeblogCategoryData;
+import org.apache.roller.pojos.WebsiteData;
+
+
+/**
+ * Test WeblogCategory CRUD actions.
+ */
+public class WeblogCategoryCRUDTest extends TestCase {
+    
+    public static Log log = LogFactory.getLog(WeblogCategoryCRUDTest.class);
+    
+    UserData testUser = null;
+    WebsiteData testWeblog = null;
+    
+    
+    /**
+     * All tests in this suite require a user and a weblog.
+     */
+    public void setUp() {
+        
+        log.info("BEGIN");
+        
+        try {
+            testUser = TestUtils.setupUser("categoryCRUDTestUser");
+            testWeblog = TestUtils.setupWeblog("categoryCRUDTestWeblog", testUser);
+            TestUtils.endSession(true);
+        } catch (Exception ex) {
+            log.error(ex);
+        }
+        
+        log.info("END");
+    }
+    
+    public void tearDown() {
+        
+        log.info("BEGIN");
+        
+        try {
+            TestUtils.teardownWeblog(testWeblog.getId());
+            TestUtils.teardownUser(testUser.getId());
+            TestUtils.endSession(true);
+        } catch (Exception ex) {
+            log.error(ex);
+        }
+        
+        log.info("END");
+    }
+    
+    
+    /**
+     * Test WeblogCategoryData.equals() method.
+     */
+    public void testWeblogCategoryEquality() throws Exception {
+        
+        log.info("BEGIN");
+        
+        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
+        
+        WeblogCategoryData root = mgr.getRootWeblogCategory(testWeblog);
+        
+        WeblogCategoryData testCat = new WeblogCategoryData(testWeblog, null, "root", "root",
null);
+        assertTrue(root.equals(testCat));
+        
+        testCat = new WeblogCategoryData(testWeblog, root, "root", "root", null);
+        assertFalse(root.equals(testCat));
+        
+        log.info("END");
+    }
+    
+    
+    /**
+     * Test basic persistence operations ... Create, Update, Delete.
+     */
+    public void testBasicCRUD() throws Exception {
+        
+        log.info("BEGIN");
+        
+        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
+        WeblogCategoryData cat = null;
+        List cats = null;
+        
+        // root category is always available
+        WeblogCategoryData root = mgr.getRootWeblogCategory(testWeblog);
+        
+        // make sure we are starting with 0 categories (beneath root)
+        assertEquals(0, root.getWeblogCategories().size());
+        
+        // add a new category
+        WeblogCategoryData newCat = new WeblogCategoryData(TestUtils.getManagedWebsite(testWeblog),
root, "catTestCategory", null, null);
+        mgr.saveWeblogCategory(newCat);
+        TestUtils.endSession(true);
+        
+        // make sure category was added
+        cat = null;
+        cat = mgr.getWeblogCategory(newCat.getId());
+        assertNotNull(cat);
+        assertEquals(newCat, cat);
+        
+        // make sure category count increased
+        root = mgr.getRootWeblogCategory(testWeblog);
+        assertEquals(1, root.getWeblogCategories().size());
+        
+        // update category
+        cat.setName("testtest");
+        mgr.saveWeblogCategory(cat);
+        TestUtils.endSession(true);
+        
+        // verify category was updated
+        cat = null;
+        cat = mgr.getWeblogCategory(newCat.getId());
+        assertNotNull(cat);
+        assertEquals("testtest", cat.getName());
+        
+        // remove category
+        mgr.removeWeblogCategory(cat);
+        TestUtils.endSession(true);
+        
+        // make sure cat was removed
+        cat = null;
+        cat = mgr.getWeblogCategory(newCat.getId());
+        assertNull(cat);
+        
+        // make sure category count decreased
+        root = mgr.getRootWeblogCategory(testWeblog);
+        assertEquals(0, root.getWeblogCategories().size());
+        
+        log.info("END");
+    }
+    
+    
+    /**
+     * Make sure that deleting a category deletes all child categories.
+     */
+    public void testCategoryCascadingDelete() throws Exception {
+        
+        log.info("BEGIN");
+        
+        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
+        
+        // root category is always available
+        WeblogCategoryData root = mgr.getRootWeblogCategory(testWeblog);
+        
+        // add a small category tree /subcat/subcat2
+        WeblogCategoryData subcat = new WeblogCategoryData(testWeblog, root, "subcatTest1",
null, null);
+        root.addCategory(subcat);
+        mgr.saveWeblogCategory(subcat);
+        WeblogCategoryData subcat2 = new WeblogCategoryData(testWeblog, subcat, "subcatTest2",
null, null);
+        subcat.addCategory(subcat2);
+        mgr.saveWeblogCategory(subcat2);
+        TestUtils.endSession(true);
+        
+        // check that subcat tree can be navigated
+        root = mgr.getRootWeblogCategory(testWeblog);
+        assertEquals(1, root.getWeblogCategories().size());
+        subcat = (WeblogCategoryData) root.getWeblogCategories().iterator().next();
+        assertEquals("subcatTest1", subcat.getName());
+        assertEquals(1, subcat.getWeblogCategories().size());
+        subcat2 = (WeblogCategoryData) subcat.getWeblogCategories().iterator().next();
+        assertEquals("subcatTest2", subcat2.getName());
+        
+        // now delete category and subcats should be deleted by cascade
+        mgr.removeWeblogCategory(subcat);
+        TestUtils.endSession(true);
+        
+        // verify cascading delete succeeded
+        root = mgr.getRootWeblogCategory(testWeblog);
+        assertEquals(0, root.getWeblogCategories().size());
+        assertNull(mgr.getWeblogCategoryByPath(TestUtils.getManagedWebsite(testWeblog), "/subcatTest1/subcatTest2"));
+        
+        log.info("END");
+    }
+    
+}

Added: incubator/roller/trunk/tests/org/apache/roller/business/WeblogCategoryParentDeletesTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/tests/org/apache/roller/business/WeblogCategoryParentDeletesTest.java?view=auto&rev=501623
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/business/WeblogCategoryParentDeletesTest.java
(added)
+++ incubator/roller/trunk/tests/org/apache/roller/business/WeblogCategoryParentDeletesTest.java
Tue Jan 30 14:52:34 2007
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.business;
+
+import junit.framework.TestCase;
+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.pojos.UserData;
+import org.apache.roller.pojos.WeblogCategoryData;
+import org.apache.roller.pojos.WebsiteData;
+
+
+/**
+ * Test deleting of WeblogCategory parent objects to test cascading deletes.
+ */
+public class WeblogCategoryParentDeletesTest extends TestCase {
+    
+    public static Log log = LogFactory.getLog(WeblogCategoryParentDeletesTest.class);
+    
+    UserData testUser = null;
+    WebsiteData testWeblog = null;
+    
+    
+    /**
+     * All tests in this suite require a user and a weblog.
+     */
+    public void setUp() {
+        
+        log.info("BEGIN");
+        
+        try {
+            testUser = TestUtils.setupUser("categoryParentDeletesTestUser");
+            testWeblog = TestUtils.setupWeblog("categoryParentDeletesTestWeblog", testUser);
+            TestUtils.endSession(true);
+        } catch (Exception ex) {
+            log.error(ex);
+        }
+        
+        log.info("END");
+    }
+    
+    public void tearDown() {
+        
+        log.info("BEGIN");
+        
+        try {
+            TestUtils.teardownUser(testUser.getId());
+            TestUtils.endSession(true);
+        } catch (Exception ex) {
+            log.error(ex);
+        }
+        
+        log.info("END");
+    }
+    
+    
+    /**
+     * Test that deleting a categories parent object deletes all categories.
+     */
+    public void testCategoryParentDeletes() throws Exception {
+        
+        log.info("BEGIN");
+        
+        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
+        
+        // root category is always available
+        WeblogCategoryData root = mgr.getRootWeblogCategory(testWeblog);
+        
+        // add a small category tree /subcat/subcat2
+        WeblogCategoryData subcat = new WeblogCategoryData(testWeblog, root, "categoryParentDeletes1",
null, null);
+        root.addCategory(subcat);
+        mgr.saveWeblogCategory(subcat);
+        WeblogCategoryData subcat2 = new WeblogCategoryData(testWeblog, subcat, "categoryParentDeletes2",
null, null);
+        subcat.addCategory(subcat2);
+        mgr.saveWeblogCategory(subcat2);
+        TestUtils.endSession(true);
+        
+        // now delete the weblog owning these categories
+        Exception ex = null;
+        try {
+            UserManager umgr = RollerFactory.getRoller().getUserManager();
+            umgr.removeWebsite(TestUtils.getManagedWebsite(testWeblog));
+            TestUtils.endSession(true);
+        } catch (RollerException e) {
+            ex = e;
+        }
+        assertNull(ex);
+        
+        log.info("END");
+    }
+    
+}

Modified: incubator/roller/trunk/tests/org/apache/roller/business/WeblogCategoryTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/tests/org/apache/roller/business/WeblogCategoryTest.java?view=diff&rev=501623&r1=501622&r2=501623
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/business/WeblogCategoryTest.java (original)
+++ incubator/roller/trunk/tests/org/apache/roller/business/WeblogCategoryTest.java Tue Jan
30 14:52:34 2007
@@ -18,15 +18,13 @@
 
 package org.apache.roller.business;
 
+import java.util.Iterator;
 import java.util.List;
-import junit.framework.Test;
+import java.util.Set;
 import junit.framework.TestCase;
-import junit.framework.TestSuite;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.TestUtils;
-import org.apache.roller.business.RollerFactory;
-import org.apache.roller.business.WeblogManager;
 import org.apache.roller.pojos.UserData;
 import org.apache.roller.pojos.WeblogCategoryData;
 import org.apache.roller.pojos.WeblogEntryData;
@@ -43,186 +41,186 @@
     
     UserData testUser = null;
     WebsiteData testWeblog = null;
-    
-    
-    public WeblogCategoryTest() {
-    }
-    
-    
-    public static Test suite() {
-        return new TestSuite(WeblogCategoryTest.class);
-    }
+    WeblogCategoryData cat1 = null;
+    WeblogCategoryData cat2 = null;
+    WeblogCategoryData cat3 = null;
+    WeblogCategoryData testCat = null;
     
     
     /**
      * All tests in this suite require a user and a weblog.
      */
-    public void setUp() throws Exception {
+    public void setUp() {
         
-        log.info("Setup "+this.getClass().getName());
+        log.info("BEGIN");
         
         try {
-            testUser = TestUtils.setupUser("entryTestUser");
-            testWeblog = TestUtils.setupWeblog("entryTestWeblog", testUser);
+            testUser = TestUtils.setupUser("categoryTestUser");
+            testWeblog = TestUtils.setupWeblog("categoryTestWeblog", testUser);
+            
+            // setup a category tree to use for testing
+            cat1 = TestUtils.setupWeblogCategory(testWeblog, "catTest-cat1", null);
+            cat2 = TestUtils.setupWeblogCategory(testWeblog, "catTest-cat2", cat1);
+            cat3 = TestUtils.setupWeblogCategory(testWeblog, "catTest-cat3", cat2);
+            
+            // a simple test cat at the root level
+            testCat = TestUtils.setupWeblogCategory(testWeblog, "catTest-testCat", null);
+            
             TestUtils.endSession(true);
-        } catch (Exception ex) {
-            log.error(ex);
-            throw new Exception("Test setup failed", ex);
+        } catch (Throwable t) {
+            log.error(t);
         }
+        
+        log.info("END");
     }
     
-    public void tearDown() throws Exception {
+    public void tearDown() {
         
-        log.info("Teardown "+this.getClass().getName());
+        log.info("BEGIN");
         
         try {
             TestUtils.teardownWeblog(testWeblog.getId());
             TestUtils.teardownUser(testUser.getId());
             TestUtils.endSession(true);
-        } catch (Exception ex) {
-            log.error(ex);
-            throw new Exception("Test teardown failed", ex);
+        } catch (Throwable t) {
+            log.error(t);
         }
+        
+        log.info("END");
     }
     
     
     /**
-     * Test basic persistence operations ... Create, Update, Delete.
+     * Test that we can walk a category tree.
      */
-    public void testWeblogCategoryCRUD() throws Exception {
+    public void testWalkCategoryTree() throws Exception {
+        
+        log.info("BEGIN");
         
         WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
-        WeblogCategoryData cat = null;
-        List cats = null;
         
-        WeblogCategoryData root = mgr.getRootWeblogCategory(testWeblog);
+        // start at root
+        WeblogCategoryData root = mgr.getRootWeblogCategory(TestUtils.getManagedWebsite(testWeblog));
         
-        // make sure we are starting with 0 categories (beneath root)
-        assertEquals(0, root.getWeblogCategories().size());
+        // walk first level
+        Set cats = root.getWeblogCategories();
+        assertEquals(2, cats.size());
+        assertTrue(cats.contains(testCat));
         
-        // add a new category
-        WeblogCategoryData newCat = new WeblogCategoryData(TestUtils.getManagedWebsite(testWeblog),
root, "catTestCategory", null, null);
-        mgr.saveWeblogCategory(newCat);
-        TestUtils.endSession(true);
+        // find cat1
+        WeblogCategoryData cat = null;
+        for(Iterator it = cats.iterator(); it.hasNext(); ) {
+            cat = (WeblogCategoryData) it.next();
+            if(cat.getName().equals(cat1.getName())) {
+                break;
+            }
+        }
         
-        // make sure category was added
-        cat = null;
-        cat = mgr.getWeblogCategory(newCat.getId());
-        assertNotNull(cat);
-        assertEquals(newCat, cat);
+        // walk second level
+        cats = cat.getWeblogCategories();
+        assertEquals(1, cats.size());
+        assertTrue(cats.contains(cat2));
+        
+        // find cat2
+        cat = (WeblogCategoryData) cats.iterator().next();
+        
+        // walk third level
+        cats = cat.getWeblogCategories();
+        assertEquals(1, cats.size());
+        assertTrue(cats.contains(cat3));
+        
+        // find cat3
+        cat = (WeblogCategoryData) cats.iterator().next();
+        
+        // make sure this is the end of the tree
+        cats = cat.getWeblogCategories();
+        assertEquals(0, cats.size());
         
-        // make sure category count increased
-        root = mgr.getRootWeblogCategory(testWeblog);
-        assertEquals(1, root.getWeblogCategories().size());
-        
-        // update category
-        cat.setName("testtest");
-        mgr.saveWeblogCategory(cat);
-        TestUtils.endSession(true);
+        log.info("END");
+    }
+    
+    
+    /**
+     * Test the hasCategory() method on WeblogCategoryData.
+     */
+    public void testHasCategory() throws Exception {
         
-        // verify category was updated
-        cat = null;
-        cat = mgr.getWeblogCategory(newCat.getId());
-        assertNotNull(cat);
-        assertEquals("testtest", cat.getName());
+        log.info("BEGIN");
         
-        // add a subcat
-        WeblogCategoryData subcat = new WeblogCategoryData(TestUtils.getManagedWebsite(testWeblog),
cat, "subcatTest1", null, null);
-        mgr.saveWeblogCategory(subcat);
-        TestUtils.endSession(true);
+        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
         
-        // check that subcat was saved and we can navigate to it
-        root = mgr.getRootWeblogCategory(testWeblog);
-        assertEquals(1, root.getWeblogCategories().size());
-        cat = (WeblogCategoryData) root.getWeblogCategories().iterator().next();
-        assertEquals("testtest", cat.getName());
-        assertEquals(1, cat.getWeblogCategories().size());
-        subcat = (WeblogCategoryData) cat.getWeblogCategories().iterator().next();
-        assertEquals("subcatTest1", subcat.getName());
+        WeblogCategoryData root = mgr.getRootWeblogCategory(TestUtils.getManagedWebsite(testWeblog));
         
-        // remove category, should cascade to subcat
-        mgr.removeWeblogCategory(cat);
-        TestUtils.endSession(true);
+        // check that root has category
+        assertTrue(root.hasCategory(testCat.getName()));
         
-        // make sure folder and subfolder was removed
-        cat = null;
-        cat = mgr.getWeblogCategory(newCat.getId());
-        assertNull(cat);
-        cat = mgr.getWeblogCategory(subcat.getId());
-        assertNull(cat);
-        
-        // make sure category count decreased
-        root = mgr.getRootWeblogCategory(testWeblog);
-        assertEquals(0, root.getWeblogCategories().size());
+        log.info("END");
     }
     
     
     /**
-     * Test lookup mechanisms ... 
+     * Lookup category by id.
      */
-    public void testWeblogCategoryLookups() throws Exception {
+    public void testLookupCategoryById() throws Exception {
+        
+        log.info("BEGIN");
+        
+        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
         
+        WeblogCategoryData cat = mgr.getWeblogCategory(testCat.getId());
+        assertNotNull(cat);
+        assertEquals(cat, testCat);
+        
+        log.info("END");
     }
     
     
     /**
-     * Test WeblogCategoryData.equals() method.
+     * Lookup category by path.
      */
-    public void testWeblogCategoryEquality() throws Exception {
+    public void testLookupCategoryByPath() throws Exception {
+        
+        log.info("BEGIN");
         
         WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
         
-        WeblogCategoryData root = mgr.getRootWeblogCategory(testWeblog);
+        WeblogCategoryData cat = mgr.getWeblogCategoryByPath(testWeblog, "/catTest-cat1");
+        assertNotNull(cat);
+        assertEquals(cat, cat1);
         
-        WeblogCategoryData testCat = new WeblogCategoryData(testWeblog, null, "root", "root",
null);
-        assertTrue(root.equals(testCat));
+        cat = mgr.getWeblogCategoryByPath(testWeblog, "/catTest-cat1/catTest-cat2/catTest-cat3");
+        assertNotNull(cat);
+        assertEquals(cat, cat3);
         
-        testCat = new WeblogCategoryData(testWeblog, root, "root", "root", null);
-        assertFalse(root.equals(testCat));
+        log.info("END");
     }
     
     
     /**
-     * Test working with category paths.
+     * Lookup all categories for a weblog.
      */
-    public void testWeblogCategoryPaths() throws Exception {
-        
-        WeblogCategoryData root = null;
-        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
+    public void testLookupAllCategoriesByWeblog() throws Exception {
         
-        root = mgr.getRootWeblogCategory(testWeblog);
+        log.info("BEGIN");
         
-        WeblogCategoryData f1 = new WeblogCategoryData(TestUtils.getManagedWebsite(testWeblog),
root, "f1", null, null);
-        mgr.saveWeblogCategory(f1);
-        
-        WeblogCategoryData f2 = new WeblogCategoryData(TestUtils.getManagedWebsite(testWeblog),
f1, "f2", null, null);
-        mgr.saveWeblogCategory(f2);
-        
-        WeblogCategoryData f3 = new WeblogCategoryData(TestUtils.getManagedWebsite(testWeblog),
f2, "f3", null, null);
-        mgr.saveWeblogCategory(f3);
+        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
         
-        TestUtils.endSession(true);
+        // default, including root
+        List cats = mgr.getWeblogCategories(testWeblog);
+        assertNotNull(cats);
+        assertEquals(5, cats.size());
+        
+        // including root
+        cats = mgr.getWeblogCategories(testWeblog, true);
+        assertNotNull(cats);
+        assertEquals(5, cats.size());
+        
+        // not including root
+        cats = mgr.getWeblogCategories(testWeblog, false);
+        assertNotNull(cats);
+        assertEquals(4, cats.size());
         
-        // test get by path
-        assertEquals("f1",
-                mgr.getWeblogCategoryByPath(testWeblog, null, "f1").getName());
-        
-        assertEquals("f1",
-                mgr.getWeblogCategoryByPath(testWeblog, null, "/f1").getName());
-        
-        assertEquals("f2",
-                mgr.getWeblogCategoryByPath(testWeblog, null, "/f1/f2").getName());
-        
-        assertEquals("f3",
-                mgr.getWeblogCategoryByPath(testWeblog, null, "/f1/f2/f3").getName());
-        
-        // test path creation
-        f3 = mgr.getWeblogCategoryByPath(testWeblog, null, "/f1/f2/f3");
-        String pathString = f3.getPath();
-        String[] pathArray = Utilities.stringToStringArray(pathString,"/");
-        assertEquals("f1", pathArray[0]);
-        assertEquals("f2", pathArray[1]);
-        assertEquals("f3", pathArray[2]);
+        log.info("END");
     }
     
     
@@ -362,27 +360,6 @@
         // c1 category should be empty now
         assertEquals(0, c1.retrieveWeblogEntries(false).size());
 
-    }
-    
-    
-    /**
-     * Test the hasCategory() method on WeblogCategoryData.
-     */
-    public void testHasCategory() throws Exception {
-        
-        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
-        
-        WeblogCategoryData root = mgr.getRootWeblogCategory(testWeblog);
-        
-        // add some categories to test with
-        WeblogCategoryData c1 = new WeblogCategoryData(TestUtils.getManagedWebsite(testWeblog),
root, "c1", null, null);
-        mgr.saveWeblogCategory(c1);
-        
-        TestUtils.endSession(true);
-        
-        // check that root has category c1
-        root = mgr.getWeblogCategory(root.getId());
-        assertTrue(root.hasCategory("c1"));
     }
     
 }



Mime
View raw message