roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r189695 [45/67] - in /incubator/roller/trunk: ./ contrib/ contrib/lib/ contrib/plugins/ contrib/plugins/src/ contrib/plugins/src/org/ contrib/plugins/src/org/roller/ contrib/plugins/src/org/roller/presentation/ contrib/plugins/src/org/roller/presentation/velocity/ contrib/plugins/src/org/roller/presentation/velocity/plugins/ contrib/plugins/src/org/roller/presentation/velocity/plugins/acronyms/ contrib/plugins/src/org/roller/presentation/velocity/plugins/bookmarks/ contrib/plugins/src/org/roller/presentation/velocity/plugins/email/ contrib/plugins/src/org/roller/presentation/velocity/plugins/jspwiki/ contrib/plugins/src/org/roller/presentation/velocity/plugins/radeox/ contrib/plugins/src/org/roller/presentation/velocity/plugins/readmore/ contrib/plugins/src/org/roller/presentation/velocity/plugins/smileys/ contrib/plugins/src/org/roller/presentation/velocity/plugins/textile/ contrib/plugins/src/org/roller/presentation/velocity/plugins/topictag/ custom/ custom/src/ custom/web/ docs/ docs/images/ docs/installguide/ docs/installguide/old/ docs/userguide/ docs/userguide/images/ docs/userguide/old/ metadata/ metadata/database/ metadata/database/hibernate/ metadata/xdoclet/ nbproject/ personal/ personal/eclipse/ personal/testing/ sandbox/ sandbox/planetroller/ sandbox/planetroller/metadata/ sandbox/planetroller/metadata/database/ sandbox/planetroller/src/ sandbox/planetroller/src/org/ sandbox/planetroller/src/org/roller/ sandbox/planetroller/src/org/roller/tools/ sandbox/planetroller/src/org/roller/tools/planet/ sandbox/planetroller/templates/ sandbox/planetroller/test/ sandbox/planetroller/test/org/ sandbox/planetroller/test/org/roller/ sandbox/planetroller/test/org/roller/model/ sandbox/planetroller/test/org/roller/tools/ sandbox/planetroller/test/org/roller/tools/planet/ sandbox/planetroller/testdata/ sandbox/planetroller/testdata/cache/ sandbox/planetroller/testdata/output/ sandbox/standalone/ sandbox/standalone/jspwiki/ sandbox/standalone/jspwiki/default/ sandbox/standalone/jspwiki/default/images/ sandbox/standalone/lib/ sandbox/standalone/src/ sandbox/standalone/src/org/ sandbox/standalone/src/org/roller/ sandbox/standalone/src/org/roller/jspwiki/ sandbox/standalone/src/org/roller/tomcat/ sandbox/standalone/src/org/roller/util/ sandbox/standalone/tests/ sandbox/standalone/tests/org/ sandbox/standalone/tests/org/roller/ sandbox/standalone/tests/org/roller/util/ sandbox/standalone/tomcat/ src/ src/org/ src/org/roller/ src/org/roller/business/ src/org/roller/business/hibernate/ src/org/roller/business/search/ src/org/roller/business/search/operations/ src/org/roller/business/utils/ src/org/roller/config/ src/org/roller/config/runtime/ src/org/roller/model/ src/org/roller/pojos/ src/org/roller/presentation/ src/org/roller/presentation/atomapi/ src/org/roller/presentation/bookmarks/ src/org/roller/presentation/bookmarks/actions/ src/org/roller/presentation/bookmarks/formbeans/ src/org/roller/presentation/bookmarks/tags/ src/org/roller/presentation/filters/ src/org/roller/presentation/forms/ src/org/roller/presentation/newsfeeds/ src/org/roller/presentation/pagecache/ src/org/roller/presentation/pagecache/rollercache/ src/org/roller/presentation/pings/ src/org/roller/presentation/planet/ src/org/roller/presentation/tags/ src/org/roller/presentation/tags/calendar/ src/org/roller/presentation/tags/menu/ src/org/roller/presentation/util/ src/org/roller/presentation/velocity/ src/org/roller/presentation/weblog/ src/org/roller/presentation/weblog/actions/ src/org/roller/presentation/weblog/formbeans/ src/org/roller/presentation/weblog/tags/ src/org/roller/presentation/website/ src/org/roller/presentation/website/actions/ src/org/roller/presentation/website/formbeans/ src/org/roller/presentation/website/tags/ src/org/roller/presentation/xmlrpc/ src/org/roller/util/ src/org/roller/util/rome/ tests/ tests/org/ tests/org/roller/ tests/org/roller/ant/ tests/org/roller/business/ tests/org/roller/presentation/ tests/org/roller/presentation/atomapi/ tests/org/roller/presentation/bookmarks/ tests/org/roller/presentation/filters/ tests/org/roller/presentation/velocity/ tests/org/roller/presentation/velocity/plugins/ tests/org/roller/presentation/velocity/plugins/smileys/ tests/org/roller/presentation/velocity/plugins/textile/ tests/org/roller/presentation/weblog/ tests/org/roller/presentation/xmlrpc/ tests/org/roller/util/ tests/org/roller/util/rome/ tools/ tools/buildtime/ tools/buildtime/ant-1.6.2/ tools/buildtime/findbugs/ tools/buildtime/findbugs/lib/ tools/buildtime/findbugs/plugin/ tools/buildtime/mockrunner-0.3/ tools/buildtime/mockrunner-0.3/lib/ tools/buildtime/mockrunner-0.35/ tools/buildtime/mockrunner-0.35/lib/ tools/buildtime/tomcat-4.1.24/ tools/buildtime/xdoclet-1.2/ tools/buildtime/xdoclet-1.2/lib/ tools/hibernate-2.1/ tools/hibernate-2.1/lib/ tools/lib/ tools/standard-1.0.3/ tools/standard-1.0.3/lib/ tools/standard-1.0.3/tld/ tools/struts-1.2.4/ tools/struts-1.2.4/lib/ web/ web/WEB-INF/ web/WEB-INF/classes/ web/WEB-INF/classes/flavors/ web/WEB-INF/classes/themes/ web/bookmarks/ web/editor/ web/editor/images/ web/images/ web/images/editor/ web/images/midas/ web/images/preview/ web/images/smileys/ web/planet/ web/tags/ web/templates/ web/theme/ web/theme/images/ web/theme/lavender/ web/theme/scripts/ web/theme/scripts/classes/ web/themes/ web/themes/basic/ web/themes/berkley/ web/themes/berkley/images/ web/themes/brushedmetal/ web/themes/brushedmetal/images/ web/themes/cheb/ web/themes/cheb/images/ web/themes/cheb/scripts/ web/themes/clean/ web/themes/currency-i18n/ web/themes/currency-i18n/images/ web/themes/currency/ web/themes/currency/images/ web/themes/grey2/ web/themes/moonshine/ web/themes/movablemanila/ web/themes/movablemanila/images/ web/themes/pacifica/ web/themes/robot/ web/themes/rolling/ web/themes/rolling/images/ web/themes/sotto/ web/themes/sotto/images/ web/themes/sotto/styles/ web/themes/sunsets/ web/themes/sunsets/images/ web/themes/sunsets/scripts/ web/themes/sunsets/styles/ web/themes/werner/ web/themes/x2/ web/themes/x2/images/ web/themes/x2/scripts/ web/themes/x2/styles/ web/weblog/ web/website/
Date Thu, 09 Jun 2005 03:19:20 GMT
Added: incubator/roller/trunk/tests/org/roller/business/UserManagerTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/roller/business/UserManagerTest.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/roller/business/UserManagerTest.java (added)
+++ incubator/roller/trunk/tests/org/roller/business/UserManagerTest.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,427 @@
+
+package org.roller.business;
+
+import java.io.FileInputStream;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties; 
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.roller.RollerException;
+import org.roller.RollerPermissionsException;
+import org.roller.model.UserManager;
+import org.roller.model.WeblogManager;
+import org.roller.pojos.FolderData;
+import org.roller.pojos.PageData;
+import org.roller.pojos.UserData;
+import org.roller.pojos.WeblogCategoryData;
+import org.roller.pojos.WebsiteData;
+import org.roller.RollerTestBase;
+
+///////////////////////////////////////////////////////////////////////////////
+/**
+ * Test Roller User Management.
+ */
+public class UserManagerTest  extends RollerTestBase
+{
+    UserData enabledUser = null;
+    UserData disabledUser = null;
+    String enabledUserName = "enabledUser";
+    String disabledUserName = "disabledUser";
+
+    //------------------------------------------------------------------------
+    public UserManagerTest()
+    {
+        super();
+    }
+
+    //------------------------------------------------------------------------
+    public UserManagerTest(String name)
+    {
+        super(name);
+    }
+
+    //------------------------------------------------------------------------
+    public static Test suite()
+    {
+        return new TestSuite(UserManagerTest.class);
+    }
+
+    //------------------------------------------------------------------------
+    public static void main(String args[])
+    {
+        junit.textui.TestRunner.run(UserManagerTest.class);
+    }
+
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+
+        getRoller().begin(UserData.SYSTEM_USER);
+        UserManager umgr = getRoller().getUserManager();
+
+        enabledUser = createUser(umgr,
+                                 enabledUserName,
+                                 "password",
+                                 "EnabledUser",
+                                 "enabledUser@example.com"
+        );
+
+        disabledUser = createUser(umgr,
+                                 disabledUserName,
+                                 "password",
+                                 "DisabledUser",
+                                 "disabledUser@example.com"
+        );
+        umgr.getWebsite(disabledUserName,false).setIsEnabled(Boolean.FALSE);
+
+        getRoller().commit();
+    }
+
+    /**
+     * @see junit.framework.TestCase#tearDown()
+     */
+    public void tearDown() throws Exception
+    {
+        super.tearDown();
+
+        getRoller().begin(UserData.SYSTEM_USER);
+        UserManager umgr = getRoller().getUserManager();
+
+        enabledUser = umgr.retrieveUser(enabledUser.getId());
+        enabledUser.remove();
+
+        disabledUser = umgr.retrieveUser(disabledUser.getId());
+        disabledUser.remove();
+
+        getRoller().commit();
+    }
+
+    //------------------------------------------------------------------------
+    /** Tests storage and removal of user. */
+    public void testUserStorage() throws RollerException
+    {
+        UserManager umgr = getRoller().getUserManager();
+        UserData stored = null;
+
+        getRoller().begin(UserData.SYSTEM_USER);
+        stored = new UserData(
+            null,
+            "testUserStorage",
+            "password2",
+            "TestUser2",
+            "testuser2@example.com",
+            new java.util.Date());
+        umgr.storeUser(stored);
+        getRoller().commit();
+
+        getRoller().begin(UserData.SYSTEM_USER);
+        UserData retrieved = umgr.retrieveUser(stored.getId());
+        assertEquals(stored, retrieved);
+        getRoller().release();
+
+        getRoller().begin(UserData.SYSTEM_USER);
+        retrieved = umgr.retrieveUser(stored.getId());
+        retrieved.remove();
+        getRoller().commit();
+
+        getRoller().begin(UserData.SYSTEM_USER);
+        assertNull(umgr.retrieveUser(stored.getId()));
+        getRoller().release();
+    }
+
+    //------------------------------------------------------------------------
+    /** Tests storage and removal of website. */
+    public void testWebsiteStorage() throws RollerException
+    {
+        UserData user = null;
+        WebsiteData stored = null;
+        UserManager umgr = getRoller().getUserManager();
+
+        getRoller().begin(UserData.SYSTEM_USER);
+
+        user = new UserData(
+            null,
+            "testWebsiteStorage",
+            "password3",
+            "TestUser3",
+            "testuser3@example.com",
+            new java.util.Date());
+        umgr.storeUser( user );
+
+        stored = new WebsiteData(
+            null,
+            "testsite",
+            "Testsite",
+            user,
+            "dpid",
+            "wpid",
+            Boolean.FALSE,
+            null,
+            null,
+            "edit-weblog.jsp",
+            "ignore",
+            Boolean.TRUE,
+            Boolean.FALSE,
+            null,
+            Boolean.TRUE);
+        umgr.storeWebsite(stored);
+
+        FolderData rootFolder = getRoller().getBookmarkManager()
+            .createFolder(null, "root", "root", stored);
+        rootFolder.save();
+
+        WeblogCategoryData rootCategory = getRoller().getWeblogManager()
+            .createWeblogCategory(stored, null, "root", "root", "");
+        rootCategory.save();
+
+        stored.setBloggerCategory(rootCategory);
+        stored.setDefaultCategory(rootCategory);
+        stored.save();
+
+        getRoller().commit();
+
+        getRoller().begin(UserData.SYSTEM_USER);
+        WebsiteData retrieved = umgr.retrieveWebsite(stored.getId());
+        assertEquals(stored, retrieved);
+        getRoller().release();
+
+        getRoller().begin(UserData.SYSTEM_USER);
+        user = umgr.retrieveUser(user.getId());
+        user.remove();
+        getRoller().commit();
+
+        getRoller().begin(UserData.SYSTEM_USER);
+        assertNull(umgr.retrieveUser(user.getId()));
+        assertNull(umgr.retrieveWebsite(stored.getId()));
+        getRoller().rollback();
+    }
+
+    public void testAddRemoveUser() throws RollerException
+    {
+        UserManager umgr = getRoller().getUserManager();
+
+        // Add a user
+
+        getRoller().begin(UserData.SYSTEM_USER);
+        UserData user = new UserData(
+            null,
+            "testAddRemoveUser",
+            "password4",
+            "TestUser4",
+            "testuser4@example.com",
+            new java.util.Date());
+        Map pages = new HashMap();
+        pages.put("Weblog","Weblog page content");
+        pages.put("_day","Day page content");
+        pages.put("css","CSS page content");
+        umgr.addUser(user, pages, "basic", "en_US_WIN", "America/Los_Angeles");
+        getRoller().commit();
+
+        // Verify that user has all the goodies
+        getRoller().begin(UserData.SYSTEM_USER);
+        UserData user1 = umgr.retrieveUser(user.getId());
+        assertNotNull(user1);
+
+        WebsiteData website = umgr.getWebsite(user.getUserName());
+        assertNotNull(website);
+
+        FolderData root = getRoller().getBookmarkManager().getRootFolder(website);
+        assertNotNull(root);
+
+        List pages1 = getRoller().getUserManager().getPages(website);
+        assertEquals(3, pages1.size());
+        getRoller().rollback();
+
+        // Remove the user
+
+        getRoller().begin(UserData.SYSTEM_USER);
+        user = umgr.retrieveUser(user.getId());
+        user.remove();
+        getRoller().commit();
+
+        // Verify that user was completely deleted
+        getRoller().begin(UserData.SYSTEM_USER);
+        UserData user2 = umgr.retrieveUser(user.getId());
+        assertNull(user2);
+
+        WebsiteData website2 = umgr.getWebsite(user.getUserName());
+        assertNull(website2);
+
+        assertNull(getRoller().getBookmarkManager().retrieveFolder(root.getId()));
+
+        List pages2 = getRoller().getUserManager().getPages(website);
+        assertEquals(0, pages2.size());
+        getRoller().rollback();
+    }
+
+    public void testGetWebsite() throws RollerException
+    {
+        // can get testuser0 who is enabled
+        assertNotNull(getRoller().getUserManager().getWebsite(enabledUserName));
+
+        // can't get testuser1, who is disabled
+        assertNull(getRoller().getUserManager().getWebsite(disabledUserName));
+
+        // can get testuser1 with enabledOnly flag set to false
+        assertNotNull(getRoller().getUserManager().getWebsite(disabledUserName,false));
+    }
+
+    public void testGetUser() throws RollerException
+    {
+        // can get testuser0 who is enabled
+        getRoller().begin(UserData.SYSTEM_USER);
+        
+        UserData user = getRoller().getUserManager().getUser(enabledUserName);
+        assertNotNull(user);
+        
+        // can't get testuser1, who is disabled
+        assertNull(getRoller().getUserManager().getUser(disabledUserName));
+
+        // can get testuser1 with enabledOnly flag set to false
+        assertNotNull(getRoller().getUserManager().getUser(disabledUserName,false));
+        
+        getRoller().release();
+    }
+
+    public void testGetUsers() throws RollerException
+    {
+        // There are users
+        int userCountEnabled = getRoller().getUserManager().getUsers().size();
+        assertTrue(userCountEnabled > 0);
+
+        // At least one user is disabled
+        int userCountAll = getRoller().getUserManager().getUsers(false).size();
+        assertTrue(userCountAll > userCountEnabled);
+    }
+
+    public void testUserRoles() throws Exception {
+        
+        UserData user = null;
+        
+        // check existing roles within a session
+        getRoller().begin(UserData.SYSTEM_USER);        
+        user = getRoller().getUserManager().getUser(enabledUserName);
+        assertNotNull(user);
+        assertNotNull(user.getRoles());
+        assertEquals(1, user.getRoles().size()); 
+        getRoller().release();
+        
+        // test hasRole within a session
+        getRoller().begin(UserData.SYSTEM_USER);        
+        user = getRoller().getUserManager().getUser(enabledUserName);
+        assertTrue(user.hasRole("editor"));
+        getRoller().release();
+        
+        // and without a session
+        assertTrue(user.hasRole("editor"));
+
+        // test revokeRole within session
+        getRoller().begin(UserData.SYSTEM_USER);
+        user = getRoller().getUserManager().getUser(enabledUserName);
+        user.revokeRole("editor");
+        assertFalse(user.hasRole("editor"));
+        getRoller().commit();
+        
+        // role has been removed after commit?
+        assertFalse(user.hasRole("editor"));
+        
+        // restore role
+        getRoller().begin(UserData.SYSTEM_USER);
+        user = getRoller().getUserManager().getUser(enabledUserName);
+        user.grantRole("editor");
+        assertTrue(user.hasRole("editor"));
+        getRoller().commit();
+
+        assertTrue(user.hasRole("editor"));
+    }
+    
+    public void testGetPageByName() throws RollerException
+    {
+        WebsiteData wd0 = getRoller().getUserManager().getWebsite(enabledUserName);
+        assertNotNull(getRoller().getUserManager().getPageByName(wd0,"Weblog"));
+    }
+
+    public void testGetPageByLink() throws RollerException
+    {
+        WebsiteData wd0 = getRoller().getUserManager().getWebsite(enabledUserName);
+        assertNotNull(getRoller().getUserManager().getPageByLink(wd0,"Weblog"));
+    }
+
+    public void testGetPages() throws RollerException
+    {
+        // testuser0 is enabled and has 3 pages
+        WebsiteData wd0 = getRoller().getUserManager().getWebsite(enabledUserName);
+        assertEquals(3, getRoller().getUserManager().getPages(wd0).size());
+    }
+
+    public void hide_testUpdateIfNeeded() throws Exception
+    {
+        UserManager umgr = getRoller().getUserManager();
+        WeblogManager wmgr = getRoller().getWeblogManager();
+        PersistenceStrategy pstrategy = getRoller().getPersistenceStrategy();
+
+        // create cats without a root
+        getRoller().begin(UserData.SYSTEM_USER);
+
+        WebsiteData website = umgr.retrieveWebsite(mWebsite.getId());
+        WeblogCategoryData origRoot = wmgr.getRootWeblogCategory(mWebsite);
+        website.setBloggerCategory(null);
+        website.setDefaultCategory(null);
+
+        if (null != origRoot) origRoot.remove();
+
+        WeblogCategoryData cat1 = wmgr.createWeblogCategory(
+            website, null, "cat1 name", "cat1 desc", null);
+        pstrategy.store(cat1);
+
+        WeblogCategoryData cat2 = wmgr.createWeblogCategory(
+            website, null, "cat2 name", "cat2 desc", null);
+        pstrategy.store(cat2);
+
+        WeblogCategoryData cat3 = wmgr.createWeblogCategory(
+            website, null, "cat3 name", "cat3 desc", null);
+        pstrategy.store(cat3);
+
+        getRoller().commit();
+
+        // upgrade site
+
+        // We need a database connection and the hibernate.properties file
+        // is easier to parse than the Castor database.xml file.
+        Properties hibernateProperties = new Properties();
+        hibernateProperties.load(new FileInputStream("hibernate.properties"));
+        String driverClass = hibernateProperties.getProperty("hibernate.connection.driver_class");
+        String connectionUrl = hibernateProperties.getProperty("hibernate.connection.url");
+        Class.forName(driverClass);
+        Connection con = DriverManager.getConnection(connectionUrl);
+
+        getRoller().upgradeDatabase(con);
+
+        // verify that upgrade created a root and assigned it to cats
+        getRoller().begin(UserData.SYSTEM_USER);
+        WeblogCategoryData root = wmgr.getRootWeblogCategory(mWebsite);
+        assertNotNull(root);
+
+        cat1 = wmgr.retrieveWeblogCategory(cat1.getId());
+        assertEquals(root, cat1.getParent());
+
+        cat2 = wmgr.retrieveWeblogCategory(cat2.getId());
+        assertEquals(root, cat2.getParent());
+
+        cat3 = wmgr.retrieveWeblogCategory(cat3.getId());
+        assertEquals(root, cat3.getParent());
+
+        getRoller().release();
+    }
+
+
+}

Added: incubator/roller/trunk/tests/org/roller/business/WeblogManagerTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/roller/business/WeblogManagerTest.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/roller/business/WeblogManagerTest.java (added)
+++ incubator/roller/trunk/tests/org/roller/business/WeblogManagerTest.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,795 @@
+package org.roller.business; 
+
+import java.sql.Timestamp;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.Test; 
+import junit.framework.TestSuite;
+
+import org.roller.RollerException;
+import org.roller.RollerPermissionsException;
+import org.roller.model.UserManager;
+import org.roller.model.WeblogManager;
+import org.roller.pojos.CommentData;
+import org.roller.pojos.UserData;
+import org.roller.pojos.WeblogCategoryData;
+import org.roller.pojos.WeblogEntryData;
+import org.roller.pojos.WebsiteData;
+import org.roller.util.Utilities;
+import org.roller.RollerTestBase;
+
+/**
+ * Test Roller Weblog Management.
+ */
+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;
+        WeblogCategoryData root = null;
+        WeblogManager wmgr = getRoller().getWeblogManager();
+
+        wd = getRoller().getUserManager().retrieveWebsite(mWebsite.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, "title1", null, "text", "anchor", 
+            new Timestamp(0), new Timestamp(0), Boolean.FALSE);
+        e1.save();
+        
+        WeblogCategoryData c2 = wmgr.createWeblogCategory(); 
+        c2.setName("c2");
+        c2.setParent(c1);
+        c2.setWebsite(wd);
+        c2.save();
+      
+        WeblogEntryData e2 = new WeblogEntryData(
+            null, c2, wd, "title2", null, "text", "anchor", 
+            new Timestamp(0), new Timestamp(0), Boolean.FALSE);
+        e2.save();
+        
+        WeblogCategoryData c3 = wmgr.createWeblogCategory(); 
+        c3.setName("c3");
+        c3.setParent(c2);
+        c3.setWebsite(wd);
+        c3.save();
+        
+        WeblogEntryData e3 = new WeblogEntryData(
+            null, c3, wd, "title3", null, "text", "anchor", 
+            new Timestamp(0), new Timestamp(0), Boolean.FALSE);
+        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;
+        WeblogCategoryData root = null;
+        WeblogManager wmgr = getRoller().getWeblogManager();
+
+        wd = getRoller().getUserManager().retrieveWebsite(mWebsite.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, "title1", null, "text1", "anchor", 
+                new Timestamp(0), new Timestamp(0), Boolean.FALSE);
+        e1.save();
+        
+        WeblogEntryData e2 = new WeblogEntryData(
+                null, t1, wd, "title2", null, "text2", "anchor", 
+                new Timestamp(0), new Timestamp(0), Boolean.FALSE);
+        e2.save();
+        
+        WeblogEntryData e3 = new WeblogEntryData(
+                null, t1, wd, "title3", null, "text3", "anchor", 
+                new Timestamp(0), new Timestamp(0), Boolean.FALSE);
+        e3.save();
+        
+        WeblogEntryData e4 = new WeblogEntryData(
+                null, t1, wd, "title4", null, "text4", "anchor", 
+                new Timestamp(0), new Timestamp(0), Boolean.FALSE);
+        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
+                        WeblogManager.ALL,           // status
+                        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(8, 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
+    {
+        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.getPublishEntry().booleanValue()) // 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.getPublishEntry().booleanValue()) {
+                    break;
+                }
+            }
+        }
+        
+        WebsiteData website = entry1.getWebsite();
+        UserData user = website.getUser();        
+        Date updateTime = wmgr.getWeblogLastPublishTime(user.getUserName());
+                
+        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.getPublishEntry().booleanValue()) 
+            {
+                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(
+            null, 
+            entry1, 
+            "TestCommentUser", 
+            "test@test.com", 
+            "", 
+            "This is a test", 
+            new Timestamp(new Date().getTime()), 
+            Boolean.FALSE,   // spam
+            Boolean.FALSE);  // notify
+            
+        comment.save();
+        getRoller().commit();
+        
+        List comments = wmgr.getComments(entry1.getId());
+        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
+    {
+        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(entry0.getId()).size());
+        getRoller().commit();
+    }
+    
+    public void testQueryWeblogEntries() throws RollerException
+    {
+        getRoller().begin(UserData.SYSTEM_USER);
+        WeblogManager wmgr = getRoller().getWeblogManager();
+        UserManager umgr = getRoller().getUserManager();
+        
+        WebsiteData website = (WebsiteData)mWebsites.get(0);
+        website = umgr.retrieveWebsite(website.getId());
+
+        // PUBLISHISHED ONLY
+        List publishedEntries = wmgr.getWeblogEntries(
+                        website,                 // userName
+                        null,                    // startDate
+                        new Date(),              // endDate
+                        null,                    // catName
+                        WeblogManager.PUB_ONLY,  // status
+                        null);                   // maxEntries
+        assertEquals(mExpectedPublishedEntryCount, publishedEntries.size());
+                    
+        // DRAFT ONLY
+        List draftEntries = wmgr.getWeblogEntries(
+                        website,                 // userName
+                        null,                    // startDate
+                        new Date(),              // endDate
+                        null,                    // catName
+                        WeblogManager.DRAFT_ONLY,  // status
+                        null);                   // maxEntries
+        assertEquals(mExpectedEntryCount-mExpectedPublishedEntryCount, draftEntries.size());
+                          
+        // PUBLISHED and DRAFT
+        List allEntries = wmgr.getWeblogEntries(
+                        website,                 // userName
+                        null,                    // startDate
+                        new Date(),              // endDate
+                        null,                    // catName
+                        WeblogManager.ALL,       // status
+                        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);                   // 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)mWebsites.get(0);
+        website = umgr.retrieveWebsite(website.getId());
+        List comments = wmgr.getRecentComments(website, 2);
+        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)mWebsites.get(0);
+        
+        Date lastPub = wmgr.getWeblogLastPublishTime(
+                           website.getUser().getUserName());
+        //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)mWebsites.get(0); 
+        
+        WeblogCategoryData cat = wmgr.getRootWeblogCategory(website);       
+
+        WeblogEntryData entry = new WeblogEntryData(
+                null, cat, website, "title2", null, "text2", "attributetest", 
+                new Timestamp(0), new Timestamp(0), Boolean.FALSE);
+        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);
+        
+        // evil testuser
+        UserData testuser = getRoller().getUserManager().getUser("testuser");       
+        assertNotNull(testuser);
+        
+        // gets hold of testuser0's entry
+        WebsiteData website0 = getRoller().getUserManager().getWebsite("testuser0");
+        assertNotNull(website0);
+        List entries = getRoller().getWeblogManager().getWeblogEntries(
+                website0,
+                null,       // start
+                new Date(), // end
+                null,       // cat
+                WeblogManager.ALL,
+                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/trunk/tests/org/roller/business/package.html
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/roller/business/package.html?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/roller/business/package.html (added)
+++ incubator/roller/trunk/tests/org/roller/business/package.html Wed Jun  8 20:18:46 2005
@@ -0,0 +1,9 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+  <title></title>
+</head>
+<body>
+JUnit tests for Roller backend implementations.<br>
+</body>
+</html>

Added: incubator/roller/trunk/tests/org/roller/presentation/ApplicationResourcesTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/roller/presentation/ApplicationResourcesTest.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/roller/presentation/ApplicationResourcesTest.java (added)
+++ incubator/roller/trunk/tests/org/roller/presentation/ApplicationResourcesTest.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,162 @@
+/*
+ * Filename: ApplicationResourcesTest.java
+ * 
+ * Created on 24-May-04
+ */
+package org.roller.presentation;
+
+import java.io.FileInputStream;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Set;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * The purpose of this class is to verify that all messages in
+ * the base ApplicationResources.properties file also appear
+ * in the localized properties files.
+ * 
+ * If messages do not appear, the test fails and the 'evil-doers' are
+ * printed to System.out.  
+ * 
+ * Note: we need to make sure that new property files are added to this
+ * test.
+ * 
+ * @author <a href="mailto:molen@mail.com">Jaap van der Molen</a>
+ * @version $Revision: 1.7 $
+ */
+public class ApplicationResourcesTest extends TestCase
+{
+	private String userDir = null;
+	private Properties baseProps = null; 
+
+	/**
+	 * @param arg0
+	 */
+	public ApplicationResourcesTest(String name)
+	{
+		super(name);
+	}
+	
+	public static Test suite() {
+		TestSuite suite = new TestSuite();
+		//suite.addTest(new ApplicationResourcesTest("testSystemProperties"));
+		suite.addTest(
+			new ApplicationResourcesTest("testApplicationResources_nl"));
+		suite.addTest(
+			new ApplicationResourcesTest("testApplicationResources_zh_cn"));
+		suite.addTest(
+			new ApplicationResourcesTest("testApplicationResources_zh_tw"));
+		suite.addTest(
+			new ApplicationResourcesTest("testApplicationResources_vi"));
+		return suite;
+	}
+	
+	/**
+	 * @see junit.framework.TestCase#setUp()
+	 */
+	protected void setUp() throws Exception
+	{
+		super.setUp();
+		userDir = System.getProperty("user.dir");
+		
+		// load base ApplicationResources.properties file
+		baseProps = new Properties();
+		baseProps.load(new FileInputStream( 
+                userDir + "/WEB-INF/classes/ApplicationResources.properties"));
+	}
+
+	/**
+	 * Test Dutch stuff.
+	 * 
+	 * @throws Exception
+	 */
+	public void testApplicationResources_nl() throws Exception
+	{
+		verifyResourceBundle("ApplicationResources_nl");
+	}
+
+	/**
+	 * Test Simple Chinese stuff.
+	 * 
+	 * @throws Exception
+	 */
+	public void testApplicationResources_zh_cn() throws Exception
+	{
+		verifyResourceBundle("ApplicationResources_zh_cn");
+	}
+
+	/**
+	 * Test Traditional Chinese stuff.
+	 * 
+	 * @throws Exception
+	 */
+	public void testApplicationResources_zh_tw() throws Exception
+	{
+		verifyResourceBundle("ApplicationResources_zh_tw");
+	}
+
+	/**
+	 * Test Vietnamese stuff.
+	 * 
+	 * @throws Exception
+	 */
+	public void testApplicationResources_vi() throws Exception
+	{
+		verifyResourceBundle("ApplicationResources_vi");
+	}
+
+	public void testSystemProperties()
+	{
+		Properties sysProps = System.getProperties();
+		Set keys = sysProps.keySet();
+		for (Iterator iter = keys.iterator(); iter.hasNext();)
+		{
+			String key = (String) iter.next();
+			System.out.println(key + " = " + sysProps.getProperty(key));
+		}
+	}
+
+	/**
+	 * Helper method to do the actual testing.
+	 * 
+	 * @param bundle name of bundle to test
+	 * @throws Exception if file not found, or if io ecxeption occurs.
+	 */
+	private void verifyResourceBundle(String bundle) throws Exception
+	{
+		// verify user-dir; should end with roller
+		assertNotNull(userDir);
+		assertTrue(userDir.endsWith("roller"));
+		
+		// load Chinese resource file
+		Properties props = new Properties();
+		props.load(
+			new FileInputStream(
+				userDir
+					+ "/web/WEB-INF/classes/"
+					+ bundle
+					+ ".properties"));
+
+		Set keys = baseProps.keySet();
+		boolean missingMessage = false;
+
+		// check Chinese
+		System.out.println("Veriyfing " + bundle + "...");
+		for (Iterator iter = keys.iterator(); iter.hasNext();)
+		{
+			String key = (String) iter.next();
+			if (props.getProperty(key) == null)
+			{
+				System.err.println(key + " = " + baseProps.getProperty(key));
+				missingMessage = true;
+			}
+		}
+
+		assertFalse(missingMessage);
+	}
+
+}

Added: incubator/roller/trunk/tests/org/roller/presentation/ArchiveParserTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/roller/presentation/ArchiveParserTest.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/roller/presentation/ArchiveParserTest.java (added)
+++ incubator/roller/trunk/tests/org/roller/presentation/ArchiveParserTest.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,113 @@
+/*
+ * Created on May 4, 2004
+ */
+package org.roller.presentation;
+
+import java.io.File;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.roller.RollerException;
+import org.roller.RollerTestBase;
+import org.roller.business.FileManagerTest;
+import org.roller.pojos.RollerConfigData;
+import org.roller.presentation.velocity.ExportRssTest;
+
+import com.mockrunner.mock.web.MockServletContext;
+ 
+/**
+ * TODO: revisit this class once Atom 1.0 support comes to Rome
+ * @author lance.lavandowska
+ */
+public class ArchiveParserTest extends RollerTestBase
+{    
+    MockServletContext mContext = null;
+    RollerConfigData  rollerConfig = null;
+    
+    private static String FILE_LOCATION = "./build/junk/";
+    private static String RSS_ARCHIVE = "export-test.rss.xml";
+    private static String ATOM_ARCHIVE = "export-test.atom.xml";
+    
+    public void _testAtomParsing() throws RollerException 
+    {
+        File archiveFile = new File(FILE_LOCATION + 
+                                    mWebsite.getUser().getUserName() + 
+                                    "/" + ATOM_ARCHIVE);
+        parseFile(archiveFile);
+    }
+    
+    public void _testRssParsing() throws RollerException 
+    {
+        File archiveFile = new File(FILE_LOCATION + 
+                                    mWebsite.getUser().getUserName() + 
+                                    "/" + RSS_ARCHIVE);
+        parseFile(archiveFile);
+    }
+    
+    /**
+     * @param archiveFile
+     * @throws RollerException
+     */
+    private void parseFile(File archiveFile) throws RollerException
+    {
+        if (archiveFile.exists())
+        {    
+            //ArchiveParser parser = new ArchiveParser(getRoller(), mWebsite, archiveFile);
+            //getRoller().begin(UserData.SYSTEM_USER);
+            String result = null; // parser.parse();
+            getRoller().commit();
+            assertTrue(result.length() > 0);
+            System.out.println(result);
+        }
+        else
+        {
+            //try again, use export test to create necessary files
+            ExportRssTest exportTest = new ExportRssTest();
+            try
+            {
+                exportTest.setUp();
+                exportTest.testExportRecent();
+                exportTest.tearDown();
+                
+                parseFile(archiveFile);
+            }
+            catch (Exception e)
+            {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+            
+            // if it *still* isn't there, then fail
+            if (!archiveFile.exists())
+            {
+                fail(archiveFile.getAbsolutePath() + " does not exist.");
+            }
+        }
+    }
+
+    /*
+     * Need to change the UploadPath location for testing. 
+     * @see junit.framework.TestCase#setUp()
+     */
+    public void setUp() throws Exception
+    {
+        super.setUp();
+
+        //rollerConfig = rollerContext.getRollerConfig();
+    }
+
+    /*
+     * Need to reset the UploadPath after testing. 
+     * @see junit.framework.TestCase#tearDown()
+     */
+    public void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+
+    public static Test suite()
+    {
+        return new TestSuite(ArchiveParserTest.class);
+    }
+}

Added: incubator/roller/trunk/tests/org/roller/presentation/LanguageUtilTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/roller/presentation/LanguageUtilTest.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/roller/presentation/LanguageUtilTest.java (added)
+++ incubator/roller/trunk/tests/org/roller/presentation/LanguageUtilTest.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,91 @@
+/*
+ * Filename: LanguageUtilTest.java
+ * 
+ * Created on 13-Jul-04
+ */
+package org.roller.presentation;
+
+import java.util.Locale;
+import java.util.Vector;
+
+import javax.servlet.ServletContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.BasicConfigurator;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import com.mockrunner.mock.web.MockServletContext;
+
+/**
+ * The purpose of this class is to 
+ * 
+ * @author <a href="mailto:molen@mail.com">Jaap van der Molen</a>
+ * @version $Revision: 1.1 $
+ */
+public class LanguageUtilTest extends TestCase
+{
+	private static Log logger = LogFactory.getLog(LanguageUtilTest.class);
+
+	private static String supportedLanguages = "en,nl,vi,zh_cn,zh_tw";
+
+	private ServletContext servletContext = null;
+
+	/**
+	 * @param arg0
+	 */
+	public LanguageUtilTest(String name)
+	{
+		super(name);
+		BasicConfigurator.configure();
+	}
+
+	/**
+	 * @see junit.framework.TestCase#setUp()
+	 */
+	protected void setUp() throws Exception
+	{
+		super.setUp();
+		servletContext = new MockServletContext();
+		servletContext.setAttribute(
+			LanguageUtil.SUPPORTED_LANGUAGES,
+			LanguageUtil.extractLanguages(supportedLanguages));
+	}
+
+	public static Test suite()
+	{
+		TestSuite suite = new TestSuite();
+		suite.addTest(new LanguageUtilTest("testSupportedLanguages"));
+		suite.addTest(new LanguageUtilTest("testIsSupported"));
+		return suite;
+	}
+	
+	public void testSupportedLanguages() {
+		Locale[] l = LanguageUtil.getSupportedLanguages(servletContext);
+
+		assertNotNull(l);
+
+		for (int i=0; i<l.length; i++) {
+			logger.debug("locale: "+l[i]);
+		}
+
+		assertEquals(l.length, 5);
+		assertEquals(l[0], new Locale("en"));
+		assertEquals(l[1], new Locale("nl"));
+		assertEquals(l[2], new Locale("vi"));
+		assertEquals(l[3], new Locale("zh", "cn"));
+		assertEquals(l[4], new Locale("zh", "tw"));
+		
+	}
+	
+	public void testIsSupported() {
+		assertTrue(LanguageUtil.isSupported( new Locale("en", "GB"), servletContext));
+		assertFalse(LanguageUtil.isSupported( new Locale("de"), servletContext));
+		assertTrue(LanguageUtil.isSupported( "en_GB", servletContext));
+		assertFalse(LanguageUtil.isSupported( "de", servletContext));
+	}
+
+}

Added: incubator/roller/trunk/tests/org/roller/presentation/MockPrincipal.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/roller/presentation/MockPrincipal.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/roller/presentation/MockPrincipal.java (added)
+++ incubator/roller/trunk/tests/org/roller/presentation/MockPrincipal.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,17 @@
+/*
+ * Created on Mar 8, 2004
+ */
+package org.roller.presentation;
+
+public class MockPrincipal implements java.security.Principal
+{
+    String mName;
+    public MockPrincipal(String name)
+    {
+        mName = name;
+    }
+    public String getName()
+    {
+        return mName;
+    }
+}
\ No newline at end of file

Added: incubator/roller/trunk/tests/org/roller/presentation/MockRollerContext.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/roller/presentation/MockRollerContext.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/roller/presentation/MockRollerContext.java (added)
+++ incubator/roller/trunk/tests/org/roller/presentation/MockRollerContext.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1 @@
+/*
 * Created on Mar 4, 2004
 */
package org.roller.presentation;
import java.io.File;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.roller.RollerException;

/**
 * @author lance.lavandowska
 */
public class MockRollerContext extends RollerContext
{
    private static Log mLogger =
        LogFactory.getFactory().getInstance(MockRollerContext.class);
    private static ServletContext mContext = null;
    public void init(ServletContext sc)
    {
        mLogger.debug("MockRollerContext initializing");
        
        // initialize super 
        super.contextInitialized(new ServletContextEvent(sc));
        
        // Save context in self and self in context
        mContext = sc;
        mContext.setAttribute(ROLLER_CONTEXT, this);
        mContext.setAttribute("org.roller.absoluteContextURL", "/");
    }
    //-----------------------------------------------------------------------
    /** Because I cannot set the super's values, I have to
     * overide the methods as well */  
    public static RollerContext getRollerContext(ServletContext sc)
    {
        // get roller from servlet context
        return (RollerContext) mContext.getAttribute(ROLLER_CONTEXT);
    }
    //-----------------------------------------------------------------------
    /** Because I cannot set the super's values, I have to
     * overide the methods as well */  
    public static ServletContext getServletContext()
    {
        return mContext;
    }

    //-----------------------------------------------------------------------
    /** Because I cannot set the super's values, I have to
     * overide the methods as well */
    public String getRollerVersion()
    {
        return super.getRollerVersion();
    }
    //-----------------------------------------------------------------------
    /** Because I cannot set the super's values, I have to
     * overide the methods as well */
    public String getRollerBuildTime()
    {
        return super.getRollerBuildTime();
    }
    //-----------------------------------------------------------------------
    /** Because I cannot set the super's values, I have to
     * overide the methods as well */
    public String getRollerBuildUser()
    {
        return super.getRollerBuildUser();
    }

    //-----------------------------------------------------------------------
    /** Because I cannot set the super's values, I have to
     * overide the methods as well */
    public String getAbsoluteContextUrl()
    {
        return "";
    }
    //-----------------------------------------------------------------------
    /** Because I cannot set the super's values, I have to
     * overide the methods as well */
    public String getAbsoluteContextUrl(HttpServletRequest request)
    {
        return request.getScheme() +"://" + request.getServerName() + "";
    }
    //-----------------------------------------------------------------------
    /** Because I cannot set the super's values, I have to
     * overide the methods as well */
    /* not available anymore ... use the new config classes instead -- Allen G
    public RollerConfigData getRollerConfig()
    {
        return super.getRollerConfig();
    }
    */
    //------------------------------------------------------------------------
    public String getConfigPath() 
    {
        String root = System.getProperty("ro.build");
        String configPath =
            root
                + File.separator
                + "roller"
                + File.separator
                + "WEB-INF"
                + File.separator
                + "roller-config.xml";
        return configPath;
    }
    protected void upgradeDatabaseIfNeeded() throws RollerException
    {
        // for now, this is a no-op
    }

}
\ No newline at end of file

Added: incubator/roller/trunk/tests/org/roller/presentation/MockRollerRequest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/roller/presentation/MockRollerRequest.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/roller/presentation/MockRollerRequest.java (added)
+++ incubator/roller/trunk/tests/org/roller/presentation/MockRollerRequest.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,26 @@
+/*
+ * Created on Jun 8, 2004
+ */
+package org.roller.presentation;
+
+import org.roller.RollerException;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @author lance.lavandowska
+ */
+public class MockRollerRequest extends RollerRequest
+{
+    /**
+     * @param req
+     * @param ctx
+     * @throws RollerException
+     */
+    public MockRollerRequest(HttpServletRequest req, ServletContext ctx) throws RollerException
+    {
+        super(req, ctx);
+    }
+
+}

Added: incubator/roller/trunk/tests/org/roller/presentation/SearchServletTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/roller/presentation/SearchServletTest.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/roller/presentation/SearchServletTest.java (added)
+++ incubator/roller/trunk/tests/org/roller/presentation/SearchServletTest.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,50 @@
+package org.roller.presentation;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.roller.presentation.filters.PersistenceSessionFilter;
+import org.roller.presentation.filters.RequestFilter;
+import org.roller.presentation.velocity.SearchServlet;
+
+import com.mockrunner.mock.web.MockHttpServletRequest;
+import com.mockrunner.mock.web.MockServletConfig;
+
+
+/**
+ * @author Dave Johnson
+ */
+public class SearchServletTest extends VelocityServletTestBase
+{    
+    public void testSearch() throws Exception
+    {
+        servletModule.setServlet(
+            servletModule.createServlet(SearchServlet.class)); 
+        MockHttpServletRequest mockRequest = getMockFactory().getMockRequest();
+
+        mockRequest.setContextPath("/search");
+        mockRequest.setQueryString("q=test");
+ 
+        servletModule.createFilter(PersistenceSessionFilter.class);
+        servletModule.createFilter(RequestFilter.class);
+        servletModule.setDoChain(true);
+        
+        servletModule.doFilter();        
+        getMockFactory().addRequestWrapper(new HttpServletRequestWrapper(
+            (HttpServletRequest)servletModule.getFilteredRequest()));
+        servletModule.doGet();
+        assertNotNull(
+            servletModule.getRequestAttribute("zzz_VelocityContext_zzz"));     
+    }
+    public static Test suite() 
+    {
+        return new TestSuite(SearchServletTest.class);
+    }
+    public static void main(String[] args)
+    {
+        junit.textui.TestRunner.run(SearchServletTest.class);
+    }
+}

Added: incubator/roller/trunk/tests/org/roller/presentation/StrutsActionTestBase.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/roller/presentation/StrutsActionTestBase.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/roller/presentation/StrutsActionTestBase.java (added)
+++ incubator/roller/trunk/tests/org/roller/presentation/StrutsActionTestBase.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,74 @@
+package org.roller.presentation;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+
+import org.roller.RollerTestBase;
+import org.roller.presentation.filters.PersistenceSessionFilter;
+import org.roller.presentation.filters.RequestFilter;
+
+import com.mockrunner.mock.web.ActionMockObjectFactory;
+import com.mockrunner.mock.web.MockHttpServletRequest;
+import com.mockrunner.mock.web.MockServletContext;
+import com.mockrunner.mock.web.WebMockObjectFactory;
+import com.mockrunner.servlet.ServletTestModule;
+import com.mockrunner.struts.ActionTestModule;
+import com.mockrunner.struts.MapMessageResources;
+
+/** 
+ * Base for Struts Action testing. 
+ * @author Dave Johnson
+ */
+public class StrutsActionTestBase extends RollerTestBase
+{     
+    private ActionMockObjectFactory mockFactory;
+    protected MockRollerContext rollerContext;
+    protected ActionTestModule strutsModule;
+    protected ServletTestModule servletModule;
+
+    public void setUp() throws Exception
+    {
+        super.setUp();       
+        getMockFactory().refresh();
+        strutsModule = new ActionTestModule(getStrutsMockFactory()); 
+        servletModule = new ServletTestModule(getStrutsMockFactory());
+        
+        MapMessageResources resources = new MapMessageResources();
+        resources.putMessages("WEB-INF/classes/ApplicationResources.properties");
+        strutsModule.setResources(resources);
+        
+        MockServletContext ctx = getMockFactory().getMockServletContext();
+        ctx.setRealPath("/", "");
+        rollerContext = new MockRollerContext();
+        rollerContext.init(ctx);
+    }
+    protected void authenticateUser(String username, String role)
+    {
+        MockHttpServletRequest mockRequest = getMockFactory().getMockRequest();
+        mockRequest.setRemoteUser(username);
+        mockRequest.setUserPrincipal(new MockPrincipal(username));
+        mockRequest.setUserInRole(role, true);
+    }
+    
+    protected void doFilters()
+    {
+        servletModule.createFilter(PersistenceSessionFilter.class);
+        servletModule.createFilter(RequestFilter.class);
+        servletModule.setDoChain(true);
+        servletModule.doFilter();        
+        getMockFactory().addRequestWrapper(new HttpServletRequestWrapper(
+            (HttpServletRequest)servletModule.getFilteredRequest()));
+    }
+    protected ActionMockObjectFactory getStrutsMockFactory()
+    {
+        return (ActionMockObjectFactory)getMockFactory();
+    }
+    protected WebMockObjectFactory getMockFactory()
+    {
+        if (mockFactory == null) 
+        {
+            mockFactory = new ActionMockObjectFactory();
+        }
+        return mockFactory;
+    }
+}

Added: incubator/roller/trunk/tests/org/roller/presentation/TestAll.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/roller/presentation/TestAll.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/roller/presentation/TestAll.java (added)
+++ incubator/roller/trunk/tests/org/roller/presentation/TestAll.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,61 @@
+package org.roller.presentation;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.roller.BlacklistTest;
+import org.roller.DateTest;
+import org.roller.presentation.bookmarks.BookmarksActionTest;
+import org.roller.presentation.filters.RequestFilterTest;
+import org.roller.presentation.velocity.plugins.smileys.SmileysTest;
+import org.roller.presentation.velocity.plugins.textile.TextileTest;
+import org.roller.presentation.weblog.WeblogEntryActionTest;
+import org.roller.presentation.xmlrpc.RollerXmlRpcServerTest;
+import org.roller.util.LRUCache2Test;
+import org.roller.util.LinkbackExtractorTest;
+import org.roller.util.RegexUtilTest;
+import org.roller.util.UtilitiesTest;
+import org.roller.util.rome.DiskFeedInfoCacheTest;
+
+/**
+ * Run the essential presentation layer tests (convenience test for IDEs)
+ * @author Dave M Johnson
+ */
+public class TestAll extends TestCase
+{
+    public static Test suite()
+    {
+        TestSuite suite = new TestSuite();
+        suite.addTest(BlacklistTest.suite());
+        suite.addTest(DateTest.suite());
+        suite.addTest(BookmarksActionTest.suite());
+        suite.addTest(RequestFilterTest.suite());
+        suite.addTest(SearchServletTest.suite());
+        suite.addTest(SmileysTest.suite());
+        suite.addTest(TextileTest.suite());
+        suite.addTest(WeblogEntryActionTest.suite());
+        suite.addTest(RollerXmlRpcServerTest.suite());
+        suite.addTest(LinkbackExtractorTest.suite());
+        suite.addTest(LRUCache2Test.suite());
+        suite.addTest(RegexUtilTest.suite());
+        suite.addTest(DiskFeedInfoCacheTest.suite());
+        suite.addTest(UtilitiesTest.suite());   
+        // TODO: suite.addTest(ApplicationResourcesTest.suite());
+        // TODO: suite.addTest(ArchiveParserTest.suite());
+        // TODO: suite.addTest(AtomCollectionTest.suite());
+        // TODO: suite.addTest(AtomServletTest.suite());
+        // TODO: suite.addTest(ExportRssTest.suite());
+        //suite.addTest(LanguageUtilTest.suite());
+        return suite;
+    }
+    public TestAll(String testName)
+    {
+        super(testName);
+    }
+    public static void main(String[] args)
+    {
+        //String[] testCaseName = { TestAll.class.getName() };
+        junit.textui.TestRunner.run(TestAll.suite());
+    }
+}
\ No newline at end of file

Added: incubator/roller/trunk/tests/org/roller/presentation/VelocityServletTestBase.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/roller/presentation/VelocityServletTestBase.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/roller/presentation/VelocityServletTestBase.java (added)
+++ incubator/roller/trunk/tests/org/roller/presentation/VelocityServletTestBase.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,112 @@
+package org.roller.presentation;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.jsp.JspEngineInfo;
+import javax.servlet.jsp.JspFactory;
+import javax.servlet.jsp.PageContext;
+
+import org.roller.RollerTestBase;
+import org.roller.presentation.filters.PersistenceSessionFilter;
+import org.roller.presentation.filters.RequestFilter;
+
+import com.mockrunner.mock.web.ActionMockObjectFactory;
+import com.mockrunner.mock.web.MockHttpServletRequest;
+import com.mockrunner.mock.web.MockServletConfig;
+import com.mockrunner.mock.web.MockServletContext;
+import com.mockrunner.mock.web.WebMockObjectFactory;
+import com.mockrunner.servlet.ServletTestModule;
+import com.mockrunner.struts.ActionTestModule;
+import com.mockrunner.struts.MapMessageResources;
+
+
+/** 
+ * Base for VelocityServlet testing. 
+ * @author Dave Johnson
+ */
+public abstract class VelocityServletTestBase extends RollerTestBase
+{ 
+    protected ServletTestModule servletModule;
+    private WebMockObjectFactory mockFactory;
+    protected MockRollerContext rollerContext;
+    protected ActionTestModule strutsModule; // need Struts for message resources
+    
+    public void setUp() throws Exception
+    {
+        super.setUp();     
+        getMockFactory().refresh();
+        servletModule = new ServletTestModule(getMockFactory());
+        strutsModule = new ActionTestModule(getStrutsMockFactory()); 
+        
+        MockServletContext app = getMockFactory().getMockServletContext();
+        app.addResourcePath("/WEB-INF/toolbox.xml","/WEB-INF/toolbox.xml");
+        app.setResourceAsStream("/WEB-INF/toolbox.xml",
+                new FileInputStream("./WEB-INF/toolbox.xml"));
+        
+        MockServletConfig config = getMockFactory().getMockServletConfig();
+        config.setInitParameter(
+                "org.apache.velocity.properties","WEB-INF/velocity.properties");       
+
+        MapMessageResources resources = new MapMessageResources();
+        resources.putMessages("WEB-INF/classes/ApplicationResources.properties");
+        strutsModule.setResources(resources);
+        
+        MockServletContext ctx = getMockFactory().getMockServletContext();
+        ctx.setRealPath("/", "");
+        rollerContext = new MockRollerContext();
+        rollerContext.init(ctx);
+        
+        JspFactory.setDefaultFactory(new MockJspFactory(getMockFactory())); 
+    }
+    protected void authenticateUser(String username, String role)
+    {
+        MockHttpServletRequest mockRequest = getMockFactory().getMockRequest();
+        mockRequest.setRemoteUser(username);
+        mockRequest.setUserPrincipal(new MockPrincipal(username));
+        mockRequest.setUserInRole(role, true);
+    }
+    protected void doFilters()
+    {
+        servletModule.createFilter(PersistenceSessionFilter.class);
+        servletModule.createFilter(RequestFilter.class);
+        servletModule.setDoChain(false);
+        servletModule.doFilter();        
+        getMockFactory().addRequestWrapper(new HttpServletRequestWrapper(
+            (HttpServletRequest)servletModule.getFilteredRequest()));
+    }
+    /** MockRunner doesn't have one of these */
+    public class MockJspFactory extends JspFactory
+    {
+        public WebMockObjectFactory factory;
+        public MockJspFactory(WebMockObjectFactory factory)
+        {
+            this.factory = factory;
+        }
+        public PageContext getPageContext(
+            Servlet arg0, ServletRequest arg1, ServletResponse arg2, 
+            String arg3, boolean arg4, int arg5, boolean arg6)
+        {
+            return factory.getMockPageContext();
+        }
+        public void releasePageContext(PageContext arg0) {}
+        public JspEngineInfo getEngineInfo() {return null;}
+    }
+    protected ActionMockObjectFactory getStrutsMockFactory()
+    {
+        return (ActionMockObjectFactory)getMockFactory();
+    }
+    protected WebMockObjectFactory getMockFactory()
+    {
+        if (mockFactory == null) 
+        {
+            mockFactory = new ActionMockObjectFactory();
+        }
+        return mockFactory;
+    }
+}

Added: incubator/roller/trunk/tests/org/roller/presentation/atomapi/AtomCollectionTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/roller/presentation/atomapi/AtomCollectionTest.java?rev=189695&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/roller/presentation/atomapi/AtomCollectionTest.java (added)
+++ incubator/roller/trunk/tests/org/roller/presentation/atomapi/AtomCollectionTest.java Wed Jun  8 20:18:46 2005
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2005 David M Johnson (For RSS and Atom In Action)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.roller.presentation.atomapi;
+
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.jdom.Document;
+
+/**
+ * @author Dave Johnson
+ */
+public class AtomCollectionTest extends TestCase {
+    
+    private static SimpleDateFormat df =
+        new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ssZ" );
+   
+    /** Creates a new instance of AtomCollectionTest */
+    public AtomCollectionTest() {
+    }
+
+    public void testRangeParsing() throws Exception {
+        Date end = new Date(); // now 
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(end);
+        cal.add(Calendar.DATE, -1);
+        Date start = cal.getTime(); // one day ago
+        String startString = df.format(start);
+        String endString = df.format(end);
+        
+        String r1 = "Range: updated="+startString+"/"+endString;
+        AtomCollection.Range range = AtomCollection.parseRange(r1);
+        assertNotNull(range.start);
+        assertNotNull(range.end);
+        
+        String r2 = "Range: updated="+startString+"/";
+        range = AtomCollection.parseRange(r2);
+        assertNotNull(range.start);
+        assertNull(range.end);
+        
+        String r3 = "Range: updated="+"/"+endString;
+        range = AtomCollection.parseRange(r3);
+        assertNull(range.start);
+        assertNotNull(range.end);
+    }
+    
+    public void testCollectionBean() throws Exception {
+        
+        // create a collection with a member
+        Date date1 = new Date();
+        AtomCollection collection = new AtomCollection();
+        AtomCollection.Member member1 = new AtomCollection.Member();
+        member1.setTitle("title1");
+        member1.setHref("http://example.com/item1");
+        member1.setUpdated(date1);
+        collection.addMember(member1);
+        
+        // add another member
+        Date date2 = new Date();
+        AtomCollection.Member member2 = new AtomCollection.Member();
+        member2.setTitle("title2");
+        member2.setHref("http://example.com/item2");
+        member2.setUpdated(date2);
+        collection.addMember(member2);
+        
+        // serialize to XML
+        Document doc = AtomCollection.collectionToDocument(collection);
+        assertEquals("collection", doc.getRootElement().getName());
+        assertEquals(2, doc.getRootElement().getContent().size());
+        
+        // deserialize from XML and assert we've got the same stuff
+        AtomCollection col2 = AtomCollection.documentToCollection(doc);
+        assertEquals(2, col2.getMembers().size());
+        
+        AtomCollection.Member m1 = (AtomCollection.Member)col2.getMembers().get(0);
+        assertEquals("title1", m1.getTitle());
+        assertEquals("http://example.com/item1", m1.getHref());
+        assertCloseEnough(date1, m1.getUpdated());
+        
+        AtomCollection.Member m2 = (AtomCollection.Member)col2.getMembers().get(1);
+        assertEquals("title2", m2.getTitle());
+        assertEquals("http://example.com/item2", m2.getHref());
+        assertCloseEnough(date2, m2.getUpdated());
+    }
+    
+    public void testServiceBean() {
+        
+        AtomService.Collection collection = new AtomService.Collection();
+        collection.setTitle("All blog entries");
+        collection.setContents("entries");
+        collection.setHref("http://example.com/collection1");
+        
+        AtomService.Workspace workspace = new AtomService.Workspace();
+        workspace.setTitle("My blog");
+        workspace.addCollection(collection);
+        
+        AtomService service = new AtomService();
+        service.addWorkspace(workspace);
+
+        // serialize to XML
+        Document doc = AtomService.serviceToDocument(service);
+        assertEquals("service", doc.getRootElement().getName());
+        assertEquals(1, doc.getRootElement().getContent().size());
+  
+        // deserialize from XML and assert we've got the same stuff
+        AtomService service2 = AtomService.documentToService(doc);
+        
+        AtomService.Workspace workspace2 = 
+            (AtomService.Workspace)service2.getWorkspaces().get(0);
+        assertEquals("My blog", workspace2.getTitle());
+        
+        AtomService.Collection collection2 = 
+            (AtomService.Collection)workspace2.getCollections().get(0);
+        assertEquals("All blog entries", collection2.getTitle());
+        assertEquals("entries", collection.getContents());
+        assertEquals("http://example.com/collection1", collection2.getHref());
+    }
+
+    /** Compare times ignoring milliseconds */
+    public void assertCloseEnough(Date d1, Date d2) {
+        long t1 = d1.getTime() - d1.getTime() % 1000;
+        long t2 = d2.getTime() - d2.getTime() % 1000;
+        assertEquals(t1, t2);
+    }
+    
+    public static Test suite() {
+		TestSuite suite = new TestSuite();
+		suite.addTest(new TestSuite(AtomCollectionTest.class));
+		return suite;
+	}
+}



Mime
View raw message