roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r1588757 [23/25] - in /roller/branches/rome2/app/src: main/java/org/apache/roller/ main/java/org/apache/roller/planet/business/ main/java/org/apache/roller/planet/business/fetcher/ main/java/org/apache/roller/planet/business/jpa/ main/java/...
Date Sun, 20 Apr 2014 13:39:01 GMT
Modified: roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/BookmarkTest.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/BookmarkTest.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/BookmarkTest.java (original)
+++ roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/BookmarkTest.java Sun Apr 20 13:38:51 2014
@@ -85,9 +85,9 @@ public class BookmarkTest extends TestCa
         BookmarkManager bmgr = getRoller().getBookmarkManager();
         
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        WeblogBookmarkFolder root = bmgr.getRootFolder(testWeblog);
+        WeblogBookmarkFolder root = bmgr.getDefaultFolder(testWeblog);
         
-        WeblogBookmarkFolder folder = new WeblogBookmarkFolder(root, "TestFolder2", null, TestUtils.getManagedWebsite(testWeblog));
+        WeblogBookmarkFolder folder = new WeblogBookmarkFolder("TestFolder2", TestUtils.getManagedWebsite(testWeblog));
         bmgr.saveFolder(folder);
         TestUtils.endSession(true);
         
@@ -101,10 +101,7 @@ public class BookmarkTest extends TestCa
                 "created by testBookmarkCRUD()",
                 "http://www.example.com",
                 "http://www.example.com/rss.xml",
-                new Integer(1),
-                new Integer(12),
                 "test.jpg");
-        bookmark1.setFolder(folder);
         folder.addBookmark(bookmark1);
         
         // Add another bookmark
@@ -114,10 +111,7 @@ public class BookmarkTest extends TestCa
                 "created by testBookmarkCRUD()",
                 "http://www.example.com",
                 "http://www.example.com/rss.xml",
-                new Integer(1),
-                new Integer(12),
                 "test.jpf");
-        bookmark2.setFolder(folder);
         folder.addBookmark(bookmark2);
         
         TestUtils.endSession(true);
@@ -162,14 +156,14 @@ public class BookmarkTest extends TestCa
         BookmarkManager bmgr = getRoller().getBookmarkManager();
         
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        WeblogBookmarkFolder root = bmgr.getRootFolder(testWeblog);
+        WeblogBookmarkFolder root = bmgr.getDefaultFolder(testWeblog);
         
         // add some folders
-        WeblogBookmarkFolder f1 = new WeblogBookmarkFolder(root, "f1", null, TestUtils.getManagedWebsite(testWeblog));
+        WeblogBookmarkFolder f1 = new WeblogBookmarkFolder("f1", TestUtils.getManagedWebsite(testWeblog));
         bmgr.saveFolder(f1);
-        WeblogBookmarkFolder f2 = new WeblogBookmarkFolder(f1, "f2", null, TestUtils.getManagedWebsite(testWeblog));
+        WeblogBookmarkFolder f2 = new WeblogBookmarkFolder("f2", TestUtils.getManagedWebsite(testWeblog));
         bmgr.saveFolder(f2);
-        WeblogBookmarkFolder f3 = new WeblogBookmarkFolder(root, "f3", null, TestUtils.getManagedWebsite(testWeblog));
+        WeblogBookmarkFolder f3 = new WeblogBookmarkFolder("f3", TestUtils.getManagedWebsite(testWeblog));
         bmgr.saveFolder(f3);
         
         TestUtils.endSession(true);
@@ -181,17 +175,17 @@ public class BookmarkTest extends TestCa
         WeblogBookmark b1 = new WeblogBookmark(
                 f1, "b1", "testbookmark",
                 "http://example.com", "http://example.com/rss",
-                new Integer(1), new Integer(1), "image.gif");
+                "image.gif");
         bmgr.saveBookmark(b1);
         WeblogBookmark b2 = new WeblogBookmark(
                 f1, "b2", "testbookmark",
                 "http://example.com", "http://example.com/rss",
-                new Integer(1), new Integer(1), "image.gif");
+                "image.gif");
         bmgr.saveBookmark(b2);
         WeblogBookmark b3 = new WeblogBookmark(
                 f2, "b3", "testbookmark",
                 "http://example.com", "http://example.com/rss",
-                new Integer(1), new Integer(1), "image.gif");
+                "image.gif");
         bmgr.saveBookmark(b3);
         
         TestUtils.endSession(true);
@@ -203,18 +197,13 @@ public class BookmarkTest extends TestCa
         
         // test lookup of all bookmarks in single folder
         WeblogBookmarkFolder testFolder = bmgr.getFolder(f1.getId());
-        List allBookmarks = bmgr.getBookmarks(testFolder, false);
+        List allBookmarks = bmgr.getBookmarks(testFolder);
         assertNotNull(allBookmarks);
         assertEquals(2, allBookmarks.size());
         
         // getBookmarks(folder, false) should also match folder.getBookmarks()
         assertEquals(allBookmarks.size(), testFolder.getBookmarks().size());
         
-        // test lookup of all bookmarks in folder branch (including subfolders)
-        testFolder = bmgr.getFolder(f1.getId());
-        allBookmarks = bmgr.getBookmarks(testFolder, true);
-        assertNotNull(allBookmarks);
-        assertEquals(3, allBookmarks.size());
     }
     
     
@@ -238,42 +227,42 @@ public class BookmarkTest extends TestCa
         try {        
 
             testWeblog = TestUtils.getManagedWebsite(testWeblog);
-            WeblogBookmarkFolder root = bmgr.getRootFolder(testWeblog);
+            WeblogBookmarkFolder root = bmgr.getDefaultFolder(testWeblog);
 
-            WeblogBookmarkFolder dest = new WeblogBookmarkFolder(root, "dest", null, testWeblog);
+            WeblogBookmarkFolder dest = new WeblogBookmarkFolder("dest", testWeblog);
             bmgr.saveFolder(dest);
 
             // create source folder f1
-            WeblogBookmarkFolder f1 = new WeblogBookmarkFolder(root, "f1", null, testWeblog);
+            WeblogBookmarkFolder f1 = new WeblogBookmarkFolder("f1", testWeblog);
             bmgr.saveFolder(f1);
 
             // create bookmark b1 inside source folder f1
             WeblogBookmark b1 = new WeblogBookmark(
                     f1, "b1", "testbookmark",
                     "http://example.com", "http://example.com/rss",
-                    new Integer(1), new Integer(1), "image.gif");
+                    "image.gif");
             f1.addBookmark(b1);
 
             // create folder f2 inside f1
-            WeblogBookmarkFolder f2 = new WeblogBookmarkFolder(f1, "f2", null, testWeblog);
+            WeblogBookmarkFolder f2 = new WeblogBookmarkFolder("f2", testWeblog);
             bmgr.saveFolder(f2);
 
             // create bookmark b2 inside folder f2
             WeblogBookmark b2 = new WeblogBookmark(
                     f2, "b2", "testbookmark",
                     "http://example.com", "http://example.com/rss",
-                    new Integer(1), new Integer(1), "image.gif");
+                    "image.gif");
             f2.addBookmark(b2);
 
             // create folder f3 inside folder f2
-            WeblogBookmarkFolder f3 = new WeblogBookmarkFolder(f2, "f3", null, testWeblog);
+            WeblogBookmarkFolder f3 = new WeblogBookmarkFolder("f3", testWeblog);
             bmgr.saveFolder(f3);
 
             // crete bookmark b3 inside folder f3
             WeblogBookmark b3 = new WeblogBookmark(
                     f3, "b3", "testbookmark",
                     "http://example.com", "http://example.com/rss",
-                    new Integer(1), new Integer(1), "image.gif");
+                    "image.gif");
             f3.addBookmark(b3);
 
             TestUtils.endSession(true);
@@ -287,34 +276,12 @@ public class BookmarkTest extends TestCa
             assertEquals(1, f1.getBookmarks().size());
             assertEquals(1, f2.getBookmarks().size());
             assertEquals(1, f3.getBookmarks().size());
-            assertEquals(0, dest.retrieveBookmarks(true).size());
-            assertEquals(3, f1.retrieveBookmarks(true).size());
-
-            // test that parent cannot be moved into child
-            boolean safe = false;
-            try {
-                // Move folder into one of it's children
-                bmgr.moveFolder(f1, f3);
-                TestUtils.endSession(true);
-            } catch (WebloggerException e) {
-                safe = true;
-            }
-            assertTrue(safe);
-
-            // move f1 to dest
-            f1   = bmgr.getFolder( f1.getId());   //Get managed copy
-            dest = bmgr.getFolder( dest.getId()); //Get managed copy
-            bmgr.moveFolder(f1, dest);
-            TestUtils.endSession(true);
-
-            // after move, verify number of entries in eacch folder
-            dest = bmgr.getFolder(dest.getId());
-            f1 = bmgr.getFolder(f1.getId());
-            assertEquals(3, dest.retrieveBookmarks(true).size());
+            assertEquals(0, dest.retrieveBookmarks().size());
+            assertEquals(3, f1.retrieveBookmarks().size());
 
             // check that paths and child folders are correct
-            assertEquals("/dest/f1", f1.getPath());
-            assertEquals(1, dest.getFolders().size());
+            assertEquals("f1", f1.getName());
+            assertEquals(1, dest.getWeblog().getBookmarkFolders().size());
         
             bmgr.removeFolder(f1);
             bmgr.removeFolder(dest);
@@ -339,7 +306,7 @@ public class BookmarkTest extends TestCa
         
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
         fd = getRoller().getBookmarkManager().getFolder(testWeblog, "ZZZ_imports_ZZZ");
-        assertTrue(fd.retrieveBookmarks(true).size() > 0 );
+        assertTrue(fd.retrieveBookmarks().size() > 0 );
         getRoller().getBookmarkManager().removeFolder(fd);
         TestUtils.endSession(true);
     }

Modified: roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/CommentTest.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/CommentTest.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/CommentTest.java (original)
+++ roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/CommentTest.java Sun Apr 20 13:38:51 2014
@@ -28,6 +28,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.TestUtils;
+import org.apache.roller.weblogger.pojos.CommentSearchCriteria;
 import org.apache.roller.weblogger.pojos.WeblogEntryComment;
 import org.apache.roller.weblogger.pojos.User;
 import org.apache.roller.weblogger.pojos.WeblogEntry;
@@ -114,7 +115,6 @@ public class CommentTest extends TestCas
         TestUtils.endSession(true);
         
         // make sure comment was created
-        comment = null;
         comment = mgr.getComment(id);
         assertNotNull(comment);
         assertEquals("this is a test comment", comment.getContent());
@@ -125,7 +125,6 @@ public class CommentTest extends TestCas
         TestUtils.endSession(true);
         
         // make sure comment was updated
-        comment = null;
         comment = mgr.getComment(id);
         assertNotNull(comment);
         assertEquals("testtest", comment.getContent());
@@ -135,7 +134,6 @@ public class CommentTest extends TestCas
         TestUtils.endSession(true);
         
         // make sure comment was deleted
-        comment = null;
         comment = mgr.getComment(id);
         assertNull(comment);
     }
@@ -147,7 +145,7 @@ public class CommentTest extends TestCas
     public void testCommentLookups() throws Exception {
         
         WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
-        List comments = null;
+        List comments;
         
         // we need some comments to play with
         testEntry = TestUtils.getManagedWeblogEntry(testEntry);
@@ -157,15 +155,15 @@ public class CommentTest extends TestCas
         TestUtils.endSession(true);
         
         // get all comments
-        comments = null;
-        comments = mgr.getComments(null, null, null, null, null, null, false, 0, -1);
+        CommentSearchCriteria csc = new CommentSearchCriteria();
+        comments = mgr.getComments(csc);
         assertNotNull(comments);
         assertEquals(3, comments.size());
         
         // get all comments for entry
         testEntry = TestUtils.getManagedWeblogEntry(testEntry);
-        comments = null;
-        comments = mgr.getComments(null, testEntry, null, null, null, null, false, 0, -1);
+        csc.setEntry(testEntry);
+        comments = mgr.getComments(csc);
         assertNotNull(comments);
         assertEquals(3, comments.size());
         
@@ -176,20 +174,22 @@ public class CommentTest extends TestCas
         TestUtils.endSession(true);
         
         // get pending comments
-        comments = null;
-        comments = mgr.getComments(null, null, null, null, null, WeblogEntryComment.PENDING, false, 0, -1);
+        csc.setEntry(null);
+        csc.setStatus(WeblogEntryComment.PENDING);
+        comments = mgr.getComments(csc);
         assertNotNull(comments);
         assertEquals(1, comments.size());
         
         // get approved comments
-        comments = null;
-        comments = mgr.getComments(null, null, null, null, null, WeblogEntryComment.APPROVED, false, 0, -1);
+        csc.setStatus(WeblogEntryComment.APPROVED);
+        comments = mgr.getComments(csc);
         assertNotNull(comments);
         assertEquals(2, comments.size());
         
         // get comments with offset
-        comments = null;
-        comments = mgr.getComments(null, null, null, null, null, null, false, 1, -1);
+        csc.setStatus(null);
+        csc.setOffset(1);
+        comments = mgr.getComments(csc);
         assertNotNull(comments);
         assertEquals(2, comments.size());
         

Modified: roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/FolderCRUDTest.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/FolderCRUDTest.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/FolderCRUDTest.java (original)
+++ roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/FolderCRUDTest.java Sun Apr 20 13:38:51 2014
@@ -26,7 +26,6 @@ import org.apache.roller.weblogger.pojos
 import org.apache.roller.weblogger.pojos.User;
 import org.apache.roller.weblogger.pojos.Weblog;
 
-
 /**
  * Test basic folder operations.
  */
@@ -78,28 +77,6 @@ public class FolderCRUDTest extends Test
     
     
     /**
-     * Test WeblogBookmarkFolder.equals() method.
-     */
-    public void testFolderEquality() throws Exception {
-        
-        log.info("BEGIN");
-        
-        BookmarkManager bmgr = WebloggerFactory.getWeblogger().getBookmarkManager();
-        
-        testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        WeblogBookmarkFolder root = bmgr.getRootFolder(testWeblog);
-        
-        WeblogBookmarkFolder testFolder = new WeblogBookmarkFolder(null, "root", "root", TestUtils.getManagedWebsite(testWeblog));
-        assertTrue(root.equals(testFolder));
-        
-        testFolder = new WeblogBookmarkFolder(root, "root", "root", TestUtils.getManagedWebsite(testWeblog));
-        assertFalse(root.equals(testFolder));
-        
-        log.info("END");
-    }
-    
-    
-    /**
      * Test add/modify/remove of folders.
      */
     public void testBasicCRUD() throws Exception {
@@ -109,22 +86,21 @@ public class FolderCRUDTest extends Test
         BookmarkManager bmgr = WebloggerFactory.getWeblogger().getBookmarkManager();
         
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        WeblogBookmarkFolder root = bmgr.getRootFolder(testWeblog);
+        WeblogBookmarkFolder root = bmgr.getDefaultFolder(testWeblog);
         
-        // start out with no folders and no bookmarks
-        assertEquals(0, root.getFolders().size());
+        // start out with just default folder and no bookmarks
+        assertEquals(1, testWeblog.getBookmarkFolders().size());
         assertEquals(0, root.getBookmarks().size());
         
         // add a folder
-        WeblogBookmarkFolder newFolder = new WeblogBookmarkFolder(root, "folderBasicCRUD", null, TestUtils.getManagedWebsite(testWeblog));
+        WeblogBookmarkFolder newFolder = new WeblogBookmarkFolder("folderBasicCRUD", TestUtils.getManagedWebsite(testWeblog));
         bmgr.saveFolder(newFolder);
         TestUtils.endSession(true);
         
         // check that folder was saved
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        root = bmgr.getRootFolder(testWeblog);
-        assertEquals(1, root.getFolders().size());
-        WeblogBookmarkFolder folder = (WeblogBookmarkFolder) root.getFolders().iterator().next();
+        assertEquals(2, testWeblog.getBookmarkFolders().size());
+        WeblogBookmarkFolder folder = testWeblog.getBookmarkFolders().get(1);
         assertEquals(newFolder, folder);
         
         // modify folder
@@ -134,8 +110,7 @@ public class FolderCRUDTest extends Test
         
         // check that folder was saved
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        root = bmgr.getRootFolder(testWeblog);
-        folder = (WeblogBookmarkFolder) root.getFolders().iterator().next();
+        folder = testWeblog.getBookmarkFolders().get(1);
         assertEquals("folderTest1", folder.getName());
         
         // test remove folder
@@ -144,57 +119,11 @@ public class FolderCRUDTest extends Test
         
         // make sure folder was removed
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        root = bmgr.getRootFolder(testWeblog);
-        assertEquals(0, root.getFolders().size());
+        assertEquals(1, testWeblog.getBookmarkFolders().size());
         folder = bmgr.getFolder(newFolder.getId());
         assertNull(folder);
         
         log.info("END");
     }
-    
-    
-    /**
-     * Make sure that deleting a folder deletes all child folders.
-     */
-    public void testFolderCascadingDelete() throws Exception {
-        
-        log.info("BEGIN");
-        
-        BookmarkManager bmgr = WebloggerFactory.getWeblogger().getBookmarkManager();
-        
-        testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        WeblogBookmarkFolder root = bmgr.getRootFolder(testWeblog);
-        
-        // add a small tree /fold1/fold2
-        WeblogBookmarkFolder fold1 = new WeblogBookmarkFolder(root, "fold1", null, testWeblog);
-        root.addFolder(fold1);
-        bmgr.saveFolder(fold1);
-        WeblogBookmarkFolder fold2 = new WeblogBookmarkFolder(fold1, "fold2", null, testWeblog);
-        fold1.addFolder(fold2);
-        bmgr.saveFolder(fold2);
-        TestUtils.endSession(true);
-        
-        // check that tree can be navigated
-        testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        root = bmgr.getRootFolder(testWeblog);
-        assertEquals(1, root.getFolders().size());
-        fold1 = (WeblogBookmarkFolder) root.getFolders().iterator().next();
-        assertEquals("fold1", fold1.getName());
-        assertEquals(1, fold1.getFolders().size());
-        fold2 = (WeblogBookmarkFolder) fold1.getFolders().iterator().next();
-        assertEquals("fold2", fold2.getName());
-        
-        // now delete folder and subfolders should be deleted by cascade
-        bmgr.removeFolder(fold1);
-        TestUtils.endSession(true);
-        
-        // verify cascading delete succeeded
-        testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        root = bmgr.getRootFolder(testWeblog);
-        assertEquals(0, root.getFolders().size());
-        assertNull(bmgr.getFolder(testWeblog, "/fold1/fold2"));
-        
-        log.info("END");
-    }
-    
+
 }

Modified: roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/FolderFunctionalityTest.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/FolderFunctionalityTest.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/FolderFunctionalityTest.java (original)
+++ roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/FolderFunctionalityTest.java Sun Apr 20 13:38:51 2014
@@ -20,9 +20,7 @@ package org.apache.roller.weblogger.busi
 
 import java.io.PrintWriter;
 import java.io.StringWriter;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Set;
 import junit.framework.TestCase;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -60,12 +58,12 @@ public class FolderFunctionalityTest ext
             testWeblog = TestUtils.setupWeblog("folderFuncTestWeblog", testUser);
             
             // setup a category tree to use for testing
-            f1 = TestUtils.setupFolder(testWeblog, "folderFuncTest-f1", null);
-            f2 = TestUtils.setupFolder(testWeblog, "folderFuncTest-f2", f1);
-            f3 = TestUtils.setupFolder(testWeblog, "folderFuncTest-f3", f2);
+            f1 = TestUtils.setupFolder(testWeblog, "folderFuncTest-f1");
+            f2 = TestUtils.setupFolder(testWeblog, "folderFuncTest-f2");
+            f3 = TestUtils.setupFolder(testWeblog, "folderFuncTest-f3");
             
             // a simple test folder at the root level
-            testFolder = TestUtils.setupFolder(testWeblog, "folderFuncTest-testFolder", null);
+            testFolder = TestUtils.setupFolder(testWeblog, "folderFuncTest-testFolder");
             
             TestUtils.endSession(true);
         } catch (Exception ex) {
@@ -94,69 +92,16 @@ public class FolderFunctionalityTest ext
     
     
     /**
-     * Test that we can walk a folder tree.
-     */
-    public void testWalkFolderTree() throws Exception {
-        
-        log.info("BEGIN");
-        
-        BookmarkManager bmgr = WebloggerFactory.getWeblogger().getBookmarkManager();
-        
-        // start at root
-        WeblogBookmarkFolder root = bmgr.getRootFolder(TestUtils.getManagedWebsite(testWeblog));
-        
-        // walk first level
-        Set folders = root.getFolders();
-        assertEquals(2, folders.size());
-        assertTrue(folders.contains(testFolder));
-        
-        // find cat1
-        WeblogBookmarkFolder folder = null;
-        for(Iterator it = folders.iterator(); it.hasNext(); ) {
-            folder = (WeblogBookmarkFolder) it.next();
-            if(folder.getName().equals(f1.getName())) {
-                break;
-            }
-        }
-        
-        // walk second level
-        folders = folder.getFolders();
-        assertEquals(1, folders.size());
-        assertTrue(folders.contains(f2));
-        
-        // find cat2
-        folder = (WeblogBookmarkFolder) folders.iterator().next();
-        
-        // walk third level
-        folders = folder.getFolders();
-        assertEquals(1, folders.size());
-        assertTrue(folders.contains(f3));
-        
-        // find cat3
-        folder = (WeblogBookmarkFolder) folders.iterator().next();
-        
-        // make sure this is the end of the tree
-        folders = folder.getFolders();
-        assertEquals(0, folders.size());
-        
-        log.info("END");
-    }
-    
-    
-    /**
-     * Test the hasFolder() method on WeblogBookmarkFolder.
+     * Test the hasBookmarkFolder() method on Weblog.
      */
     public void testHasFolder() throws Exception {
         
         log.info("BEGIN");
         
-        BookmarkManager bmgr = WebloggerFactory.getWeblogger().getBookmarkManager();
-        
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        WeblogBookmarkFolder root = bmgr.getRootFolder(testWeblog);
-        
-        // check that root has folder
-        assertTrue(root.hasFolder(testFolder.getName()));
+
+        // check that weblog has folder
+        assertTrue(testWeblog.hasBookmarkFolder(testFolder.getName()));
         
         log.info("END");
     }
@@ -170,14 +115,12 @@ public class FolderFunctionalityTest ext
         log.info("BEGIN");
         try {
             BookmarkManager bmgr = WebloggerFactory.getWeblogger().getBookmarkManager();
-
             testWeblog = TestUtils.getManagedWebsite(testWeblog);
-            WeblogBookmarkFolder root = bmgr.getRootFolder(testWeblog);
 
             boolean exception = false;
             try {
                 // child folder with same name as first
-                WeblogBookmarkFolder dupeFolder = new WeblogBookmarkFolder(root, testFolder.getName(), null, testWeblog);
+                WeblogBookmarkFolder dupeFolder = new WeblogBookmarkFolder(testFolder.getName(), testWeblog);
                 bmgr.saveFolder(dupeFolder);
                 TestUtils.endSession(true);
             } catch (Throwable e) {
@@ -219,30 +162,25 @@ public class FolderFunctionalityTest ext
     /**
      * Test folder lookup by id.
      */
-    public void testLookupFolderByPath() throws Exception {
+    public void testLookupFolderByName() throws Exception {
         
         log.info("BEGIN");
         
         BookmarkManager bmgr = WebloggerFactory.getWeblogger().getBookmarkManager();
         
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        WeblogBookmarkFolder folder = bmgr.getFolder(testWeblog, "/folderFuncTest-f1");
+        WeblogBookmarkFolder folder = bmgr.getFolder(testWeblog, "folderFuncTest-f1");
         assertNotNull(folder);
         assertEquals(f1, folder);
         
-        folder = bmgr.getFolder(testWeblog, "/folderFuncTest-f1/folderFuncTest-f2/folderFuncTest-f3");
+        folder = bmgr.getFolder(testWeblog, "folderFuncTest-f3");
         assertNotNull(folder);
         assertEquals(f3, folder);
         
-        // test lazy lookup, with no slashes
-        folder = bmgr.getFolder(testWeblog, "folderFuncTest-f1");
-        assertNotNull(folder);
-        assertEquals(f1, folder);
-        
-        // if no path is specified then we should get root folder
-        folder = bmgr.getFolder(testWeblog, null);
+        // test to check that default folder is accessible
+        folder = bmgr.getDefaultFolder(testWeblog);
         assertNotNull(folder);
-        assertEquals("/", folder.getPath());
+        assertEquals("default", folder.getName());
         
         log.info("END");
     }

Modified: roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/HitCountTest.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/HitCountTest.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/HitCountTest.java (original)
+++ roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/HitCountTest.java Sun Apr 20 13:38:51 2014
@@ -100,7 +100,7 @@ public class HitCountTest extends TestCa
         TestUtils.endSession(true);
         
         // make sure it was created
-        WeblogHitCount hitCount = null;
+        WeblogHitCount hitCount;
         hitCount = mgr.getHitCount(id);
         assertNotNull(hitCount);
         assertEquals(testCount, hitCount);
@@ -112,7 +112,6 @@ public class HitCountTest extends TestCa
         TestUtils.endSession(true);
         
         // make sure it was updated
-        hitCount = null;
         hitCount = mgr.getHitCount(id);
         assertNotNull(hitCount);
         assertEquals(testCount, hitCount);
@@ -123,7 +122,6 @@ public class HitCountTest extends TestCa
         TestUtils.endSession(true);
         
         // make sure it was deleted
-        hitCount = null;
         hitCount = mgr.getHitCount(id);
         assertNull(hitCount);
     }
@@ -144,14 +142,13 @@ public class HitCountTest extends TestCa
         TestUtils.endSession(true);
         
         // test lookup by id
-        WeblogHitCount hitCount = null;
+        WeblogHitCount hitCount;
         hitCount = mgr.getHitCount(id);
         assertNotNull(hitCount);
         assertEquals(testCount, hitCount);
         assertEquals(10, hitCount.getDailyHits());
         
         // test lookup by weblog
-        hitCount = null;
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
         hitCount = mgr.getHitCountByWeblog(testWeblog);
         assertNotNull(hitCount);
@@ -163,7 +160,6 @@ public class HitCountTest extends TestCa
         TestUtils.endSession(true);
         
         // make sure it was deleted
-        hitCount = null;
         hitCount = mgr.getHitCount(id);
         assertNull(hitCount);
     }
@@ -184,7 +180,7 @@ public class HitCountTest extends TestCa
         TestUtils.endSession(true);
         
         // make sure it was created
-        WeblogHitCount hitCount = null;
+        WeblogHitCount hitCount;
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
         hitCount = mgr.getHitCountByWeblog(testWeblog);
         assertNotNull(hitCount);
@@ -195,7 +191,6 @@ public class HitCountTest extends TestCa
         TestUtils.endSession(true);
         
         // make sure it was incremented properly
-        hitCount = null;
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
         hitCount = mgr.getHitCountByWeblog(testWeblog);
         assertNotNull(hitCount);
@@ -206,7 +201,6 @@ public class HitCountTest extends TestCa
         TestUtils.endSession(true);
         
         // make sure it was deleted
-        hitCount = null;
         hitCount = mgr.getHitCount(id);
         assertNull(hitCount);
     }
@@ -228,7 +222,7 @@ public class HitCountTest extends TestCa
         
         try {
             // make sure data was properly initialized
-            WeblogHitCount testCount = null;
+            WeblogHitCount testCount;
             testCount = mgr.getHitCount(cnt1.getId());
             assertEquals(10, testCount.getDailyHits());
             testCount = mgr.getHitCount(cnt2.getId());
@@ -289,7 +283,7 @@ public class HitCountTest extends TestCa
         TestUtils.endSession(true);
         
         // make sure data was properly initialized
-        WeblogHitCount testCount = null;
+        WeblogHitCount testCount;
         testCount = mgr.getHitCount(cnt1.getId());
         assertEquals(10, testCount.getDailyHits());
         testCount = mgr.getHitCount(cnt2.getId());
@@ -303,11 +297,10 @@ public class HitCountTest extends TestCa
         assertEquals(3, hotBlogs.size());
         
         // also check ordering and values
-        WeblogHitCount hitCount = null;
+        WeblogHitCount hitCount;
         Iterator it = hotBlogs.iterator();
-        for(int i=3; it.hasNext(); i--) {
+        for (int i=3; it.hasNext(); i--) {
             hitCount = (WeblogHitCount) it.next();
-            
             assertEquals(i*10, hitCount.getDailyHits());
         }
         

Modified: roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/IndexManagerTest.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/IndexManagerTest.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/IndexManagerTest.java (original)
+++ roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/IndexManagerTest.java Sun Apr 20 13:38:51 2014
@@ -21,6 +21,7 @@ import java.sql.Timestamp;
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
+import org.apache.roller.util.RollerConstants;
 import org.apache.roller.weblogger.TestUtils;
 import org.apache.roller.weblogger.business.search.IndexManagerImpl;
 import org.apache.roller.weblogger.business.search.operations.AddEntryOperation;
@@ -134,7 +135,7 @@ public class IndexManagerTest extends Te
          imgr.executeIndexOperationNow(
              new AddEntryOperation(WebloggerFactory.getWeblogger(), (IndexManagerImpl)imgr, wd2));
 
-        Thread.sleep(1000);
+        Thread.sleep(RollerConstants.SEC_IN_MS);
 
         SearchOperation search = new SearchOperation(imgr);
         search.setTerm("Enterprise");

Modified: roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/MediaFileTest.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/MediaFileTest.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/MediaFileTest.java (original)
+++ roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/MediaFileTest.java Sun Apr 20 13:38:51 2014
@@ -18,7 +18,9 @@
 package org.apache.roller.weblogger.business;
 
 import java.io.File;
+import java.sql.Timestamp;
 import java.util.Arrays;
+import java.util.Calendar;
 import java.util.Collection;
 import java.util.List;
 import java.util.Set;
@@ -172,6 +174,7 @@ public class MediaFileTest extends TestC
         TestUtils.endSession(true);
         TestUtils.teardownWeblog(testWeblog.getId());
         TestUtils.teardownUser(testUser.getUserName());
+        TestUtils.endSession(true);
     }
 
     /**
@@ -226,6 +229,7 @@ public class MediaFileTest extends TestC
         TestUtils.endSession(true);
         TestUtils.teardownWeblog(testWeblog.getId());
         TestUtils.teardownUser(testUser.getUserName());
+        TestUtils.endSession(true);
     }
 
     /**
@@ -273,6 +277,7 @@ public class MediaFileTest extends TestC
         TestUtils.endSession(true);
         TestUtils.teardownWeblog(testWeblog.getId());
         TestUtils.teardownUser(testUser.getUserName());
+        TestUtils.endSession(true);
     }
 
     /**
@@ -311,8 +316,8 @@ public class MediaFileTest extends TestC
      * Test deletion of media file
      */
     public void testDeleteMediaFile() throws Exception {
-        User testUser = null;
-        Weblog testWeblog = null;
+        User testUser;
+        Weblog testWeblog;
         testUser = TestUtils.setupUser("mediaFileTestUser4");
         testWeblog = TestUtils.setupWeblog("mediaFileTestWeblog4", testUser);
 
@@ -377,6 +382,8 @@ public class MediaFileTest extends TestC
         File flag = new File(uploadsDirName + File.separator
                 + "migration-status.properties");
         flag.delete();
+        
+        TestUtils.endSession(true);
     }
 
     /**
@@ -782,6 +789,8 @@ public class MediaFileTest extends TestC
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
         rootDirectory = mfMgr.getMediaFileDirectory(rootDirectory.getId());
         String[] contentTypes = { "image/gif", "image/jpeg", "image/bmp" };
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(new Timestamp(System.currentTimeMillis()));
         for (int i = 0; i < 3; i++) {
             MediaFile mediaFile = new MediaFile();
             mediaFile
@@ -795,6 +804,10 @@ public class MediaFileTest extends TestC
             mediaFile
                     .setInputStream(getClass().getResourceAsStream(TEST_IMAGE));
             mediaFile.setContentType(contentTypes[i]);
+
+            mediaFile.setDateUploaded(new Timestamp(cal.getTimeInMillis()));
+            // Add one second for date sql on mysql
+            cal.add(Calendar.SECOND, 1);
             mfMgr.createMediaFile(testWeblog, mediaFile, new RollerMessages());
             rootDirectory.getMediaFiles().add(mediaFile);
             assertNotNull(mediaFile.getId());
@@ -949,6 +962,11 @@ public class MediaFileTest extends TestC
                 "dir3", "directory 3", testWeblog);
         mfMgr.createMediaFileDirectory(directory3);
         rootDirectory.getChildDirectories().add(directory3);
+        
+        TestUtils.endSession(true);
+        
+        testWeblog = TestUtils.getManagedWebsite(testWeblog);
+        rootDirectory = mfMgr.getMediaFileDirectory(rootDirectory.getId());
 
         MediaFile mediaFile = new MediaFile();
         mediaFile.setDirectory(rootDirectory);
@@ -961,7 +979,7 @@ public class MediaFileTest extends TestC
         mediaFile.setInputStream(getClass().getResourceAsStream(TEST_IMAGE));
         mediaFile.setContentType("image/jpeg");
         mfMgr.createMediaFile(testWeblog, mediaFile, new RollerMessages());
-        rootDirectory.getMediaFiles().add(mediaFile);
+        //rootDirectory.getMediaFiles().add(mediaFile);
 
         MediaFile mediaFile2 = new MediaFile();
         mediaFile2.setDirectory(rootDirectory);
@@ -974,7 +992,7 @@ public class MediaFileTest extends TestC
         mediaFile2.setInputStream(getClass().getResourceAsStream(TEST_IMAGE));
         mediaFile2.setContentType("image/jpeg");
         mfMgr.createMediaFile(testWeblog, mediaFile2, new RollerMessages());
-        rootDirectory.getMediaFiles().add(mediaFile2);
+        //rootDirectory.getMediaFiles().add(mediaFile2);
 
         TestUtils.endSession(true);
 
@@ -1025,7 +1043,7 @@ public class MediaFileTest extends TestC
 
             // MediaFileDirectory rootDirectory = new MediaFileDirectory(null,
             // "root", "root d", testWeblog);
-            mfMgr.createMediaFileDirectory(rootDirectory);
+            //mfMgr.createMediaFileDirectory(rootDirectory);
 
             MediaFileDirectory directory1 = new MediaFileDirectory(
                     rootDirectory, "dir1", "directory 1", testWeblog);
@@ -1041,7 +1059,12 @@ public class MediaFileTest extends TestC
             MediaFileDirectory directory3 = new MediaFileDirectory(
                     rootDirectory, "dir3", "directory 3", testWeblog);
             mfMgr.createMediaFileDirectory(directory3);
-            rootDirectory.getChildDirectories().add(directory3);
+            //rootDirectory.getChildDirectories().add(directory3);
+            
+            TestUtils.endSession(true);
+            
+            testWeblog = TestUtils.getManagedWebsite(testWeblog);
+            rootDirectory = mfMgr.getMediaFileDirectory(rootDirectory.getId());
 
             MediaFile mediaFile = new MediaFile();
             mediaFile.setDirectory(rootDirectory);
@@ -1055,7 +1078,7 @@ public class MediaFileTest extends TestC
                     .setInputStream(getClass().getResourceAsStream(TEST_IMAGE));
             mediaFile.setContentType("image/jpeg");
             mfMgr.createMediaFile(testWeblog, mediaFile, new RollerMessages());
-            rootDirectory.getMediaFiles().add(mediaFile);
+            //rootDirectory.getMediaFiles().add(mediaFile);
 
             MediaFile mediaFile2 = new MediaFile();
             mediaFile2.setDirectory(rootDirectory);
@@ -1069,7 +1092,7 @@ public class MediaFileTest extends TestC
                     .getResourceAsStream(TEST_IMAGE));
             mediaFile2.setContentType("image/jpeg");
             mfMgr.createMediaFile(testWeblog, mediaFile2, new RollerMessages());
-            rootDirectory.getMediaFiles().add(mediaFile2);
+            //rootDirectory.getMediaFiles().add(mediaFile2);
 
             TestUtils.endSession(true);
 
@@ -1101,6 +1124,7 @@ public class MediaFileTest extends TestC
             TestUtils.endSession(true);
             TestUtils.teardownWeblog(testWeblog.getId());
             TestUtils.teardownUser(testUser.getUserName());
+            TestUtils.endSession(true);
         }
     }
 
@@ -1123,6 +1147,8 @@ public class MediaFileTest extends TestC
             testUser = TestUtils.setupUser("mediaFileTestUser");
             testWeblog1 = TestUtils.setupWeblog("testblog1", testUser);
             testWeblog2 = TestUtils.setupWeblog("testblog2", testUser);
+            
+            TestUtils.endSession(true);
 
             MediaFileManager mgr = WebloggerFactory.getWeblogger()
                     .getMediaFileManager();
@@ -1135,7 +1161,7 @@ public class MediaFileTest extends TestC
 
             assertFalse("Upgrade required", mmgr.isFileStorageUpgradeRequired());
 
-            // now, let's check to see if migration was sucessful
+            // now, let's check to see if migration was successful
 
             MediaFileDirectory root1 = mgr
                     .getMediaFileRootDirectory(testWeblog1);
@@ -1238,7 +1264,7 @@ public class MediaFileTest extends TestC
         TestUtils.endSession(true);
 
         directory = null;
-        
+
         // Using named query again MediaFileDirectory.getByWeblogAndNoParent
         directory = mfMgr.getMediaFileRootDirectory(testWeblog);
 
@@ -1248,5 +1274,6 @@ public class MediaFileTest extends TestC
         TestUtils.endSession(true);
         TestUtils.teardownWeblog(testWeblog.getId());
         TestUtils.teardownUser(testUser.getUserName());
+        TestUtils.endSession(true);
     }
 }
\ No newline at end of file

Modified: roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/PingsTest.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/PingsTest.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/PingsTest.java (original)
+++ roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/PingsTest.java Sun Apr 20 13:38:51 2014
@@ -49,8 +49,7 @@ public class PingsTest extends TestCase 
     User testUser = null;
     Weblog testWeblog = null;
     PingTarget testCommonPing = null;
-    PingTarget testCustomPing = null;
-    
+
     
     public PingsTest(String name) {
         super(name);
@@ -82,10 +81,6 @@ public class PingsTest extends TestCase 
         testCommonPing = new PingTarget();
         testCommonPing.setName("testCommonPing");
         testCommonPing.setPingUrl("http://localhost/testCommonPing");
-        
-        testCustomPing = new PingTarget();
-        testCustomPing.setName("testCustomPing");
-        testCustomPing.setPingUrl("http://localhost/testCustomPing");
     }
     
     public void tearDown() throws Exception {
@@ -100,7 +95,6 @@ public class PingsTest extends TestCase 
         }
         
         testCommonPing = null;
-        testCustomPing = null;
     }
     
     
@@ -123,18 +117,6 @@ public class PingsTest extends TestCase 
         assertNotNull(ping);
         assertEquals(testCommonPing.getPingUrl(), ping.getPingUrl());
         
-        // create custom ping
-        testCustomPing.setWebsite(TestUtils.getManagedWebsite(testWeblog));
-        mgr.savePingTarget(testCustomPing);
-        String customId = testCustomPing.getId();
-        TestUtils.endSession(true);
-        
-        // make sure custom ping was stored
-        ping = null;
-        ping = mgr.getPingTarget(customId);
-        assertNotNull(ping);
-        assertEquals(testCustomPing.getPingUrl(), ping.getPingUrl());
-        
         // update common ping
         ping = null;
         ping = mgr.getPingTarget(commonId);
@@ -148,19 +130,6 @@ public class PingsTest extends TestCase 
         assertNotNull(ping);
         assertEquals("testtestCommon", ping.getName());
         
-        // update custom ping
-        ping = null;
-        ping = mgr.getPingTarget(customId);
-        ping.setName("testtestCustom");
-        mgr.savePingTarget(ping);
-        TestUtils.endSession(true);
-        
-        // make sure custom ping was updated
-        ping = null;
-        ping = mgr.getPingTarget(customId);
-        assertNotNull(ping);
-        assertEquals("testtestCustom", ping.getName());
-        
         // delete common ping
         ping = null;
         ping = mgr.getPingTarget(commonId);
@@ -171,22 +140,11 @@ public class PingsTest extends TestCase 
         ping = null;
         ping = mgr.getPingTarget(commonId);
         assertNull(ping);
-        
-        // delete custom ping
-        ping = null;
-        ping = mgr.getPingTarget(customId);
-        mgr.removePingTarget(ping);
-        TestUtils.endSession(true);
-        
-        // make sure custom ping was deleted
-        ping = null;
-        ping = mgr.getPingTarget(customId);
-        assertNull(ping);
     }
     
     
     /**
-     * Test lookup mechanisms ... id, all common, all custom for weblog
+     * Test lookup mechanisms ... id, all common for weblog
      */
     public void testPingTargetLookups() throws Exception {
         
@@ -198,13 +156,6 @@ public class PingsTest extends TestCase 
         String commonId = testCommonPing.getId();
         TestUtils.endSession(true);
         
-        // create custom ping
-        testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        testCustomPing.setWebsite(testWeblog);
-        mgr.savePingTarget(testCustomPing);
-        String customId = testCustomPing.getId();
-        TestUtils.endSession(true);
-        
         // lookup by id
         ping = null;
         ping = mgr.getPingTarget(commonId);
@@ -217,23 +168,11 @@ public class PingsTest extends TestCase 
         // correct answer is: 4 pings in config + 1 new one = 5
         assertEquals(5, commonPings.size());
         
-        // lookup all custom pings for weblog
-        testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        List customPings = mgr.getCustomPingTargets(testWeblog);
-        assertNotNull(customPings);
-        assertEquals(1, customPings.size());
-        
         // delete common ping
         ping = null;
         ping = mgr.getPingTarget(commonId);
         mgr.removePingTarget(ping);
         TestUtils.endSession(true);
-        
-        // delete custom ping
-        ping = null;
-        ping = mgr.getPingTarget(customId);
-        mgr.removePingTarget(ping);
-        TestUtils.endSession(true);
     }
     
     

Modified: roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryCRUDTest.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryCRUDTest.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryCRUDTest.java (original)
+++ roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryCRUDTest.java Sun Apr 20 13:38:51 2014
@@ -18,11 +18,9 @@
 
 package org.apache.roller.weblogger.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.weblogger.WebloggerException;
 import org.apache.roller.weblogger.TestUtils;
 import org.apache.roller.weblogger.pojos.User;
 import org.apache.roller.weblogger.pojos.WeblogCategory;
@@ -87,14 +85,13 @@ public class WeblogCategoryCRUDTest exte
         WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
         
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        WeblogCategory root = mgr.getRootWeblogCategory(testWeblog);
-        
-        WeblogCategory testCat = new WeblogCategory(testWeblog, null, "root", "root", null);
-        assertTrue(root.equals(testCat));
-        
-        testCat = new WeblogCategory(testWeblog, root, "root", "root", null);
-        assertFalse(root.equals(testCat));
-        
+
+        WeblogCategory testCat = new WeblogCategory(testWeblog, "root", "desc", null);
+        WeblogCategory testCat2 = new WeblogCategory(testWeblog, "root2", "desc2", null);
+        assertFalse(testCat2.equals(testCat));
+        mgr.removeWeblogCategory(testCat);
+        mgr.removeWeblogCategory(testCat2);
+
         log.info("END");
     }
     
@@ -108,17 +105,15 @@ public class WeblogCategoryCRUDTest exte
         
         WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
         WeblogCategory cat = null;
-        List cats = null;
-        
+
         // root category is always available
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        WeblogCategory root = mgr.getRootWeblogCategory(testWeblog);
-        
-        // make sure we are starting with 0 categories (beneath root)
-        assertEquals(0, root.getWeblogCategories().size());
-        
+
+        // make sure we are starting with 1 categories
+        assertEquals(1, testWeblog.getWeblogCategories().size());
+
         // add a new category
-        WeblogCategory newCat = new WeblogCategory(testWeblog, root, "catTestCategory", null, null);
+        WeblogCategory newCat = new WeblogCategory(testWeblog, "catTestCategory", null, null);
         mgr.saveWeblogCategory(newCat);
         TestUtils.endSession(true);
         
@@ -130,24 +125,24 @@ public class WeblogCategoryCRUDTest exte
         
         // make sure category count increased
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        root = mgr.getRootWeblogCategory(testWeblog);
-        assertEquals(1, root.getWeblogCategories().size());
-        
+        assertEquals(2, testWeblog.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());
-        
+        assertEquals(2, testWeblog.getWeblogCategories().size());
+
         // remove category
         mgr.removeWeblogCategory(cat);
         TestUtils.endSession(true);
-        
+
         // make sure cat was removed
         cat = null;
         cat = mgr.getWeblogCategory(newCat.getId());
@@ -155,8 +150,7 @@ public class WeblogCategoryCRUDTest exte
         
         // make sure category count decreased
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        root = mgr.getRootWeblogCategory(testWeblog);
-        assertEquals(0, root.getWeblogCategories().size());
+        assertEquals(1, testWeblog.getWeblogCategories().size());
         
         log.info("END");
     }
@@ -173,36 +167,27 @@ public class WeblogCategoryCRUDTest exte
         
         // root category is always available
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        WeblogCategory root = mgr.getRootWeblogCategory(testWeblog);
-        
-        // add a small category tree /subcat/subcat2
-        WeblogCategory subcat = new WeblogCategory(testWeblog, root, "subcatTest1", null, null);
-        root.addCategory(subcat);
-        mgr.saveWeblogCategory(subcat);
-        WeblogCategory subcat2 = new WeblogCategory(testWeblog, subcat, "subcatTest2", null, null);
-        subcat.addCategory(subcat2);
-        mgr.saveWeblogCategory(subcat2);
+
+        // add a category above default one
+        WeblogCategory testCat = new WeblogCategory(testWeblog, "SampleCategory", null, null);
+        mgr.saveWeblogCategory(testCat);
         TestUtils.endSession(true);
         
-        // check that subcat tree can be navigated
+        // check that testCat can be retrieved
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        root = mgr.getRootWeblogCategory(testWeblog);
-        assertEquals(1, root.getWeblogCategories().size());
-        subcat = (WeblogCategory) root.getWeblogCategories().iterator().next();
-        assertEquals("subcatTest1", subcat.getName());
-        assertEquals(1, subcat.getWeblogCategories().size());
-        subcat2 = (WeblogCategory) subcat.getWeblogCategories().iterator().next();
-        assertEquals("subcatTest2", subcat2.getName());
-        
+
+        assertEquals(2, testWeblog.getWeblogCategories().size());
+        testCat = testWeblog.getWeblogCategories().get(1);
+        assertEquals("SampleCategory", testCat.getName());
+
         // now delete category and subcats should be deleted by cascade
-        mgr.removeWeblogCategory(subcat);
+        mgr.removeWeblogCategory(testCat);
         TestUtils.endSession(true);
         
         // verify cascading delete succeeded
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        root = mgr.getRootWeblogCategory(testWeblog);
-        assertEquals(0, root.getWeblogCategories().size());
-        assertNull(mgr.getWeblogCategoryByPath(TestUtils.getManagedWebsite(testWeblog), "/subcatTest1/subcatTest2"));
+        assertEquals(1, testWeblog.getWeblogCategories().size());
+        assertNull(mgr.getWeblogCategoryByName(TestUtils.getManagedWebsite(testWeblog), "SampleCategory"));
         
         log.info("END");
     }

Modified: roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryFunctionalityTest.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryFunctionalityTest.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryFunctionalityTest.java (original)
+++ roller/branches/rome2/app/src/test/java/org/apache/roller/weblogger/business/WeblogCategoryFunctionalityTest.java Sun Apr 20 13:38:51 2014
@@ -60,13 +60,13 @@ public class WeblogCategoryFunctionality
             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);
+            // setup several categories for testing
+            cat1 = TestUtils.setupWeblogCategory(testWeblog, "catTest-cat1");
+            cat2 = TestUtils.setupWeblogCategory(testWeblog, "catTest-cat2");
+            cat3 = TestUtils.setupWeblogCategory(testWeblog, "catTest-cat3");
             
             // a simple test cat at the root level
-            testCat = TestUtils.setupWeblogCategory(testWeblog, "catTest-testCat", null);
+            testCat = TestUtils.setupWeblogCategory(testWeblog, "catTest-testCat");
             
             TestUtils.endSession(true);
         } catch (Throwable t) {
@@ -90,71 +90,16 @@ public class WeblogCategoryFunctionality
         
         log.info("END");
     }
-    
-    
-    /**
-     * Test that we can walk a category tree.
-     */
-    public void testWalkCategoryTree() throws Exception {
-        
-        log.info("BEGIN");
-        
-        WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
-        
-        // start at root
-        WeblogCategory root = mgr.getRootWeblogCategory(TestUtils.getManagedWebsite(testWeblog));
-        
-        // walk first level
-        Set cats = root.getWeblogCategories();
-        assertEquals(2, cats.size());
-        assertTrue(cats.contains(testCat));
-        
-        // find cat1
-        WeblogCategory cat = null;
-        for(Iterator it = cats.iterator(); it.hasNext(); ) {
-            cat = (WeblogCategory) it.next();
-            if(cat.getName().equals(cat1.getName())) {
-                break;
-            }
-        }
-        
-        // walk second level
-        cats = cat.getWeblogCategories();
-        assertEquals(1, cats.size());
-        assertTrue(cats.contains(cat2));
-        
-        // find cat2
-        cat = (WeblogCategory) cats.iterator().next();
-        
-        // walk third level
-        cats = cat.getWeblogCategories();
-        assertEquals(1, cats.size());
-        assertTrue(cats.contains(cat3));
-        
-        // find cat3
-        cat = (WeblogCategory) cats.iterator().next();
-        
-        // make sure this is the end of the tree
-        cats = cat.getWeblogCategories();
-        assertEquals(0, cats.size());
-        
-        log.info("END");
-    }
-    
-    
+
     /**
      * Test the hasCategory() method on WeblogCategory.
      */
     public void testHasCategory() throws Exception {
         
         log.info("BEGIN");
-        
-        WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
-        
-        WeblogCategory root = mgr.getRootWeblogCategory(TestUtils.getManagedWebsite(testWeblog));
-        
+
         // check that root has category
-        assertTrue(root.hasCategory(testCat.getName()));
+        assertTrue(testWeblog.hasCategory(testCat.getName()));
         
         log.info("END");
     }
@@ -178,33 +123,28 @@ public class WeblogCategoryFunctionality
     
     
     /**
-     * Lookup category by path.
+     * Lookup category by name.
      */
-    public void testLookupCategoryByPath() throws Exception {
+    public void testLookupCategoryByName() throws Exception {
         
         log.info("BEGIN");
         
         WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
         
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        WeblogCategory cat = mgr.getWeblogCategoryByPath(testWeblog, "/catTest-cat1");
+        WeblogCategory cat = mgr.getWeblogCategoryByName(testWeblog, "catTest-cat1");
         assertNotNull(cat);
         assertEquals(cat, cat1);
         
-        cat = mgr.getWeblogCategoryByPath(testWeblog, "/catTest-cat1/catTest-cat2/catTest-cat3");
+        cat = mgr.getWeblogCategoryByName(testWeblog, "catTest-cat3");
         assertNotNull(cat);
         assertEquals(cat, cat3);
         
         // test lazy lookup, specifying just a name without slashes
-        cat = mgr.getWeblogCategoryByPath(testWeblog, "catTest-cat1");
+        cat = mgr.getWeblogCategoryByName(testWeblog, "catTest-cat1");
         assertNotNull(cat);
         assertEquals(cat, cat1);
-        
-        // if no path is specified we should get the root category
-        cat = mgr.getWeblogCategoryByPath(testWeblog, null);
-        assertNotNull(cat);
-        assertEquals(cat.getPath(), "/");
-        
+
         log.info("END");
     }
     
@@ -218,108 +158,14 @@ public class WeblogCategoryFunctionality
         
         WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
         
-        // including root
         testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        List cats = mgr.getWeblogCategories(testWeblog, true);
+        List cats = mgr.getWeblogCategories(testWeblog);
         assertNotNull(cats);
         assertEquals(5, cats.size());
         
-        // not including root
-        cats = mgr.getWeblogCategories(testWeblog, false);
-        assertNotNull(cats);
-        assertEquals(4, cats.size());
-        
         log.info("END");
     }
-    
-    
-    /**
-     * Test moving one category into another.
-     */
-    public void testMoveWeblogCategory() throws Exception {
-        log.info("BEGIN");
-        
-        WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
-        
-        testWeblog = TestUtils.getManagedWebsite(testWeblog);
-        testUser = TestUtils.getManagedUser(testUser);
-        WeblogCategory root = mgr.getRootWeblogCategory(testWeblog);
-        WeblogEntry e1 = null;
-        WeblogEntry e2 = null; 
-        WeblogEntry e3 = null; 
-        
-        try {
-            // add some categories and entries to test with
-            WeblogCategory dest = new WeblogCategory(testWeblog, root, "c0", null, null);
-            mgr.saveWeblogCategory(dest);
 
-            WeblogCategory c1 = new WeblogCategory(testWeblog, root, "c1", null, null);
-            mgr.saveWeblogCategory(c1);
-
-            WeblogCategory c2 = new WeblogCategory(testWeblog, c1, "c2", null, null);
-            mgr.saveWeblogCategory(c2);
-
-            WeblogCategory c3 = new WeblogCategory(testWeblog, c2, "c3", null, null);
-            mgr.saveWeblogCategory(c3);
-
-            TestUtils.endSession(true);
-
-            c1 = mgr.getWeblogCategory(c1.getId());
-            c2 = mgr.getWeblogCategory(c2.getId());
-            c3 = mgr.getWeblogCategory(c3.getId());
-            dest = mgr.getWeblogCategory(dest.getId());
-
-            e1 = TestUtils.setupWeblogEntry("e1", c1, testWeblog, testUser);
-            e2 = TestUtils.setupWeblogEntry("e2", c2, testWeblog, testUser);
-            e3 = TestUtils.setupWeblogEntry("e3", c3, testWeblog, testUser);
-
-            TestUtils.endSession(true);
-
-            // need to query for cats again because we closed the session
-            c1 = mgr.getWeblogCategory(c1.getId());
-            c2 = mgr.getWeblogCategory(c2.getId());
-            c3 = mgr.getWeblogCategory(c3.getId());
-            dest = mgr.getWeblogCategory(dest.getId());
-
-            // verify number of entries in each category
-            assertEquals(0, dest.retrieveWeblogEntries(true).size());
-            assertEquals(0, dest.retrieveWeblogEntries(false).size());
-            assertEquals(1, c1.retrieveWeblogEntries(false).size());
-            assertEquals(3, c1.retrieveWeblogEntries(true).size());
-
-            // move contents of source category c1 to destination catetory dest
-            mgr.moveWeblogCategory(c1, dest);
-            TestUtils.endSession(true);
-
-            // after move, verify number of entries in each category
-            dest = mgr.getWeblogCategory(dest.getId());
-            c1 = mgr.getWeblogCategory(c1.getId());
-            c2 = mgr.getWeblogCategory(c2.getId());
-            c3 = mgr.getWeblogCategory(c3.getId());
-
-            assertEquals(3, dest.retrieveWeblogEntries(true).size());
-            assertEquals(0, dest.retrieveWeblogEntries(false).size());
-
-            assertEquals(dest, c1.getParent());
-            assertEquals(c1,   c2.getParent());
-            assertEquals(c2,   c3.getParent());
-
-            assertEquals(1, c1.retrieveWeblogEntries(false).size());
-            assertEquals(1, c2.retrieveWeblogEntries(false).size());
-            assertEquals(1, c3.retrieveWeblogEntries(false).size());
-
-            List entries = c1.retrieveWeblogEntries(true);
-            assertEquals(3, entries.size());
-
-        } finally {
-            mgr.removeWeblogEntry(TestUtils.getManagedWeblogEntry(e1));
-            mgr.removeWeblogEntry(TestUtils.getManagedWeblogEntry(e2));
-            mgr.removeWeblogEntry(TestUtils.getManagedWeblogEntry(e3));
-        }
-        log.info("END");
-    }
-    
-    
     /**
      * Test moving entries in category to new category.
      */
@@ -328,52 +174,39 @@ public class WeblogCategoryFunctionality
         WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
         WeblogEntry e1 = null;
         WeblogEntry e2 = null; 
-        WeblogEntry e3 = null; 
         try {
 
             testWeblog = TestUtils.getManagedWebsite(testWeblog);
             testUser = TestUtils.getManagedUser(testUser);
-            WeblogCategory root = mgr.getRootWeblogCategory(testWeblog);
 
             // add some categories and entries to test with
-            WeblogCategory dest = new WeblogCategory(testWeblog, root, "c0", null, null);
-            mgr.saveWeblogCategory(dest);
-
-            WeblogCategory c1 = new WeblogCategory(testWeblog, root, "c1", null, null);
+            WeblogCategory c1 = new WeblogCategory(testWeblog, "c1", null, null);
             mgr.saveWeblogCategory(c1);
 
-            WeblogCategory c2 = new WeblogCategory(testWeblog, c1, "c2", null, null);
-            mgr.saveWeblogCategory(c2);
-
-            WeblogCategory c3 = new WeblogCategory(testWeblog, c2, "c3", null, null);
-            mgr.saveWeblogCategory(c3);
+            WeblogCategory dest = new WeblogCategory(testWeblog, "dest", null, null);
+            mgr.saveWeblogCategory(dest);
 
             TestUtils.endSession(true);
 
             c1 = mgr.getWeblogCategory(c1.getId());
-            c2 = mgr.getWeblogCategory(c2.getId());
-            c3 = mgr.getWeblogCategory(c3.getId());
             dest = mgr.getWeblogCategory(dest.getId());
 
             testWeblog = TestUtils.getManagedWebsite(testWeblog);
             testUser = TestUtils.getManagedUser(testUser);
             e1 = TestUtils.setupWeblogEntry("e1", c1, testWeblog, testUser);
-            e2 = TestUtils.setupWeblogEntry("e2", c2, testWeblog, testUser);
-            e3 = TestUtils.setupWeblogEntry("e3", c3, testWeblog, testUser);
+            e2 = TestUtils.setupWeblogEntry("e2", c1, WeblogEntry.DRAFT, testWeblog, testUser);
 
             TestUtils.endSession(true);
 
             // need to query for cats again since session was closed
             c1 = mgr.getWeblogCategory(c1.getId());
-            c2 = mgr.getWeblogCategory(c2.getId());
-            c3 = mgr.getWeblogCategory(c3.getId());
             dest = mgr.getWeblogCategory(dest.getId());
 
             // verify number of entries in each category
             assertEquals(0, dest.retrieveWeblogEntries(true).size());
             assertEquals(0, dest.retrieveWeblogEntries(false).size());
-            assertEquals(1, c1.retrieveWeblogEntries(false).size());
-            assertEquals(3, c1.retrieveWeblogEntries(true).size());
+            assertEquals(2, c1.retrieveWeblogEntries(false).size());
+            assertEquals(1, c1.retrieveWeblogEntries(true).size());
 
             // move contents of source category c1 to destination category dest
             mgr.moveWeblogCategoryContents(c1, dest);
@@ -385,16 +218,15 @@ public class WeblogCategoryFunctionality
             c1 = mgr.getWeblogCategory(c1.getId());
 
             // Hierarchy is flattened under dest      
-            assertEquals(3, dest.retrieveWeblogEntries(true).size());
-            assertEquals(3, dest.retrieveWeblogEntries(false).size());
+            assertEquals(2, dest.retrieveWeblogEntries(false).size());
+            assertEquals(1, dest.retrieveWeblogEntries(true).size());
 
             // c1 category should be empty now
             assertEquals(0, c1.retrieveWeblogEntries(false).size());
-            
+
         } finally {
             mgr.removeWeblogEntry(TestUtils.getManagedWeblogEntry(e1));
             mgr.removeWeblogEntry(TestUtils.getManagedWeblogEntry(e2));
-            mgr.removeWeblogEntry(TestUtils.getManagedWeblogEntry(e3));
         }
         
         log.info("END");



Mime
View raw message