roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r392622 [3/3] - in /incubator/roller/branches/roller-newbackend: ./ testdata/WEB-INF/classes/ tests/org/roller/ tests/org/roller/business/ tests/org/roller/presentation/velocity/
Date Sat, 08 Apr 2006 22:43:01 GMT
Modified: incubator/roller/branches/roller-newbackend/tests/org/roller/business/WeblogManagerTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/tests/org/roller/business/WeblogManagerTest.java?rev=392622&r1=392621&r2=392622&view=diff
==============================================================================
--- incubator/roller/branches/roller-newbackend/tests/org/roller/business/WeblogManagerTest.java (original)
+++ incubator/roller/branches/roller-newbackend/tests/org/roller/business/WeblogManagerTest.java Sat Apr  8 15:42:58 2006
@@ -26,815 +26,815 @@
  */
 public class WeblogManagerTest extends RollerTestBase 
 {    
-    String dest_id = null;
-    String c1_id = null;
-    String c2_id = null;
-    String c3_id = null;
-    
-    //------------------------------------------------------------------------
-    public WeblogManagerTest(String name) 
-    {
-        super(name);
-    }
-    
-    //------------------------------------------------------------------------
-    public static void main(String args[]) 
-    {
-        junit.textui.TestRunner.run(WeblogManagerTest.class);
-    }
-    
-    //------------------------------------------------------------------------
-    public static Test suite() 
-    {
-        return new TestSuite(WeblogManagerTest.class);
-    }
-
-    //-----------------------------------------------------------------------
-    /**
-     * @see junit.framework.TestCase#setUp()
-     */
-    public void setUp() throws Exception
-    {
-        super.setUp();
-        setUpTestWeblogs();
-        setUpCategoryTree();
-    }
-    
-    /** 
-     * Add a small category tree to the small test website (mWebsite). 
-     *    root/
-     *       c0/
-     *       c1/
-     *          c2/
-     *             c3/
-     */
-    public void setUpCategoryTree() throws Exception
-    {
-        getRoller().begin(UserData.SYSTEM_USER);
-        
-        WebsiteData wd = null;
-        UserData ud = null;
-        WeblogCategoryData root = null;
-        WeblogManager wmgr = getRoller().getWeblogManager();
-
-        wd = getRoller().getUserManager().retrieveWebsite(mWebsite.getId());
-        ud = getRoller().getUserManager().retrieveUser(mUser.getId());
-        root = wmgr.getRootWeblogCategory(wd);
-
-        // create empty destination folder
-        WeblogCategoryData dest = wmgr.createWeblogCategory();
-        dest.setName("c0");
-        dest.setParent(root);
-        dest.setWebsite(wd);
-        dest.save();       
-        
-        // create three level src category with entry in each category
-        WeblogCategoryData c1 = wmgr.createWeblogCategory();
-        c1.setName("c1");
-        c1.setParent(root);
-        c1.setWebsite(wd);
-        c1.save();
-        
-        WeblogEntryData e1 = new WeblogEntryData(
-            null, c1, wd, ud, "title1", null, "text", "anchor", 
-            new Timestamp(0), new Timestamp(0), WeblogEntryData.DRAFT);
-        e1.save();
-        
-        WeblogCategoryData c2 = wmgr.createWeblogCategory(); 
-        c2.setName("c2");
-        c2.setParent(c1);
-        c2.setWebsite(wd);
-        c2.save();
-      
-        WeblogEntryData e2 = new WeblogEntryData(
-            null, c2, wd, ud, "title2", null, "text", "anchor", 
-            new Timestamp(0), new Timestamp(0), WeblogEntryData.DRAFT);
-        e2.save();
-        
-        WeblogCategoryData c3 = wmgr.createWeblogCategory(); 
-        c3.setName("c3");
-        c3.setParent(c2);
-        c3.setWebsite(wd);
-        c3.save();
-        
-        WeblogEntryData e3 = new WeblogEntryData(
-            null, c3, wd, ud, "title3", null, "text", "anchor", 
-            new Timestamp(0), new Timestamp(0), WeblogEntryData.DRAFT);
-        e3.save();
-        
-        getRoller().commit(); 
-        
-        dest_id = dest.getId();
-        c1_id = c1.getId();  
-        c2_id = c2.getId();  
-        c3_id = c3.getId();  
-    }
-    
-    //-----------------------------------------------------------------------
-    /**
-     * @see junit.framework.TestCase#tearDown()
-     */
-    public void tearDown() throws Exception
-    {
-        super.tearDown();
-        tearDownTestWeblogs();
-    }
-    
-    //-----------------------------------------------------------------------
-    
-    /** Add a small category tree to the small test website (mWebsite). */
-    public void testGetRecent() throws Exception
-    {
-        getRoller().begin(UserData.SYSTEM_USER);
-        
-        WebsiteData wd = null;
-        UserData ud = null;
-        WeblogCategoryData root = null;
-        WeblogManager wmgr = getRoller().getWeblogManager();
-
-        wd = getRoller().getUserManager().retrieveWebsite(mWebsite.getId());
-        ud = getRoller().getUserManager().retrieveUser(mUser.getId());
-        root = wmgr.getRootWeblogCategory(wd);
-
-        // create top level folders
-        WeblogCategoryData t1 = wmgr.createWeblogCategory();
-        t1.setName("toplevel1");
-        t1.setParent(root);
-        t1.setWebsite(wd);
-        t1.save();       
-        
-        WeblogCategoryData t2 = wmgr.createWeblogCategory();
-        t2.setName("toplevel2");
-        t2.setParent(root);
-        t2.setWebsite(wd);
-        t2.save();       
-        
-        WeblogCategoryData t3 = wmgr.createWeblogCategory();
-        t3.setName("toplevel3");
-        t3.setParent(root);
-        t3.setWebsite(wd);
-        t3.save(); 
-        
-        getRoller().commit(); 
-        
-        getRoller().begin(UserData.SYSTEM_USER); 
-        
-        // get persistent instances
-        t1 = wmgr.retrieveWeblogCategory(t1.getId());
-        wd = getRoller().getUserManager().retrieveWebsite(mWebsite.getId());
-        
-        // Create four entries in 1st category
-        WeblogEntryData e1 = new WeblogEntryData(
-                null, t1, wd, ud, "title1", null, "text1", "anchor", 
-                new Timestamp(0), new Timestamp(0), WeblogEntryData.DRAFT);
-        e1.save();
-        
-        WeblogEntryData e2 = new WeblogEntryData(
-                null, t1, wd, ud, "title2", null, "text2", "anchor", 
-                new Timestamp(0), new Timestamp(0), WeblogEntryData.DRAFT);
-        e2.save();
-        
-        WeblogEntryData e3 = new WeblogEntryData(
-                null, t1, wd, ud, "title3", null, "text3", "anchor", 
-                new Timestamp(0), new Timestamp(0), WeblogEntryData.DRAFT);
-        e3.save();
-        
-        WeblogEntryData e4 = new WeblogEntryData(
-                null, t1, wd, ud, "title4", null, "text4", "anchor", 
-                new Timestamp(0), new Timestamp(0), WeblogEntryData.DRAFT);
-        e4.save();
-        
-        getRoller().commit(); 
-        
-        getRoller().begin(UserData.SYSTEM_USER);
-        
-        //List entries = wmgr.getRecentWeblogEntriesArray(
-            //wd.getUser().getUserName(), new Date(), "toplevel1", 15, false);
-        
-        List entries = wmgr.getWeblogEntries(
-                        wd,
-                        null,             // startDate
-                        new Date(),       // endDate
-                        "toplevel1",      // catName
-                        null,             // status
-                        null,             // sortby
-                        new Integer(15)); // maxEntries
-
-        assertEquals(4, entries.size());
-        
-        getRoller().rollback();
-    }
-    
-    public void testGetWeblogCategoryRoot() throws Exception
-    {
-        getRoller().begin(UserData.SYSTEM_USER);
-        WeblogManager wmgr = getRoller().getWeblogManager();
-        assertNotNull(wmgr.getRootWeblogCategory(mWebsite));
-        getRoller().rollback();
-    }    
-    
-    public void testGetWeblogCategories() throws Exception
-    {
-        getRoller().begin(UserData.SYSTEM_USER);
-        WeblogManager wmgr = getRoller().getWeblogManager();
-        assertEquals(10, wmgr.getWeblogCategories(mWebsite).size());
-        getRoller().rollback();
-    }    
-    
-    public void testWeblogCategoryPaths() throws Exception
-    {
-        WebsiteData wd = null;
-        WeblogCategoryData root = null;
-        WeblogManager wmgr = getRoller().getWeblogManager();
-        
-        getRoller().begin(UserData.SYSTEM_USER);
-        
-        wd = getRoller().getUserManager().retrieveWebsite(mWebsite.getId());
-        root = wmgr.getRootWeblogCategory(wd);
-
-        WeblogCategoryData f1 = wmgr.createWeblogCategory();
-        f1.setName("f1");
-        f1.setParent(root);
-        f1.setWebsite(wd);
-        f1.save();
-        
-        WeblogCategoryData f2 = wmgr.createWeblogCategory(); 
-        f2.setName("f2");
-        f2.setParent(f1);
-        f2.setWebsite(wd);
-        f2.save();
-      
-        WeblogCategoryData f3 = wmgr.createWeblogCategory(); 
-        f3.setName("f3");
-        f3.setParent(f2);
-        f3.setWebsite(wd);
-        f3.save();
-        
-        getRoller().commit();
-        
-        getRoller().begin(UserData.SYSTEM_USER);
-        
-        // check count of descendents and ancestors
-        f1 = wmgr.retrieveWeblogCategory(f1.getId());        
-        assertEquals(2, f1.getAllDescendentAssocs().size());
-        assertEquals(1, f1.getAncestorAssocs().size());
-        
-        f2 = wmgr.retrieveWeblogCategory(f2.getId());        
-        assertEquals(1, f2.getAllDescendentAssocs().size());
-        assertEquals(2, f2.getAncestorAssocs().size());
-        
-        f3 = wmgr.retrieveWeblogCategory(f3.getId());        
-        assertEquals(0, f3.getAllDescendentAssocs().size());
-        assertEquals(3, f3.getAncestorAssocs().size());
-        
-        // test get by path
-        assertEquals("f1", 
-            wmgr.getWeblogCategoryByPath(wd, null, "f1").getName());
-        
-        assertEquals("f1", 
-            wmgr.getWeblogCategoryByPath(wd, null, "/f1").getName());
-        
-        assertEquals("f2", 
-            wmgr.getWeblogCategoryByPath(wd, null, "/f1/f2").getName());
-        
-        assertEquals("f3", 
-            wmgr.getWeblogCategoryByPath(wd, null, "/f1/f2/f3").getName());
-        
-        // test path creation
-        f3 = wmgr.getWeblogCategoryByPath(wd, null, "/f1/f2/f3");
-        String pathString = wmgr.getPath(f3);
-        String[] pathArray = Utilities.stringToStringArray(pathString,"/");
-        assertEquals("f1", pathArray[0]);
-        assertEquals("f2", pathArray[1]);
-        assertEquals("f3", pathArray[2]);
-        
-        getRoller().commit();
-    }    
-        
-    //-----------------------------------------------------------------------
-    
-    public void testGetWeblogEntryByAnchor() throws Exception
-    {
-        WeblogManager wmgr = getRoller().getWeblogManager();
-        
-        WeblogEntryData entry1 = (WeblogEntryData)mEntriesCreated.get(0);
-        
-        WebsiteData website = entry1.getWebsite();
-        
-        WeblogEntryData entry2 = wmgr.getWeblogEntryByAnchor(
-            website, entry1.getAnchor() );
-        
-        assertEquals( entry1.getId(), entry2.getId() );
-    }
-     
-    //-----------------------------------------------------------------------
-    /**
-     * Test latest publishTime for a User.
-     * This test passes inconsistently - I suspect Hibernate.
-     */
-    public void testGetWeblogLastUpdateTimeForUser() throws Exception
-    {
-        UserManager umgr = getRoller().getUserManager();
-        WeblogManager wmgr = getRoller().getWeblogManager();
-
-        /** 
-         * really weird, but we cannot get 'entry1' directly,
-         * we have to iterate over entries.  We end up getting the same one
-         * either way, but fetching it directly fails!
-         */
-        int lastEntryIndex = (mEntriesCreated.size()-1);
-        //System.out.println("# entries:" + lastEntryIndex);
-        WeblogEntryData entry1 = null;
-        //WeblogEntryData entry1 = (WeblogEntryData)mEntriesCreated.get(lastEntryIndex);
-        if (entry1 == null || !entry1.isPublished()) // if not published, find one
-        {
-            for (int i=lastEntryIndex; i >= 0; i--)
-            {
-                entry1 = (WeblogEntryData)        
-                    mEntriesCreated.get(i); // last entry is newest
-                //System.out.println("entry " + i + "published:" + entry1.getPublishEntry());
-                if (entry1.isPublished()) {
-                    break;
-                }
-            }
-        }
-        
-        WebsiteData website = entry1.getWebsite();
-        UserData user = (UserData)umgr.getUsers(website, null).get(0);
-        Date updateTime = wmgr.getWeblogLastPublishTime(website);
-                
-        assertEquals("THIS FAILS RANDOMLY, TRY AGAIN", entry1.getPubTime(),updateTime);
-    }
-
-    //-----------------------------------------------------------------------
-    /**
-     * Test latest publishTime when no User is specified.
-     * This test passes inconsistently - I suspect Hibernate.
-     */
-    public void testGetWeblogLastUpdateTimeForAll() throws Exception
-    {
-        WeblogManager wmgr = getRoller().getWeblogManager();
-
-        /** 
-         * Have to iterate and test to find the latest *enabled* entry.
-         */
-        int lastEntryIndex = (mEntriesCreated.size()-1);
-        //System.out.println("# entries:" + lastEntryIndex);
-        WeblogEntryData entry1 = null;
-        WeblogEntryData temp = null;
-        for (int i=lastEntryIndex; i >= 0; i--)
-        {
-            temp = (WeblogEntryData)        
-                mEntriesCreated.get(i); // last entry is newest
-            //System.out.println("entry " + i + "published:" + entry1.getPublishEntry());
-            if (temp.isPublished()) 
-            {
-                if (entry1 ==  null || entry1.getPubTime().compareTo(temp.getPubTime()) < 0)
-                {   
-                    if (entry1 != null)
-                        System.out.println("replacing " + entry1.getTitle() + " with " + temp.getTitle());
-                    else
-                        System.out.println("setting entry1 to " + temp.getTitle());
-                    entry1 = temp;
-                }
-            }
-        }
-        
-        Date updateTime = wmgr.getWeblogLastPublishTime(null);
-
-        assertEquals("THIS FAILS RANDOMLY, TRY AGAIN", entry1.getPubTime(),updateTime);
-    }
-
-    /** Count weblog entries in a weblogEntry map */
-    private int countEntries( Map entryMap ) 
-    {
-        int count = 0;
-        Iterator days = entryMap.values().iterator();
-        while (days.hasNext())
-        {
-            List dayEntries = (List) days.next();
-            Iterator entries = dayEntries.iterator();
-            while (entries.hasNext())
-            {
-                entries.next();
-                count++;
-            }
-        }
-        return count;
-    }
-          
-    public void testIsWeblogCategoryInUse() throws Exception
-    {
-        WeblogManager wmgr = getRoller().getWeblogManager();
-        UserManager umgr = getRoller().getUserManager();
-                    
-        getRoller().begin(UserData.SYSTEM_USER);
-        
-        WebsiteData website = umgr.retrieveWebsite(mWebsite.getId());
-        WeblogEntryData entry = (WeblogEntryData)mEntriesCreated.get(2);
-        WeblogCategoryData rootCat = wmgr.getRootWeblogCategory(website);
-        
-        WeblogCategoryData usedCat = 
-            wmgr.retrieveWeblogCategory(entry.getCategory().getId()); 
-                         
-        WeblogCategoryData unusedCat = wmgr.createWeblogCategory(
-            website, rootCat, "testy", "tasty", "testy.gif");
-        unusedCat.save();
-            
-        getRoller().commit();
-        
-        getRoller().begin(UserData.SYSTEM_USER);
-        usedCat = wmgr.retrieveWeblogCategory(usedCat.getId());
-        assertTrue(usedCat.isInUse());
-        
-        unusedCat = wmgr.retrieveWeblogCategory(unusedCat.getId());
-        assertFalse(unusedCat.isInUse());       
-        getRoller().commit();
-    }
-
-    public void testStoreComment() throws Exception
-    {
-        getRoller().begin(UserData.SYSTEM_USER);
-        WeblogManager wmgr = getRoller().getWeblogManager();
-        
-        // Get entry to which comment will be added
-        WeblogEntryData entry1 = (WeblogEntryData)mEntriesCreated.get(1);
-        
-        // Ensure that entry is a persistent instance
-        entry1 = getRoller().getWeblogManager().retrieveWeblogEntry(
-            entry1.getId());
-        
-        CommentData comment = new CommentData();
-        comment.setWeblogEntry(entry1);
-        comment.setName("TestCommentUser");
-        comment.setEmail("test@test.com");
-        comment.setContent("");
-        comment.setPostTime(new java.sql.Timestamp(new Date().getTime()));
-        comment.setSpam(Boolean.FALSE);
-        comment.setNotify(Boolean.FALSE);
-        comment.setNotify(Boolean.FALSE);
-        comment.setApproved(Boolean.TRUE);
-        comment.setPending(Boolean.FALSE);
-        comment.save();
-        getRoller().commit();
-        
-        List comments = wmgr.getComments(
-                null,   // website
-                entry1, // weblogEntry
-                null,   // search
-                null,   // start
-                null,   // end
-                null,   // approved
-                null,   // pending
-                null,   // spam
-                true,   // reverseChrono
-                0,      // offset
-                -1);    // length
-        assertTrue(comments.size() > mCommentCount);
-        
-        getRoller().begin(UserData.SYSTEM_USER);
-        wmgr.removeComment(comment.getId());
-        getRoller().commit();
-    }   
-    
-    public void testMoveCategoryContents() throws RollerException
-    {
-        WeblogManager wmgr = getRoller().getWeblogManager();
-        
-        WeblogCategoryData c1 = wmgr.retrieveWeblogCategory(c1_id);       
-        //WeblogCategoryData c2 = wmgr.retrieveWeblogCategory(c2_id);       
-        //WeblogCategoryData c3 = wmgr.retrieveWeblogCategory(c3_id);       
-        WeblogCategoryData dest = wmgr.retrieveWeblogCategory(dest_id);              
-        
-        getRoller().begin(UserData.SYSTEM_USER);
-               
-        // verify number of entries in each category
-        dest = wmgr.retrieveWeblogCategory(dest.getId());
-        c1 = wmgr.retrieveWeblogCategory(c1.getId());
-        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
-        c1.moveContents(dest);
-        
-        getRoller().commit(); 
-        
-        getRoller().begin(UserData.SYSTEM_USER);
-        
-        // after move, verify number of entries in each category
-        dest = wmgr.retrieveWeblogCategory(dest.getId());
-        c1 = wmgr.retrieveWeblogCategory(c1.getId());
-        assertEquals(3, dest.retrieveWeblogEntries(true).size());
-        assertEquals(3, dest.retrieveWeblogEntries(false).size());        
-        assertEquals(0, c1.retrieveWeblogEntries(true).size());
-        assertEquals(0, c1.retrieveWeblogEntries(false).size());
-        
-        getRoller().commit();      
-    }
-    
-    public void testMoveCategoryProtection() throws RollerException
-    {
-        boolean safe = false;
-        try 
-        {
-            getRoller().begin(UserData.SYSTEM_USER);
-            WeblogManager wmgr = getRoller().getWeblogManager();        
-                   
-            // Move category into one of it's children
-            WeblogCategoryData c1 = wmgr.retrieveWeblogCategory(c1_id);       
-            WeblogCategoryData c3 = wmgr.retrieveWeblogCategory(c3_id);       
-            wmgr.moveWeblogCategoryContents(c1.getId(), c3.getId());
-            c3.save();
-            c1.save();
-            getRoller().commit(); 
-        }
-        catch (RollerException e)
-        {
-            safe = true;
-        }
-        assertTrue(safe);
-    }
-    
-    public void testMoveCategory() throws RollerException
-    {
-        getRoller().begin(UserData.SYSTEM_USER);
-        WeblogManager wmgr = getRoller().getWeblogManager();
-        
-        WeblogCategoryData c1 = wmgr.retrieveWeblogCategory(c1_id);       
-        WeblogCategoryData c2 = wmgr.retrieveWeblogCategory(c2_id);       
-        WeblogCategoryData c3 = wmgr.retrieveWeblogCategory(c3_id);       
-        WeblogCategoryData dest = wmgr.retrieveWeblogCategory(dest_id);              
-               
-        // verify number of entries in each category
-        dest = wmgr.retrieveWeblogCategory(dest.getId());
-        c1 = wmgr.retrieveWeblogCategory(c1.getId());
-        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
-        c1.setParent(dest);
-        c1.save();
-        
-        getRoller().commit(); 
-        
-        getRoller().begin(UserData.SYSTEM_USER);
-        
-        // after move, verify number of entries in each category
-        dest = wmgr.retrieveWeblogCategory(dest.getId());
-        c1 = wmgr.retrieveWeblogCategory(c1_id);       
-        c2 = wmgr.retrieveWeblogCategory(c2_id);       
-        c3 = wmgr.retrieveWeblogCategory(c3_id);
-               
-        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());
-        
-        getRoller().commit();      
-    }
-    
-//    public void testNextPrevPost() throws RollerException
+//    String dest_id = null;
+//    String c1_id = null;
+//    String c2_id = null;
+//    String c3_id = null;
+//    
+//    //------------------------------------------------------------------------
+//    public WeblogManagerTest(String name) 
+//    {
+//        super(name);
+//    }
+//    
+//    //------------------------------------------------------------------------
+//    public static void main(String args[]) 
+//    {
+//        junit.textui.TestRunner.run(WeblogManagerTest.class);
+//    }
+//    
+//    //------------------------------------------------------------------------
+//    public static Test suite() 
+//    {
+//        return new TestSuite(WeblogManagerTest.class);
+//    }
+//
+//    //-----------------------------------------------------------------------
+//    /**
+//     * @see junit.framework.TestCase#setUp()
+//     */
+//    public void setUp() throws Exception
+//    {
+//        super.setUp();
+//        setUpTestWeblogs();
+//        setUpCategoryTree();
+//    }
+//    
+//    /** 
+//     * Add a small category tree to the small test website (mWebsite). 
+//     *    root/
+//     *       c0/
+//     *       c1/
+//     *          c2/
+//     *             c3/
+//     */
+//    public void setUpCategoryTree() throws Exception
 //    {
 //        getRoller().begin(UserData.SYSTEM_USER);
+//        
+//        WebsiteData wd = null;
+//        UserData ud = null;
+//        WeblogCategoryData root = null;
 //        WeblogManager wmgr = getRoller().getWeblogManager();
+//
+//        wd = getRoller().getUserManager().retrieveWebsite(mWebsite.getId());
+//        ud = getRoller().getUserManager().retrieveUser(mUser.getId());
+//        root = wmgr.getRootWeblogCategory(wd);
+//
+//        // create empty destination folder
+//        WeblogCategoryData dest = wmgr.createWeblogCategory();
+//        dest.setName("c0");
+//        dest.setParent(root);
+//        dest.setWebsite(wd);
+//        dest.save();       
 //        
-//        // category: root
-//        WeblogEntryData entry0 = (WeblogEntryData)mEntriesCreated.get(0);
+//        // create three level src category with entry in each category
+//        WeblogCategoryData c1 = wmgr.createWeblogCategory();
+//        c1.setName("c1");
+//        c1.setParent(root);
+//        c1.setWebsite(wd);
+//        c1.save();
+//        
+//        WeblogEntryData e1 = new WeblogEntryData(
+//            null, c1, wd, ud, "title1", null, "text", "anchor", 
+//            new Timestamp(0), new Timestamp(0), WeblogEntryData.DRAFT);
+//        e1.save();
+//        
+//        WeblogCategoryData c2 = wmgr.createWeblogCategory(); 
+//        c2.setName("c2");
+//        c2.setParent(c1);
+//        c2.setWebsite(wd);
+//        c2.save();
+//      
+//        WeblogEntryData e2 = new WeblogEntryData(
+//            null, c2, wd, ud, "title2", null, "text", "anchor", 
+//            new Timestamp(0), new Timestamp(0), WeblogEntryData.DRAFT);
+//        e2.save();
+//        
+//        WeblogCategoryData c3 = wmgr.createWeblogCategory(); 
+//        c3.setName("c3");
+//        c3.setParent(c2);
+//        c3.setWebsite(wd);
+//        c3.save();
+//        
+//        WeblogEntryData e3 = new WeblogEntryData(
+//            null, c3, wd, ud, "title3", null, "text", "anchor", 
+//            new Timestamp(0), new Timestamp(0), WeblogEntryData.DRAFT);
+//        e3.save();
+//        
+//        getRoller().commit(); 
+//        
+//        dest_id = dest.getId();
+//        c1_id = c1.getId();  
+//        c2_id = c2.getId();  
+//        c3_id = c3.getId();  
+//    }
+//    
+//    //-----------------------------------------------------------------------
+//    /**
+//     * @see junit.framework.TestCase#tearDown()
+//     */
+//    public void tearDown() throws Exception
+//    {
+//        super.tearDown();
+//        tearDownTestWeblogs();
+//    }
+//    
+//    //-----------------------------------------------------------------------
+//    
+//    /** Add a small category tree to the small test website (mWebsite). */
+//    public void testGetRecent() throws Exception
+//    {
+//        getRoller().begin(UserData.SYSTEM_USER);
+//        
+//        WebsiteData wd = null;
+//        UserData ud = null;
+//        WeblogCategoryData root = null;
+//        WeblogManager wmgr = getRoller().getWeblogManager();
+//
+//        wd = getRoller().getUserManager().retrieveWebsite(mWebsite.getId());
+//        ud = getRoller().getUserManager().retrieveUser(mUser.getId());
+//        root = wmgr.getRootWeblogCategory(wd);
+//
+//        // create top level folders
+//        WeblogCategoryData t1 = wmgr.createWeblogCategory();
+//        t1.setName("toplevel1");
+//        t1.setParent(root);
+//        t1.setWebsite(wd);
+//        t1.save();       
+//        
+//        WeblogCategoryData t2 = wmgr.createWeblogCategory();
+//        t2.setName("toplevel2");
+//        t2.setParent(root);
+//        t2.setWebsite(wd);
+//        t2.save();       
+//        
+//        WeblogCategoryData t3 = wmgr.createWeblogCategory();
+//        t3.setName("toplevel3");
+//        t3.setParent(root);
+//        t3.setWebsite(wd);
+//        t3.save(); 
+//        
+//        getRoller().commit(); 
+//        
+//        getRoller().begin(UserData.SYSTEM_USER); 
+//        
+//        // get persistent instances
+//        t1 = wmgr.retrieveWeblogCategory(t1.getId());
+//        wd = getRoller().getUserManager().retrieveWebsite(mWebsite.getId());
+//        
+//        // Create four entries in 1st category
+//        WeblogEntryData e1 = new WeblogEntryData(
+//                null, t1, wd, ud, "title1", null, "text1", "anchor", 
+//                new Timestamp(0), new Timestamp(0), WeblogEntryData.DRAFT);
+//        e1.save();
+//        
+//        WeblogEntryData e2 = new WeblogEntryData(
+//                null, t1, wd, ud, "title2", null, "text2", "anchor", 
+//                new Timestamp(0), new Timestamp(0), WeblogEntryData.DRAFT);
+//        e2.save();
+//        
+//        WeblogEntryData e3 = new WeblogEntryData(
+//                null, t1, wd, ud, "title3", null, "text3", "anchor", 
+//                new Timestamp(0), new Timestamp(0), WeblogEntryData.DRAFT);
+//        e3.save();
+//        
+//        WeblogEntryData e4 = new WeblogEntryData(
+//                null, t1, wd, ud, "title4", null, "text4", "anchor", 
+//                new Timestamp(0), new Timestamp(0), WeblogEntryData.DRAFT);
+//        e4.save();
+//        
+//        getRoller().commit(); 
+//        
+//        getRoller().begin(UserData.SYSTEM_USER);
+//        
+//        //List entries = wmgr.getRecentWeblogEntriesArray(
+//            //wd.getUser().getUserName(), new Date(), "toplevel1", 15, false);
+//        
+//        List entries = wmgr.getWeblogEntries(
+//                        wd,
+//                        null,             // startDate
+//                        new Date(),       // endDate
+//                        "toplevel1",      // catName
+//                        null,             // status
+//                        null,             // sortby
+//                        new Integer(15)); // maxEntries
+//
+//        assertEquals(4, entries.size());
+//        
+//        getRoller().rollback();
+//    }
+//    
+//    public void testGetWeblogCategoryRoot() throws Exception
+//    {
+//        getRoller().begin(UserData.SYSTEM_USER);
+//        WeblogManager wmgr = getRoller().getWeblogManager();
+//        assertNotNull(wmgr.getRootWeblogCategory(mWebsite));
+//        getRoller().rollback();
+//    }    
+//    
+//    public void testGetWeblogCategories() throws Exception
+//    {
+//        getRoller().begin(UserData.SYSTEM_USER);
+//        WeblogManager wmgr = getRoller().getWeblogManager();
+//        assertEquals(10, wmgr.getWeblogCategories(mWebsite).size());
+//        getRoller().rollback();
+//    }    
+//    
+//    public void testWeblogCategoryPaths() throws Exception
+//    {
+//        WebsiteData wd = null;
+//        WeblogCategoryData root = null;
+//        WeblogManager wmgr = getRoller().getWeblogManager();
+//        
+//        getRoller().begin(UserData.SYSTEM_USER);
+//        
+//        wd = getRoller().getUserManager().retrieveWebsite(mWebsite.getId());
+//        root = wmgr.getRootWeblogCategory(wd);
+//
+//        WeblogCategoryData f1 = wmgr.createWeblogCategory();
+//        f1.setName("f1");
+//        f1.setParent(root);
+//        f1.setWebsite(wd);
+//        f1.save();
+//        
+//        WeblogCategoryData f2 = wmgr.createWeblogCategory(); 
+//        f2.setName("f2");
+//        f2.setParent(f1);
+//        f2.setWebsite(wd);
+//        f2.save();
+//      
+//        WeblogCategoryData f3 = wmgr.createWeblogCategory(); 
+//        f3.setName("f3");
+//        f3.setParent(f2);
+//        f3.setWebsite(wd);
+//        f3.save();
+//        
+//        getRoller().commit();
+//        
+//        getRoller().begin(UserData.SYSTEM_USER);
+//        
+//        // check count of descendents and ancestors
+//        f1 = wmgr.retrieveWeblogCategory(f1.getId());        
+//        assertEquals(2, f1.getAllDescendentAssocs().size());
+//        assertEquals(1, f1.getAncestorAssocs().size());
+//        
+//        f2 = wmgr.retrieveWeblogCategory(f2.getId());        
+//        assertEquals(1, f2.getAllDescendentAssocs().size());
+//        assertEquals(2, f2.getAncestorAssocs().size());
+//        
+//        f3 = wmgr.retrieveWeblogCategory(f3.getId());        
+//        assertEquals(0, f3.getAllDescendentAssocs().size());
+//        assertEquals(3, f3.getAncestorAssocs().size());
+//        
+//        // test get by path
+//        assertEquals("f1", 
+//            wmgr.getWeblogCategoryByPath(wd, null, "f1").getName());
+//        
+//        assertEquals("f1", 
+//            wmgr.getWeblogCategoryByPath(wd, null, "/f1").getName());
+//        
+//        assertEquals("f2", 
+//            wmgr.getWeblogCategoryByPath(wd, null, "/f1/f2").getName());
+//        
+//        assertEquals("f3", 
+//            wmgr.getWeblogCategoryByPath(wd, null, "/f1/f2/f3").getName());
+//        
+//        // test path creation
+//        f3 = wmgr.getWeblogCategoryByPath(wd, null, "/f1/f2/f3");
+//        String pathString = wmgr.getPath(f3);
+//        String[] pathArray = Utilities.stringToStringArray(pathString,"/");
+//        assertEquals("f1", pathArray[0]);
+//        assertEquals("f2", pathArray[1]);
+//        assertEquals("f3", pathArray[2]);
+//        
+//        getRoller().commit();
+//    }    
+//        
+//    //-----------------------------------------------------------------------
+//    
+//    public void testGetWeblogEntryByAnchor() throws Exception
+//    {
+//        WeblogManager wmgr = getRoller().getWeblogManager();
+//        
+//        WeblogEntryData entry1 = (WeblogEntryData)mEntriesCreated.get(0);
+//        
+//        WebsiteData website = entry1.getWebsite();
+//        
+//        WeblogEntryData entry2 = wmgr.getWeblogEntryByAnchor(
+//            website, entry1.getAnchor() );
+//        
+//        assertEquals( entry1.getId(), entry2.getId() );
+//    }
+//     
+//    //-----------------------------------------------------------------------
+//    /**
+//     * Test latest publishTime for a User.
+//     * This test passes inconsistently - I suspect Hibernate.
+//     */
+//    public void testGetWeblogLastUpdateTimeForUser() throws Exception
+//    {
+//        UserManager umgr = getRoller().getUserManager();
+//        WeblogManager wmgr = getRoller().getWeblogManager();
+//
+//        /** 
+//         * really weird, but we cannot get 'entry1' directly,
+//         * we have to iterate over entries.  We end up getting the same one
+//         * either way, but fetching it directly fails!
+//         */
+//        int lastEntryIndex = (mEntriesCreated.size()-1);
+//        //System.out.println("# entries:" + lastEntryIndex);
+//        WeblogEntryData entry1 = null;
+//        //WeblogEntryData entry1 = (WeblogEntryData)mEntriesCreated.get(lastEntryIndex);
+//        if (entry1 == null || !entry1.isPublished()) // if not published, find one
+//        {
+//            for (int i=lastEntryIndex; i >= 0; i--)
+//            {
+//                entry1 = (WeblogEntryData)        
+//                    mEntriesCreated.get(i); // last entry is newest
+//                //System.out.println("entry " + i + "published:" + entry1.getPublishEntry());
+//                if (entry1.isPublished()) {
+//                    break;
+//                }
+//            }
+//        }
+//        
+//        WebsiteData website = entry1.getWebsite();
+//        UserData user = (UserData)umgr.getUsers(website, null).get(0);
+//        Date updateTime = wmgr.getWeblogLastPublishTime(website);
+//                
+//        assertEquals("THIS FAILS RANDOMLY, TRY AGAIN", entry1.getPubTime(),updateTime);
+//    }
+//
+//    //-----------------------------------------------------------------------
+//    /**
+//     * Test latest publishTime when no User is specified.
+//     * This test passes inconsistently - I suspect Hibernate.
+//     */
+//    public void testGetWeblogLastUpdateTimeForAll() throws Exception
+//    {
+//        WeblogManager wmgr = getRoller().getWeblogManager();
+//
+//        /** 
+//         * Have to iterate and test to find the latest *enabled* entry.
+//         */
+//        int lastEntryIndex = (mEntriesCreated.size()-1);
+//        //System.out.println("# entries:" + lastEntryIndex);
+//        WeblogEntryData entry1 = null;
+//        WeblogEntryData temp = null;
+//        for (int i=lastEntryIndex; i >= 0; i--)
+//        {
+//            temp = (WeblogEntryData)        
+//                mEntriesCreated.get(i); // last entry is newest
+//            //System.out.println("entry " + i + "published:" + entry1.getPublishEntry());
+//            if (temp.isPublished()) 
+//            {
+//                if (entry1 ==  null || entry1.getPubTime().compareTo(temp.getPubTime()) < 0)
+//                {   
+//                    if (entry1 != null)
+//                        System.out.println("replacing " + entry1.getTitle() + " with " + temp.getTitle());
+//                    else
+//                        System.out.println("setting entry1 to " + temp.getTitle());
+//                    entry1 = temp;
+//                }
+//            }
+//        }
+//        
+//        Date updateTime = wmgr.getWeblogLastPublishTime(null);
+//
+//        assertEquals("THIS FAILS RANDOMLY, TRY AGAIN", entry1.getPubTime(),updateTime);
+//    }
+//
+//    /** Count weblog entries in a weblogEntry map */
+//    private int countEntries( Map entryMap ) 
+//    {
+//        int count = 0;
+//        Iterator days = entryMap.values().iterator();
+//        while (days.hasNext())
+//        {
+//            List dayEntries = (List) days.next();
+//            Iterator entries = dayEntries.iterator();
+//            while (entries.hasNext())
+//            {
+//                entries.next();
+//                count++;
+//            }
+//        }
+//        return count;
+//    }
+//          
+//    public void testIsWeblogCategoryInUse() throws Exception
+//    {
+//        WeblogManager wmgr = getRoller().getWeblogManager();
+//        UserManager umgr = getRoller().getUserManager();
+//                    
+//        getRoller().begin(UserData.SYSTEM_USER);
+//        
+//        WebsiteData website = umgr.retrieveWebsite(mWebsite.getId());
+//        WeblogEntryData entry = (WeblogEntryData)mEntriesCreated.get(2);
+//        WeblogCategoryData rootCat = wmgr.getRootWeblogCategory(website);
+//        
+//        WeblogCategoryData usedCat = 
+//            wmgr.retrieveWeblogCategory(entry.getCategory().getId()); 
+//                         
+//        WeblogCategoryData unusedCat = wmgr.createWeblogCategory(
+//            website, rootCat, "testy", "tasty", "testy.gif");
+//        unusedCat.save();
+//            
+//        getRoller().commit();
+//        
+//        getRoller().begin(UserData.SYSTEM_USER);
+//        usedCat = wmgr.retrieveWeblogCategory(usedCat.getId());
+//        assertTrue(usedCat.isInUse());
+//        
+//        unusedCat = wmgr.retrieveWeblogCategory(unusedCat.getId());
+//        assertFalse(unusedCat.isInUse());       
+//        getRoller().commit();
+//    }
+//
+//    public void testStoreComment() throws Exception
+//    {
+//        getRoller().begin(UserData.SYSTEM_USER);
+//        WeblogManager wmgr = getRoller().getWeblogManager();
+//        
+//        // Get entry to which comment will be added
 //        WeblogEntryData entry1 = (WeblogEntryData)mEntriesCreated.get(1);
-//        WeblogEntryData entry2 = (WeblogEntryData)mEntriesCreated.get(2);
-//        WeblogEntryData entry3 = (WeblogEntryData)mEntriesCreated.get(3);
-//        WeblogEntryData entry4 = (WeblogEntryData)mEntriesCreated.get(4);
-//        WeblogEntryData entry5 = (WeblogEntryData)mEntriesCreated.get(5);
-//        WeblogEntryData entry6 = (WeblogEntryData)mEntriesCreated.get(6);
-//        WeblogEntryData entry7 = (WeblogEntryData)mEntriesCreated.get(7);
 //        
-//        // next and prev only get published entries
+//        // Ensure that entry is a persistent instance
+//        entry1 = getRoller().getWeblogManager().retrieveWeblogEntry(
+//            entry1.getId());
+//        
+//        CommentData comment = new CommentData();
+//        comment.setWeblogEntry(entry1);
+//        comment.setName("TestCommentUser");
+//        comment.setEmail("test@test.com");
+//        comment.setContent("");
+//        comment.setPostTime(new java.sql.Timestamp(new Date().getTime()));
+//        comment.setSpam(Boolean.FALSE);
+//        comment.setNotify(Boolean.FALSE);
+//        comment.setNotify(Boolean.FALSE);
+//        comment.setApproved(Boolean.TRUE);
+//        comment.setPending(Boolean.FALSE);
+//        comment.save();
+//        getRoller().commit();
+//        
+//        List comments = wmgr.getComments(
+//                null,   // website
+//                entry1, // weblogEntry
+//                null,   // search
+//                null,   // start
+//                null,   // end
+//                null,   // approved
+//                null,   // pending
+//                null,   // spam
+//                true,   // reverseChrono
+//                0,      // offset
+//                -1);    // length
+//        assertTrue(comments.size() > mCommentCount);
 //        
-//        // entry0 is the first published entry
-//        assertEquals(null, wmgr.getPreviousEntry(entry0, null));
+//        getRoller().begin(UserData.SYSTEM_USER);
+//        wmgr.removeComment(comment.getId());
+//        getRoller().commit();
+//    }   
+//    
+//    public void testMoveCategoryContents() throws RollerException
+//    {
+//        WeblogManager wmgr = getRoller().getWeblogManager();
 //        
-//        // next published entry is entry2
-//        assertEquals(entry1, wmgr.getNextEntry(entry0, null));
+//        WeblogCategoryData c1 = wmgr.retrieveWeblogCategory(c1_id);       
+//        //WeblogCategoryData c2 = wmgr.retrieveWeblogCategory(c2_id);       
+//        //WeblogCategoryData c3 = wmgr.retrieveWeblogCategory(c3_id);       
+//        WeblogCategoryData dest = wmgr.retrieveWeblogCategory(dest_id);              
+//        
+//        getRoller().begin(UserData.SYSTEM_USER);
+//               
+//        // verify number of entries in each category
+//        dest = wmgr.retrieveWeblogCategory(dest.getId());
+//        c1 = wmgr.retrieveWeblogCategory(c1.getId());
+//        assertEquals(0, dest.retrieveWeblogEntries(true).size());
+//        assertEquals(0, dest.retrieveWeblogEntries(false).size());
+//        assertEquals(1, c1.retrieveWeblogEntries(false).size());
+//        assertEquals(3, c1.retrieveWeblogEntries(true).size());
 //        
-//        // prev to entry2 is entry 0
-//        assertEquals(entry0, wmgr.getPreviousEntry(entry2, null));
+//        // move contents of source category c1 to destination catetory dest
+//        c1.moveContents(dest);
 //        
-//        // constrain prev/next by category
+//        getRoller().commit(); 
+//        
+//        getRoller().begin(UserData.SYSTEM_USER);
+//        
+//        // after move, verify number of entries in each category
+//        dest = wmgr.retrieveWeblogCategory(dest.getId());
+//        c1 = wmgr.retrieveWeblogCategory(c1.getId());
+//        assertEquals(3, dest.retrieveWeblogEntries(true).size());
+//        assertEquals(3, dest.retrieveWeblogEntries(false).size());        
+//        assertEquals(0, c1.retrieveWeblogEntries(true).size());
+//        assertEquals(0, c1.retrieveWeblogEntries(false).size());
+//        
+//        getRoller().commit();      
+//    }
+//    
+//    public void testMoveCategoryProtection() throws RollerException
+//    {
+//        boolean safe = false;
+//        try 
+//        {
+//            getRoller().begin(UserData.SYSTEM_USER);
+//            WeblogManager wmgr = getRoller().getWeblogManager();        
+//                   
+//            // Move category into one of it's children
+//            WeblogCategoryData c1 = wmgr.retrieveWeblogCategory(c1_id);       
+//            WeblogCategoryData c3 = wmgr.retrieveWeblogCategory(c3_id);       
+//            wmgr.moveWeblogCategoryContents(c1.getId(), c3.getId());
+//            c3.save();
+//            c1.save();
+//            getRoller().commit(); 
+//        }
+//        catch (RollerException e)
+//        {
+//            safe = true;
+//        }
+//        assertTrue(safe);
+//    }
+//    
+//    public void testMoveCategory() throws RollerException
+//    {
+//        getRoller().begin(UserData.SYSTEM_USER);
+//        WeblogManager wmgr = getRoller().getWeblogManager();
+//        
+//        WeblogCategoryData c1 = wmgr.retrieveWeblogCategory(c1_id);       
+//        WeblogCategoryData c2 = wmgr.retrieveWeblogCategory(c2_id);       
+//        WeblogCategoryData c3 = wmgr.retrieveWeblogCategory(c3_id);       
+//        WeblogCategoryData dest = wmgr.retrieveWeblogCategory(dest_id);              
+//               
+//        // verify number of entries in each category
+//        dest = wmgr.retrieveWeblogCategory(dest.getId());
+//        c1 = wmgr.retrieveWeblogCategory(c1.getId());
+//        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
+//        c1.setParent(dest);
+//        c1.save();
+//        
+//        getRoller().commit(); 
+//        
+//        getRoller().begin(UserData.SYSTEM_USER);
+//        
+//        // after move, verify number of entries in each category
+//        dest = wmgr.retrieveWeblogCategory(dest.getId());
+//        c1 = wmgr.retrieveWeblogCategory(c1_id);       
+//        c2 = wmgr.retrieveWeblogCategory(c2_id);       
+//        c3 = wmgr.retrieveWeblogCategory(c3_id);
+//               
+//        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());
+//        
+//        getRoller().commit();      
+//    }
+//    
+////    public void testNextPrevPost() throws RollerException
+////    {
+////        getRoller().begin(UserData.SYSTEM_USER);
+////        WeblogManager wmgr = getRoller().getWeblogManager();
+////        
+////        // category: root
+////        WeblogEntryData entry0 = (WeblogEntryData)mEntriesCreated.get(0);
+////        WeblogEntryData entry1 = (WeblogEntryData)mEntriesCreated.get(1);
+////        WeblogEntryData entry2 = (WeblogEntryData)mEntriesCreated.get(2);
+////        WeblogEntryData entry3 = (WeblogEntryData)mEntriesCreated.get(3);
+////        WeblogEntryData entry4 = (WeblogEntryData)mEntriesCreated.get(4);
+////        WeblogEntryData entry5 = (WeblogEntryData)mEntriesCreated.get(5);
+////        WeblogEntryData entry6 = (WeblogEntryData)mEntriesCreated.get(6);
+////        WeblogEntryData entry7 = (WeblogEntryData)mEntriesCreated.get(7);
+////        
+////        // next and prev only get published entries
+////        
+////        // entry0 is the first published entry
+////        assertEquals(null, wmgr.getPreviousEntry(entry0, null));
+////        
+////        // next published entry is entry2
+////        assertEquals(entry1, wmgr.getNextEntry(entry0, null));
+////        
+////        // prev to entry2 is entry 0
+////        assertEquals(entry0, wmgr.getPreviousEntry(entry2, null));
+////        
+////        // constrain prev/next by category
+////        
+////        WeblogCategoryData cat = (WeblogCategoryData)mCategoriesCreated.get(1);
+////        
+////        assertEquals(null, wmgr.getPreviousEntry(entry5, "/root-cat1/root-cat1-cat0"));
+////        assertEquals(entry7, wmgr.getNextEntry(entry5, "/root-cat1/root-cat1-cat0"));
+////        assertEquals(entry5, wmgr.getPreviousEntry(entry7, "/root-cat1/root-cat1-cat0"));
+////        
+////        getRoller().rollback();
+////    }
+//    
+//    public void testGetComments() throws RollerException
+//    {
+//        getRoller().begin(UserData.SYSTEM_USER);
+//        WeblogEntryData entry0 = (WeblogEntryData)mEntriesCreated.get(0);
+//        WeblogManager wmgr = getRoller().getWeblogManager();
+//        assertEquals(mCommentCount, wmgr.getComments(
+//                null,   // website
+//                entry0, // weblogEntry
+//                null,   // search
+//                null,   // start
+//                null,   // end
+//                null,   // approved
+//                null,   // pending
+//                null,   // spam
+//                true,   // reverseChrono
+//                0, -1     // offset, size
+//                ).size());        
+//        getRoller().commit();
+//    }
+//    
+//    public void testQueryWeblogEntries() throws RollerException
+//    {
+//        getRoller().begin(UserData.SYSTEM_USER);
+//        WeblogManager wmgr = getRoller().getWeblogManager();
+//        UserManager umgr = getRoller().getUserManager();
+//        
+//        WebsiteData website = (WebsiteData)mWebsitesCreated.get(0);
+//        website = umgr.retrieveWebsite(website.getId());
+//
+//        // PUBLISHISHED ONLY
+//        List publishedEntries = wmgr.getWeblogEntries(
+//                        website,                    // userName
+//                        null,                       // startDate
+//                        new Date(),                 // endDate
+//                        null,                       // catName
+//                        WeblogEntryData.PUBLISHED,  // status
+//                        null,                       // sortby
+//                        null);                      // maxEntries
+//        assertEquals(mExpectedPublishedEntryCount, publishedEntries.size());
+//                    
+//        // DRAFT ONLY
+//        List draftEntries = wmgr.getWeblogEntries(
+//                        website,                 // userName
+//                        null,                    // startDate
+//                        new Date(),              // endDate
+//                        null,                    // catName
+//                        WeblogEntryData.DRAFT,   // status
+//                        null,                    // sortby
+//                        null);                   // maxEntries
+//        assertEquals(mExpectedEntryCount-mExpectedPublishedEntryCount, draftEntries.size());
+//                          
+//        // PUBLISHED and DRAFT
+//        List allEntries = wmgr.getWeblogEntries(
+//                        website,                 // userName
+//                        null,                    // startDate
+//                        new Date(),              // endDate
+//                        null,                    // catName
+//                        null,                    // status
+//                        null,                    // sortby
+//                        null);                   // maxEntries
+//        assertEquals(mExpectedEntryCount, allEntries.size());
+//
+//        // no status specified      
+//        List allEntries2 = wmgr.getWeblogEntries(
+//                        website,                 // userName
+//                        null,                    // startDate
+//                        new Date(),              // endDate
+//                        null,                    // catName
+//                        null,                    // status
+//                        null,                    // sortby
+//                        null);                   // maxEntries
+//        assertEquals(mExpectedEntryCount, allEntries2.size());
+//                                            
+//        getRoller().commit();
+//    }
+//    
+//    public void testGetRecentComments() throws Exception
+//    {
+//        getRoller().begin(UserData.SYSTEM_USER);
+//        WeblogManager wmgr = getRoller().getWeblogManager();
+//        UserManager umgr = getRoller().getUserManager();
+//        
+//        WebsiteData website = (WebsiteData)mWebsitesCreated.get(0);
+//        website = umgr.retrieveWebsite(website.getId());
+//        List comments = wmgr.getComments(
+//                website, // website
+//                null,    // weblogEntry
+//                null,    // search
+//                null,    // start
+//                null,    // end
+//                null,    // approved
+//                null,    // pending
+//                null,    // spam
+//                true,    // reverseChrono
+//                0, 2);   // offset, size
+//        assertTrue(comments.size() > 1);
+//        // Comment 0 should be named 'name1' and Comment 1 'name0'
+//        /*
+//        System.out.println(((CommentData)comments.get(0)).getName());
+//        System.out.println(((CommentData)comments.get(1)).getName());
+//        */
+//        assertTrue("name1".compareTo("name0") >0);
+//        assertTrue(
+//            ((CommentData)comments.get(0)).getName().compareTo(
+//                ((CommentData)comments.get(1)).getName()) > 0);
+//       /*
+//        System.out.println(((CommentData)comments.get(0)).getPostTime());
+//        System.out.println(((CommentData)comments.get(1)).getPostTime());
+//        */
+//        assertTrue(
+//               ((CommentData)comments.get(0)).getPostTime().compareTo(
+//                   ((CommentData)comments.get(1)).getPostTime()) > 0);
+//    }
+//    
+//    public void testGetLastPublishTime() throws Exception
+//    {
+//        getRoller().begin(UserData.SYSTEM_USER);
+//        WeblogManager wmgr = getRoller().getWeblogManager();
+//        WebsiteData website = (WebsiteData)mWebsitesCreated.get(0);
+//        
+//        Date lastPub = wmgr.getWeblogLastPublishTime(website);
+//        //System.out.println(lastPub);
+//        assertTrue(lastPub.compareTo(new Date()) <= 0);
+//    }
+//    
+//    public void testEntryAttributes() throws Exception {
+//        getRoller().begin(UserData.SYSTEM_USER);
+//        WeblogManager wmgr = getRoller().getWeblogManager();
+//        WebsiteData website = (WebsiteData)mWebsitesCreated.get(0); 
+//        UserData user = (UserData)mUsersCreated.get(0);
+//        
+//        WeblogCategoryData cat = wmgr.getRootWeblogCategory(website);       
+//
+//        WeblogEntryData entry = new WeblogEntryData(
+//                null, cat, website, user, "title2", null, "text2", "attributetest", 
+//                new Timestamp(0), new Timestamp(0), WeblogEntryData.DRAFT);
+//        entry.save();
+//        assertNotNull(entry.getId());
+//                
+//        entry.putEntryAttribute("testname", "testvalue");
+//        entry.putEntryAttribute("testname2", "testvalue2");
+//        entry.save();
+//        
+//        getRoller().commit();
+//       
+//        WeblogEntryData fetchedEntry = wmgr.retrieveWeblogEntry(entry.getId());
+//        assertNotNull(fetchedEntry.getEntryAttributes());
+//        assertEquals(2, fetchedEntry.getEntryAttributes().size());
+//        
+//        assertEquals(fetchedEntry.findEntryAttribute("testname"), "testvalue");
+//        assertEquals(fetchedEntry.findEntryAttribute("testname2"), "testvalue2");
+//    }
+//
+//
+//    public void testPermissions() throws Exception
+//    {
+//        getRoller().begin(UserData.ANONYMOUS_USER);
+//        UserManager umgr = getRoller().getUserManager();
 //        
-//        WeblogCategoryData cat = (WeblogCategoryData)mCategoriesCreated.get(1);
+//        // evil testuser
+//        UserData testuser = umgr.getUser("testuser0");       
+//        assertNotNull(testuser);
 //        
-//        assertEquals(null, wmgr.getPreviousEntry(entry5, "/root-cat1/root-cat1-cat0"));
-//        assertEquals(entry7, wmgr.getNextEntry(entry5, "/root-cat1/root-cat1-cat0"));
-//        assertEquals(entry5, wmgr.getPreviousEntry(entry7, "/root-cat1/root-cat1-cat0"));
+//        // gets hold of testuser0's entry
+//        WebsiteData website0 = (WebsiteData)umgr.getWebsites(
+//                umgr.getUser("testuser2"), null, null).get(0);
+//        assertNotNull(website0);
+//        List entries = getRoller().getWeblogManager().getWeblogEntries(
+//                website0,
+//                null,       // start
+//                new Date(), // end
+//                null,       // cat
+//                null,       // status
+//                null,       // sortby
+//                new Integer(1));
+//        WeblogEntryData entry = (WeblogEntryData)entries.get(0);
+//        assertNotNull(entry);
 //        
+//        // and tries to save it
+//        getRoller().setUser(testuser);
+//        boolean denied = false; 
+//        try 
+//        {
+//            entry.save();
+//        }
+//        catch (RollerPermissionsException e)
+//        {
+//            // permission denied!
+//            denied = true;
+//        }       
+//        assertTrue(denied);
 //        getRoller().rollback();
 //    }
-    
-    public void testGetComments() throws RollerException
-    {
-        getRoller().begin(UserData.SYSTEM_USER);
-        WeblogEntryData entry0 = (WeblogEntryData)mEntriesCreated.get(0);
-        WeblogManager wmgr = getRoller().getWeblogManager();
-        assertEquals(mCommentCount, wmgr.getComments(
-                null,   // website
-                entry0, // weblogEntry
-                null,   // search
-                null,   // start
-                null,   // end
-                null,   // approved
-                null,   // pending
-                null,   // spam
-                true,   // reverseChrono
-                0, -1     // offset, size
-                ).size());        
-        getRoller().commit();
-    }
-    
-    public void testQueryWeblogEntries() throws RollerException
-    {
-        getRoller().begin(UserData.SYSTEM_USER);
-        WeblogManager wmgr = getRoller().getWeblogManager();
-        UserManager umgr = getRoller().getUserManager();
-        
-        WebsiteData website = (WebsiteData)mWebsitesCreated.get(0);
-        website = umgr.retrieveWebsite(website.getId());
-
-        // PUBLISHISHED ONLY
-        List publishedEntries = wmgr.getWeblogEntries(
-                        website,                    // userName
-                        null,                       // startDate
-                        new Date(),                 // endDate
-                        null,                       // catName
-                        WeblogEntryData.PUBLISHED,  // status
-                        null,                       // sortby
-                        null);                      // maxEntries
-        assertEquals(mExpectedPublishedEntryCount, publishedEntries.size());
-                    
-        // DRAFT ONLY
-        List draftEntries = wmgr.getWeblogEntries(
-                        website,                 // userName
-                        null,                    // startDate
-                        new Date(),              // endDate
-                        null,                    // catName
-                        WeblogEntryData.DRAFT,   // status
-                        null,                    // sortby
-                        null);                   // maxEntries
-        assertEquals(mExpectedEntryCount-mExpectedPublishedEntryCount, draftEntries.size());
-                          
-        // PUBLISHED and DRAFT
-        List allEntries = wmgr.getWeblogEntries(
-                        website,                 // userName
-                        null,                    // startDate
-                        new Date(),              // endDate
-                        null,                    // catName
-                        null,                    // status
-                        null,                    // sortby
-                        null);                   // maxEntries
-        assertEquals(mExpectedEntryCount, allEntries.size());
-
-        // no status specified      
-        List allEntries2 = wmgr.getWeblogEntries(
-                        website,                 // userName
-                        null,                    // startDate
-                        new Date(),              // endDate
-                        null,                    // catName
-                        null,                    // status
-                        null,                    // sortby
-                        null);                   // maxEntries
-        assertEquals(mExpectedEntryCount, allEntries2.size());
-                                            
-        getRoller().commit();
-    }
-    
-    public void testGetRecentComments() throws Exception
-    {
-        getRoller().begin(UserData.SYSTEM_USER);
-        WeblogManager wmgr = getRoller().getWeblogManager();
-        UserManager umgr = getRoller().getUserManager();
-        
-        WebsiteData website = (WebsiteData)mWebsitesCreated.get(0);
-        website = umgr.retrieveWebsite(website.getId());
-        List comments = wmgr.getComments(
-                website, // website
-                null,    // weblogEntry
-                null,    // search
-                null,    // start
-                null,    // end
-                null,    // approved
-                null,    // pending
-                null,    // spam
-                true,    // reverseChrono
-                0, 2);   // offset, size
-        assertTrue(comments.size() > 1);
-        // Comment 0 should be named 'name1' and Comment 1 'name0'
-        /*
-        System.out.println(((CommentData)comments.get(0)).getName());
-        System.out.println(((CommentData)comments.get(1)).getName());
-        */
-        assertTrue("name1".compareTo("name0") >0);
-        assertTrue(
-            ((CommentData)comments.get(0)).getName().compareTo(
-                ((CommentData)comments.get(1)).getName()) > 0);
-       /*
-        System.out.println(((CommentData)comments.get(0)).getPostTime());
-        System.out.println(((CommentData)comments.get(1)).getPostTime());
-        */
-        assertTrue(
-               ((CommentData)comments.get(0)).getPostTime().compareTo(
-                   ((CommentData)comments.get(1)).getPostTime()) > 0);
-    }
-    
-    public void testGetLastPublishTime() throws Exception
-    {
-        getRoller().begin(UserData.SYSTEM_USER);
-        WeblogManager wmgr = getRoller().getWeblogManager();
-        WebsiteData website = (WebsiteData)mWebsitesCreated.get(0);
-        
-        Date lastPub = wmgr.getWeblogLastPublishTime(website);
-        //System.out.println(lastPub);
-        assertTrue(lastPub.compareTo(new Date()) <= 0);
-    }
-    
-    public void testEntryAttributes() throws Exception {
-        getRoller().begin(UserData.SYSTEM_USER);
-        WeblogManager wmgr = getRoller().getWeblogManager();
-        WebsiteData website = (WebsiteData)mWebsitesCreated.get(0); 
-        UserData user = (UserData)mUsersCreated.get(0);
-        
-        WeblogCategoryData cat = wmgr.getRootWeblogCategory(website);       
-
-        WeblogEntryData entry = new WeblogEntryData(
-                null, cat, website, user, "title2", null, "text2", "attributetest", 
-                new Timestamp(0), new Timestamp(0), WeblogEntryData.DRAFT);
-        entry.save();
-        assertNotNull(entry.getId());
-                
-        entry.putEntryAttribute("testname", "testvalue");
-        entry.putEntryAttribute("testname2", "testvalue2");
-        entry.save();
-        
-        getRoller().commit();
-       
-        WeblogEntryData fetchedEntry = wmgr.retrieveWeblogEntry(entry.getId());
-        assertNotNull(fetchedEntry.getEntryAttributes());
-        assertEquals(2, fetchedEntry.getEntryAttributes().size());
-        
-        assertEquals(fetchedEntry.findEntryAttribute("testname"), "testvalue");
-        assertEquals(fetchedEntry.findEntryAttribute("testname2"), "testvalue2");
-    }
-
-
-    public void testPermissions() throws Exception
-    {
-        getRoller().begin(UserData.ANONYMOUS_USER);
-        UserManager umgr = getRoller().getUserManager();
-        
-        // evil testuser
-        UserData testuser = umgr.getUser("testuser0");       
-        assertNotNull(testuser);
-        
-        // gets hold of testuser0's entry
-        WebsiteData website0 = (WebsiteData)umgr.getWebsites(
-                umgr.getUser("testuser2"), null, null).get(0);
-        assertNotNull(website0);
-        List entries = getRoller().getWeblogManager().getWeblogEntries(
-                website0,
-                null,       // start
-                new Date(), // end
-                null,       // cat
-                null,       // status
-                null,       // sortby
-                new Integer(1));
-        WeblogEntryData entry = (WeblogEntryData)entries.get(0);
-        assertNotNull(entry);
-        
-        // and tries to save it
-        getRoller().setUser(testuser);
-        boolean denied = false; 
-        try 
-        {
-            entry.save();
-        }
-        catch (RollerPermissionsException e)
-        {
-            // permission denied!
-            denied = true;
-        }       
-        assertTrue(denied);
-        getRoller().rollback();
-    }
 }
-
+//

Added: incubator/roller/branches/roller-newbackend/tests/org/roller/business/WeblogTemplateTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/tests/org/roller/business/WeblogTemplateTest.java?rev=392622&view=auto
==============================================================================
--- incubator/roller/branches/roller-newbackend/tests/org/roller/business/WeblogTemplateTest.java (added)
+++ incubator/roller/branches/roller-newbackend/tests/org/roller/business/WeblogTemplateTest.java Sat Apr  8 15:42:58 2006
@@ -0,0 +1,74 @@
+/*
+ * WeblogTemplateTest.java
+ *
+ * Created on April 7, 2006, 2:57 PM
+ */
+
+package org.roller.business;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.roller.TestUtils;
+import org.roller.pojos.UserData;
+import org.roller.pojos.WebsiteData;
+
+
+/**
+ * Test WeblogTemplate related business operations.
+ *
+ * That includes:
+ *   - create a template
+ *   - update a template
+ *   - delete a template
+ *   - get a template by id
+ *   - get a template by name
+ *   - get a template by link
+ *
+ */
+public class WeblogTemplateTest extends TestCase {
+    
+    UserData testUser = null;
+    WebsiteData testWeblog = null;
+    
+    
+    public WeblogTemplateTest(String name) {
+        super(name);
+    }
+    
+    
+    public static Test suite() {
+        return new TestSuite(WeblogTemplateTest.class);
+    }
+    
+    
+    /**
+     * All tests in this suite require a user and a weblog.
+     */
+    public void setUp() throws Exception {
+        testUser = TestUtils.setupUser("permsTestUser");
+        testWeblog = TestUtils.setupWeblog("permsTestWeblog", testUser);
+    }
+    
+    public void tearDown() throws Exception {
+        TestUtils.teardownWeblog(testWeblog.getHandle());
+        TestUtils.teardownUser(testUser.getUserName());
+    }
+    
+    
+    /**
+     * Test basic persistence operations ... Create, Update, Delete
+     */
+    public void testTemplateCRUD() throws Exception {
+        
+    }
+    
+    
+    /**
+     * Test lookup mechanisms ... id, name, link
+     */
+    public void testPermissionsLookups() throws Exception {
+        
+    }
+    
+}

Added: incubator/roller/branches/roller-newbackend/tests/org/roller/business/WeblogTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/tests/org/roller/business/WeblogTest.java?rev=392622&view=auto
==============================================================================
--- incubator/roller/branches/roller-newbackend/tests/org/roller/business/WeblogTest.java (added)
+++ incubator/roller/branches/roller-newbackend/tests/org/roller/business/WeblogTest.java Sat Apr  8 15:42:58 2006
@@ -0,0 +1,228 @@
+package org.roller.business;
+
+import java.util.List;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.roller.RollerException;
+import org.roller.model.RollerFactory;
+import org.roller.model.UserManager;
+import org.roller.pojos.UserData;
+import org.roller.pojos.WebsiteData;
+
+
+/**
+ * Test Weblog related business operations.
+ *
+ * That includes:
+ *   - create a weblog
+ *   - update a weblog
+ *   - delete a weblog
+ *   - get a weblog by id
+ *   - get a weblog by handle (enabled and disabled)
+ *   - get all weblogs for a user (enabled and disabled, active and inactive)
+ *
+ */
+public class WeblogTest extends TestCase {
+    
+    public static Log log = LogFactory.getLog(WeblogTest.class);
+    
+    UserData testUser = null;
+    WebsiteData testWeblog1 = null;
+    WebsiteData testWeblog2 = null;
+    
+    
+    public WeblogTest(String name) {
+        super(name);
+    }
+    
+    
+    public static Test suite() {
+        return new TestSuite(WeblogTest.class);
+    }
+    
+    
+    /**
+     * All tests in this suite require a User to run, so we
+     * create that user now and add them to the db.
+     */
+    public void setUp() throws Exception {
+        
+        testUser = new UserData();
+        testUser.setUserName("testUser");
+        testUser.setPassword("password");
+        testUser.setFullName("Test User");
+        testUser.setEmailAddress("TestUser@dev.null");
+        testUser.setLocale("en_US");
+        testUser.setTimeZone("America/Los_Angeles");
+        testUser.setDateCreated(new java.util.Date());
+        testUser.setEnabled(Boolean.TRUE);
+        
+        testWeblog1 = new WebsiteData();
+        testWeblog1.setName("Test Weblog 1");
+        testWeblog1.setDescription("Test Weblog 1");
+        testWeblog1.setHandle("testweblog1");
+        testWeblog1.setEmailAddress("testweblog1@dev.null");
+        testWeblog1.setEditorPage("editor-text.jsp");
+        testWeblog1.setBlacklist("");
+        testWeblog1.setEmailFromAddress("");
+        testWeblog1.setEditorTheme("basic");
+        testWeblog1.setLocale("en_US");
+        testWeblog1.setTimeZone("America/Los_Angeles");
+        testWeblog1.setDateCreated(new java.util.Date());
+        
+        testWeblog2 = new WebsiteData();
+        testWeblog2.setName("Test Weblog 2");
+        testWeblog2.setDescription("Test Weblog 2");
+        testWeblog2.setHandle("testWeblog2");
+        testWeblog2.setEmailAddress("testWeblog2@dev.null");
+        testWeblog2.setEditorPage("editor-text.jsp");
+        testWeblog2.setBlacklist("");
+        testWeblog2.setEmailFromAddress("");
+        testWeblog2.setEditorTheme("basic");
+        testWeblog2.setLocale("en_US");
+        testWeblog2.setTimeZone("America/Los_Angeles");
+        testWeblog2.setDateCreated(new java.util.Date());
+            
+        // add test user
+        UserManager mgr = RollerFactory.getRoller().getUserManager();
+        mgr.addUser(testUser);
+        
+        log.debug("testUser id = "+testUser.getId());
+    }
+    
+    public void tearDown() throws Exception {
+        
+        log.debug("testUser id = "+testUser.getId());
+        
+        // remove test user
+        UserManager mgr = RollerFactory.getRoller().getUserManager();
+        UserData user = mgr.getUser(testUser.getUserName());
+        mgr.removeUser(user);
+        testUser = null;
+    }
+    
+    
+    /**
+     * Test basic persistence operations ... Create, Update, Delete
+     */
+    public void testWeblogCRUD() throws Exception {
+        
+        UserManager mgr = RollerFactory.getRoller().getUserManager();
+        UserData user = mgr.getUser(testUser.getUserName());
+        
+        WebsiteData weblog = null;
+        
+        // make sure test weblog does not exist
+        weblog = mgr.getWebsiteByHandle(testWeblog1.getHandle());
+        assertNull(weblog);
+        
+        // add test weblog
+        testWeblog1.setCreator(user);
+        mgr.createWebsite(testWeblog1);
+        
+        // make sure test weblog exists
+        weblog = mgr.getWebsiteByHandle(testWeblog1.getHandle());
+        assertNotNull(weblog);
+        assertEquals(testWeblog1.getHandle(), weblog.getHandle());
+        
+        // modify weblog and save
+        weblog.setName("testtesttest");
+        mgr.storeWebsite(weblog);
+        weblog = null;
+        
+        // make sure changes were saved
+        weblog = mgr.getWebsiteByHandle(testWeblog1.getHandle());
+        assertNotNull(weblog);
+        assertEquals("testtesttest", weblog.getName());
+        
+        // remove test weblog
+        mgr.removeWebsite(weblog);
+        weblog = null;
+        
+        // make sure weblog no longer exists
+        weblog = mgr.getWebsiteByHandle(testWeblog1.getHandle());
+        assertNull(weblog);
+    }
+    
+    
+    /**
+     * Test lookup mechanisms ... Id, Handle, User
+     */
+    public void testWeblogLookups() throws Exception {
+        
+        UserManager mgr = RollerFactory.getRoller().getUserManager();
+        UserData user = mgr.getUser(testUser.getUserName());
+        
+        WebsiteData weblog = null;
+        
+        // make sure test weblog does not exist
+        weblog = mgr.getWebsiteByHandle(testWeblog1.getHandle());
+        assertNull(weblog);
+        
+        // add test weblogs
+        testWeblog1.setCreator(user);
+        mgr.createWebsite(testWeblog1);
+        String id1 = testWeblog1.getId();
+        testWeblog2.setCreator(user);
+        mgr.createWebsite(testWeblog2);
+        String id2 = testWeblog2.getId();
+        
+        // lookup by id
+        weblog = mgr.retrieveWebsite(id1);
+        assertNotNull(weblog);
+        assertEquals(testWeblog1.getHandle(), weblog.getHandle());
+        
+        // lookup by weblog handle
+        weblog = null;
+        weblog = mgr.getWebsiteByHandle(testWeblog1.getHandle());
+        assertNotNull(weblog);
+        assertEquals(testWeblog1.getHandle(), weblog.getHandle());
+        
+        // make sure disable weblogs are not returned
+        weblog.setEnabled(Boolean.FALSE);
+        mgr.storeWebsite(weblog);
+        weblog = null;
+        weblog = mgr.getWebsiteByHandle(testWeblog1.getHandle());
+        assertNull(weblog);
+        
+        // restore enabled state
+        weblog = mgr.getWebsiteByHandle(testWeblog1.getHandle(), Boolean.FALSE);
+        weblog.setEnabled(Boolean.TRUE);
+        mgr.storeWebsite(weblog);
+        weblog = null;
+        weblog = mgr.getWebsiteByHandle(testWeblog1.getHandle());
+        assertNotNull(weblog);
+        
+        // get all weblogs for user
+        weblog = null;
+        List weblogs1 = mgr.getWebsites(user, Boolean.TRUE, Boolean.TRUE);
+        assertEquals(2, weblogs1.size());
+        weblog = (WebsiteData) weblogs1.get(0);
+        assertNotNull(weblog);
+        
+        // make sure disabled weblogs are not returned
+        weblog.setEnabled(Boolean.FALSE);
+        mgr.storeWebsite(weblog);
+        List weblogs2 = mgr.getWebsites(user, Boolean.TRUE, Boolean.TRUE);
+        assertEquals(1, weblogs2.size());
+        weblog = (WebsiteData) weblogs2.get(0);
+        assertNotNull(weblog);
+        
+        // make sure inactive weblogs are not returned
+        weblog.setActive(Boolean.FALSE);
+        mgr.storeWebsite(weblog);
+        List weblogs3 = mgr.getWebsites(user, Boolean.TRUE, Boolean.TRUE);
+        assertEquals(0, weblogs3.size());
+        
+        // remove test weblogs
+        weblog = mgr.retrieveWebsite(id1);
+        mgr.removeWebsite(weblog);
+        weblog = mgr.retrieveWebsite(id2);
+        mgr.removeWebsite(weblog);
+        weblog = null;
+    }
+    
+}

Modified: incubator/roller/branches/roller-newbackend/tests/org/roller/presentation/velocity/ExportRssTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/tests/org/roller/presentation/velocity/ExportRssTest.java?rev=392622&r1=392621&r2=392622&view=diff
==============================================================================
--- incubator/roller/branches/roller-newbackend/tests/org/roller/presentation/velocity/ExportRssTest.java (original)
+++ incubator/roller/branches/roller-newbackend/tests/org/roller/presentation/velocity/ExportRssTest.java Sat Apr  8 15:42:58 2006
@@ -35,7 +35,6 @@
      */
     public void testExportRecent() throws Exception
     {      
-        getRoller().begin(UserData.SYSTEM_USER);
         ExportRss exporter = new ExportRss(mWebsite);
         
         //List entries = getRoller().getWeblogManager().getAllRecentWeblogEntries(new Date(), 5);
@@ -67,7 +66,6 @@
         }
         finally 
         {
-            getRoller().begin(UserData.SYSTEM_USER);
         }
     }
     
@@ -77,14 +75,7 @@
      */
     public void setUp() throws Exception
     {
-        super.setUp();
-
-        getRoller().begin(UserData.SYSTEM_USER);
-        //RollerConfigData  rollerConfig = rollerContext.getRollerConfig();
-        //oldUploadPath = rollerConfig.getUploadPath();
-        //rollerConfig.setUploadPath("build/junk");
-        //rollerConfig.save();
-        getRoller().commit();        
+        super.setUp();       
 
         MockServletContext mContext = getMockFactory().getMockServletContext();
         mContext.setRealPath("build/junk", "./build/junk");



Mime
View raw message