You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by sn...@apache.org on 2006/05/02 00:28:51 UTC

svn commit: r398714 [5/5] - in /incubator/roller/trunk: sandbox/atomadminprotocol/src/org/apache/ sandbox/atomadminprotocol/src/org/apache/roller/ sandbox/atomadminprotocol/src/org/apache/roller/presentation/ sandbox/atomadminprotocol/src/org/apache/ro...

Added: incubator/roller/trunk/tests/org/apache/roller/business/WeblogTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/business/WeblogTest.java?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/business/WeblogTest.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/business/WeblogTest.java Mon May  1 15:28:43 2006
@@ -0,0 +1,201 @@
+package org.apache.roller.business;
+
+import java.util.ArrayList;
+import java.util.Collection;
+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.apache.roller.TestUtils;
+import org.apache.roller.model.RollerFactory;
+import org.apache.roller.model.UserManager;
+import org.apache.roller.pojos.UserData;
+import org.apache.roller.pojos.WebsiteData;
+
+
+/**
+ * Test Weblog related business operations.
+ */
+public class WeblogTest extends TestCase {
+    
+    public static Log log = LogFactory.getLog(WeblogTest.class);
+    
+    UserData testUser = null;
+    
+    
+    public WeblogTest(String name) {
+        super(name);
+    }
+    
+    
+    public static Test suite() {
+        return new TestSuite(WeblogTest.class);
+    }
+    
+    
+    /**
+     * All tests in this suite require a user.
+     */
+    public void setUp() throws Exception {
+        
+        try {
+            testUser = TestUtils.setupUser("weblogTestUser");
+            TestUtils.endSession(true);
+        } catch (Exception ex) {
+            log.error(ex);
+            throw new Exception("Test setup failed", ex);
+        }
+    }
+    
+    public void tearDown() throws Exception {
+        
+        try {
+            TestUtils.teardownUser(testUser.getId());
+            TestUtils.endSession(true);
+        } catch (Exception ex) {
+            log.error(ex);
+            throw new Exception("Test teardown failed", ex);
+        }
+    }
+    
+    
+    /**
+     * Test basic persistence operations ... Create, Update, Delete.
+     */
+    public void testWeblogCRUD() throws Exception {
+        
+        UserManager mgr = RollerFactory.getRoller().getUserManager();
+        WebsiteData weblog = null;
+        
+        WebsiteData testWeblog = new WebsiteData();
+        testWeblog.setName("Test Weblog");
+        testWeblog.setDescription("Test Weblog");
+        testWeblog.setHandle("testweblog");
+        testWeblog.setEmailAddress("testweblog@dev.null");
+        testWeblog.setEditorPage("editor-text.jsp");
+        testWeblog.setBlacklist("");
+        testWeblog.setEmailFromAddress("");
+        testWeblog.setEditorTheme("basic");
+        testWeblog.setLocale("en_US");
+        testWeblog.setTimeZone("America/Los_Angeles");
+        testWeblog.setDateCreated(new java.util.Date());
+        testWeblog.setCreator(testUser);
+        
+        // make sure test weblog does not exist
+        weblog = mgr.getWebsiteByHandle(testWeblog.getHandle());
+        assertNull(weblog);
+        
+        // add test weblog
+        mgr.addWebsite(testWeblog);
+        String id = testWeblog.getId();
+        TestUtils.endSession(true);
+        
+        // make sure test weblog exists
+        weblog = null;
+        weblog = mgr.getWebsite(id);
+        assertNotNull(weblog);
+        assertEquals(testWeblog, weblog);
+        
+        // modify weblog and save
+        weblog.setName("testtesttest");
+        mgr.saveWebsite(weblog);
+        TestUtils.endSession(true);
+        
+        // make sure changes were saved
+        weblog = null;
+        weblog = mgr.getWebsite(id);
+        assertNotNull(weblog);
+        assertEquals("testtesttest", weblog.getName());
+        
+        // remove test weblog
+        mgr.removeWebsite(weblog);
+        TestUtils.endSession(true);
+        
+        // make sure weblog no longer exists
+        weblog = null;
+        weblog = mgr.getWebsite(id);
+        assertNull(weblog);
+    }
+    
+    
+    /**
+     * Test lookup mechanisms.
+     */
+    public void testWeblogLookups() throws Exception {
+        
+        UserManager mgr = RollerFactory.getRoller().getUserManager();
+        WebsiteData weblog = null;
+        
+        // add test weblogs
+        WebsiteData testWeblog1 = TestUtils.setupWeblog("testWeblog1", testUser);
+        WebsiteData testWeblog2 = TestUtils.setupWeblog("testWeblog2", testUser);
+        TestUtils.endSession(true);
+        
+        // lookup by id
+        weblog = mgr.getWebsite(testWeblog1.getId());
+        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.saveWebsite(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.saveWebsite(weblog);
+        TestUtils.endSession(true);
+        weblog = null;
+        weblog = mgr.getWebsiteByHandle(testWeblog1.getHandle());
+        assertNotNull(weblog);
+        
+        // get all weblogs for user
+        weblog = null;
+        List weblogs1 = mgr.getWebsites(testUser, 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.saveWebsite(weblog);
+        TestUtils.endSession(true);
+        List weblogs2 = mgr.getWebsites(testUser, 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.saveWebsite(weblog);
+        TestUtils.endSession(true);
+        List weblogs3 = mgr.getWebsites(testUser, Boolean.TRUE, Boolean.TRUE);
+        assertEquals(0, weblogs3.size());
+        
+        // remove test weblogs
+        TestUtils.teardownWeblog(testWeblog1.getId());
+        TestUtils.teardownWeblog(testWeblog2.getId());
+        TestUtils.endSession(true);
+    }
+    
+    
+    /**
+     * Test that we can safely remove a fully loaded weblog.
+     * That means a weblog with entries, categories, bookmarks, pings, etc.
+     */
+    public void testRemoveLoadedWeblog() throws Exception {
+        // TODO: implement testRemoveLoadedWeblog
+    }
+    
+}

Added: incubator/roller/trunk/tests/org/apache/roller/business/package.html
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/business/package.html?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/business/package.html (added)
+++ incubator/roller/trunk/tests/org/apache/roller/business/package.html Mon May  1 15:28:43 2006
@@ -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/apache/roller/presentation/ApplicationResourcesTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/presentation/ApplicationResourcesTest.java?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/presentation/ApplicationResourcesTest.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/presentation/ApplicationResourcesTest.java Mon May  1 15:28:43 2006
@@ -0,0 +1,162 @@
+/*
+ * Filename: ApplicationResourcesTest.java
+ * 
+ * Created on 24-May-04
+ */
+package org.apache.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/apache/roller/presentation/ArchiveParserTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/presentation/ArchiveParserTest.java?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/presentation/ArchiveParserTest.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/presentation/ArchiveParserTest.java Mon May  1 15:28:43 2006
@@ -0,0 +1,113 @@
+/*
+ * Created on May 4, 2004
+ */
+package org.apache.roller.presentation;
+
+import java.io.File;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.roller.RollerException;
+import org.apache.roller.RollerTestBase;
+import org.apache.roller.business.FileManagerTest;
+import org.apache.roller.pojos.RollerConfigData;
+import org.apache.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.getHandle() + 
+                                    "/" + ATOM_ARCHIVE);
+        parseFile(archiveFile);
+    }
+    
+    public void _testRssParsing() throws RollerException 
+    {
+        File archiveFile = new File(FILE_LOCATION + 
+                                    mWebsite.getHandle() + 
+                                    "/" + 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().flush();
+            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/apache/roller/presentation/LanguageUtilTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/presentation/LanguageUtilTest.java?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/presentation/LanguageUtilTest.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/presentation/LanguageUtilTest.java Mon May  1 15:28:43 2006
@@ -0,0 +1,91 @@
+/*
+ * Filename: LanguageUtilTest.java
+ * 
+ * Created on 13-Jul-04
+ */
+package org.apache.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/apache/roller/presentation/MockPrincipal.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/presentation/MockPrincipal.java?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/presentation/MockPrincipal.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/presentation/MockPrincipal.java Mon May  1 15:28:43 2006
@@ -0,0 +1,17 @@
+/*
+ * Created on Mar 8, 2004
+ */
+package org.apache.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/apache/roller/presentation/MockRollerContext.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/presentation/MockRollerContext.java?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/presentation/MockRollerContext.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/presentation/MockRollerContext.java Mon May  1 15:28:43 2006
@@ -0,0 +1 @@
+/*
 * Created on Mar 4, 2004
 */
package org.apache.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.apache.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.apache.roller.absolu
 teContextURL", "/");
    }
    //-----------------------------------------------------------------------
    /** Because I cannot set the super's values, I have to
     * overide the methods as well */  
    public static RollerContext getRollerContext()
    {
        // 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.getSch
 eme() +"://" + 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/apache/roller/presentation/MockRollerRequest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/presentation/MockRollerRequest.java?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/presentation/MockRollerRequest.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/presentation/MockRollerRequest.java Mon May  1 15:28:43 2006
@@ -0,0 +1,26 @@
+/*
+ * Created on Jun 8, 2004
+ */
+package org.apache.roller.presentation;
+
+import org.apache.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/apache/roller/presentation/SearchServletTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/presentation/SearchServletTest.java?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/presentation/SearchServletTest.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/presentation/SearchServletTest.java Mon May  1 15:28:43 2006
@@ -0,0 +1,50 @@
+package org.apache.roller.presentation;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.roller.presentation.filters.PersistenceSessionFilter;
+import org.apache.roller.presentation.filters.RequestFilter;
+import org.apache.roller.presentation.search.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.setupAddParameter("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/apache/roller/presentation/StrutsActionTestBase.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/presentation/StrutsActionTestBase.java?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/presentation/StrutsActionTestBase.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/presentation/StrutsActionTestBase.java Mon May  1 15:28:43 2006
@@ -0,0 +1,88 @@
+package org.apache.roller.presentation;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import javax.servlet.http.HttpSession;
+
+import org.apache.roller.RollerException;
+import org.apache.roller.RollerTestBase;
+import org.apache.roller.model.UserManager;
+import org.apache.roller.pojos.UserData;
+import org.apache.roller.pojos.WebsiteData;
+import org.apache.roller.presentation.filters.PersistenceSessionFilter;
+import org.apache.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) 
+        throws RollerException
+    {
+        MockHttpServletRequest mockRequest = getMockFactory().getMockRequest();
+        mockRequest.setRemoteUser(username);
+        mockRequest.setUserPrincipal(new MockPrincipal(username));
+        mockRequest.setUserInRole(role, true);
+        
+        HttpSession session = mockRequest.getSession(true);        
+        UserManager umgr = getRoller().getUserManager();
+        UserData user = umgr.getUserByUsername(username);
+
+        RollerSession rollerSession = new RollerSession();
+        rollerSession.setAuthenticatedUser(user);
+        session.setAttribute(RollerSession.ROLLER_SESSION, rollerSession);
+    }
+    
+    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/apache/roller/presentation/TestAll.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/presentation/TestAll.java?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/presentation/TestAll.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/presentation/TestAll.java Mon May  1 15:28:43 2006
@@ -0,0 +1,63 @@
+package org.apache.roller.presentation;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.roller.BlacklistTest;
+import org.apache.roller.DateTest;
+import org.apache.roller.presentation.bookmarks.BookmarksActionTest;
+import org.apache.roller.presentation.filters.RequestFilterTest;
+import org.apache.roller.presentation.velocity.plugins.smileys.SmileysTest;
+import org.apache.roller.presentation.velocity.plugins.textile.TextileTest;
+import org.apache.roller.presentation.weblog.WeblogEntryActionTest;
+import org.apache.roller.presentation.xmlrpc.RollerXmlRpcServerTest;
+import org.apache.roller.util.LRUCache2Test;
+import org.apache.roller.util.LinkbackExtractorTest;
+import org.apache.roller.util.RegexUtilTest;
+import org.apache.roller.util.UtilitiesTest;
+import org.apache.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(BookmarksActionTest.suite());
+        suite.addTest(WeblogEntryActionTest.suite());
+        suite.addTest(BlacklistTest.suite());
+        suite.addTest(DateTest.suite());
+        suite.addTest(RequestFilterTest.suite());
+        suite.addTest(SearchServletTest.suite());
+        suite.addTest(SmileysTest.suite());
+        suite.addTest(TextileTest.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());
+        // TODO: 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/apache/roller/presentation/VelocityServletTestBase.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/presentation/VelocityServletTestBase.java?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/presentation/VelocityServletTestBase.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/presentation/VelocityServletTestBase.java Mon May  1 15:28:43 2006
@@ -0,0 +1,112 @@
+package org.apache.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.apache.roller.RollerTestBase;
+import org.apache.roller.presentation.filters.PersistenceSessionFilter;
+import org.apache.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/apache/roller/presentation/bookmarks/BookmarksActionTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/presentation/bookmarks/BookmarksActionTest.java?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/presentation/bookmarks/BookmarksActionTest.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/presentation/bookmarks/BookmarksActionTest.java Mon May  1 15:28:43 2006
@@ -0,0 +1,96 @@
+/*
+ * Created on Oct 27, 2003
+ */
+package org.apache.roller.presentation.bookmarks;
+
+import java.util.List;
+import java.util.Set;
+
+import javax.servlet.http.HttpServletRequest;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.roller.RollerException;
+import org.apache.roller.model.UserManager;
+import org.apache.roller.pojos.FolderData;
+import org.apache.roller.pojos.UserData;
+import org.apache.roller.presentation.BasePageModel;
+import org.apache.roller.presentation.RollerRequest;
+import org.apache.roller.presentation.StrutsActionTestBase;
+import org.apache.roller.presentation.bookmarks.actions.BookmarksAction;
+import org.apache.roller.presentation.bookmarks.formbeans.BookmarksForm;
+
+import com.mockrunner.mock.web.MockActionMapping;
+import com.mockrunner.mock.web.MockHttpServletRequest;
+import com.mockrunner.mock.web.MockServletContext;
+
+/**
+ * Test BookmarkAction (proof-of-concept for Mockrunner Struts testing)
+ * @author Dave Johnson
+ */
+public class BookmarksActionTest extends StrutsActionTestBase
+{
+    public void testSelectFolder() 
+    {       
+        MockServletContext ctx = getMockFactory().getMockServletContext();
+        ctx.setServletContextName("/roller");        
+        MockHttpServletRequest request = getMockFactory().getMockRequest();
+        request.setContextPath("/roller");
+
+        UserManager umgr = null;
+        UserData user = null; 
+        try
+        {
+            umgr = getRoller().getUserManager();
+            user = (UserData)umgr.getUsers(mWebsite, null).get(0);       
+            doFilters();
+            authenticateUser(user.getUserName(), "editor");
+        }
+        catch (RollerException e)
+        {
+            e.printStackTrace();
+            fail();
+        }
+
+        // Setup form bean
+        BookmarksForm form = (BookmarksForm)
+            strutsModule.createActionForm(BookmarksForm.class);
+
+        // Setup mapping and request parameters
+        MockActionMapping mapping = strutsModule.getMockActionMapping();
+        mapping.setupForwards(new String[] {"access-denied","BookmarksForm"});
+        mapping.setParameter("method");        
+        strutsModule.addRequestParameter("weblog",mWebsite.getHandle()); 
+        strutsModule.addRequestParameter("method","selectFolder"); 
+                
+        try {
+            RollerRequest rreq = new RollerRequest(strutsModule.getMockPageContext());
+            rreq.setWebsite(mWebsite);
+            strutsModule.setRequestAttribute(RollerRequest.ROLLER_REQUEST, rreq);
+            strutsModule.actionPerform(BookmarksAction.class, form);        
+        } catch (Throwable e) {
+            e.printStackTrace();
+            fail();
+        }
+        // Test for success
+        strutsModule.verifyNoActionMessages();
+        strutsModule.verifyForward("BookmarksForm");
+        
+        // Verify objects we put in context for JSP page
+        verifyPageContext();
+    }
+    
+    protected void verifyPageContext() 
+    {
+        HttpServletRequest req = (HttpServletRequest)
+        servletModule.getFilteredRequest();
+        assertTrue(req.getAttribute("folder") instanceof FolderData);
+        assertTrue(req.getAttribute("model") instanceof BasePageModel);
+    }
+
+    public static Test suite() 
+    {
+        return new TestSuite(BookmarksActionTest.class);
+    }
+}

Added: incubator/roller/trunk/tests/org/apache/roller/presentation/filters/RequestFilterTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/presentation/filters/RequestFilterTest.java?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/presentation/filters/RequestFilterTest.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/presentation/filters/RequestFilterTest.java Mon May  1 15:28:43 2006
@@ -0,0 +1,49 @@
+package org.apache.roller.presentation.filters;
+
+import javax.servlet.http.HttpServletRequest;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.roller.presentation.RollerRequest;
+import org.apache.roller.presentation.VelocityServletTestBase;
+import org.apache.roller.presentation.velocity.PageServlet;
+
+import com.mockrunner.mock.web.MockHttpServletRequest;
+
+/** 
+ * @author Dave Johnson
+ */
+public class RequestFilterTest extends VelocityServletTestBase {
+    public void setUp() throws Exception
+    {
+        super.setUp();       
+    }
+    public RequestFilterTest() {
+    }
+    public void testRequestFilter() throws Exception {        
+        
+        servletModule.setServlet(
+           servletModule.createServlet(PageServlet.class));       
+
+        MockHttpServletRequest mockRequest = getMockFactory().getMockRequest();
+        mockRequest.setContextPath("/roller/page");
+        mockRequest.setPathInfo("/testuser/20050101");
+        mockRequest.setRequestURL("http://localost:8080");
+
+        servletModule.createFilter(PersistenceSessionFilter.class);
+        servletModule.createFilter(RequestFilter.class);
+        servletModule.setDoChain(true);
+
+        servletModule.doFilter();   
+        
+        HttpServletRequest req = (HttpServletRequest)
+            servletModule.getFilteredRequest();
+        RollerRequest rreq = RollerRequest.getRollerRequest(req);
+        assertNotNull(rreq);    
+    }
+    public static Test suite() 
+    {
+        return new TestSuite(RequestFilterTest.class);
+    }
+}

Added: incubator/roller/trunk/tests/org/apache/roller/presentation/velocity/ExportRssTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/presentation/velocity/ExportRssTest.java?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/presentation/velocity/ExportRssTest.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/presentation/velocity/ExportRssTest.java Mon May  1 15:28:43 2006
@@ -0,0 +1,138 @@
+/*
+ * Created on Mar 25, 2004
+ */
+package org.apache.roller.presentation.velocity;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Date;
+import java.util.List;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.roller.model.WeblogManager;
+import org.apache.roller.pojos.UserData;
+import org.apache.roller.presentation.StrutsActionTestBase;
+
+import com.mockrunner.mock.web.MockServletContext;
+
+/**
+ * Not really a servlet test, the ExportRss class does require
+ * that RollerContext has been loaded and initialized.
+ * 
+ * @author lance.lavandowska
+ */
+public class ExportRssTest extends StrutsActionTestBase
+{    
+    private String oldUploadPath;
+    
+    /**
+     * Not sure how to test that the file was generated, so if
+     * there was no Exception we passed.
+     */
+    public void testExportRecent() throws Exception
+    {      
+        ExportRss exporter = new ExportRss(mWebsite);
+        
+        //List entries = getRoller().getWeblogManager().getAllRecentWeblogEntries(new Date(), 5);
+        
+        List entries = getRoller().getWeblogManager().getWeblogEntries(
+                        null,               // userName
+                        null,               // startDate
+                        new Date(),         // endDate
+                        null,               // catName
+                        null,               // status
+                        null,               // sortby
+                        new Integer(5));    // maxEntries
+        
+        try
+        {
+            // test RSS output
+            exporter.exportEntries(entries, "export-test.rss.xml");
+
+            // test Atom output
+            exporter.setExportAtom(true);
+            exporter.exportEntries(entries, "export-test.atom.xml");
+        }
+        catch (Exception e)
+        {
+            mLogger.error(e);
+            // I'm not sure how best to test the output!
+            // I guess no exceptions will have to do.
+            fail("Find a better way to test than checking Exceptions, bozo!");
+        }
+        finally 
+        {
+        }
+    }
+    
+    /*
+     * Need to change the UploadPath location for testing. 
+     * @see junit.framework.TestCase#setUp()
+     */
+    public void setUp() throws Exception
+    {
+        super.setUp();       
+
+        MockServletContext mContext = getMockFactory().getMockServletContext();
+        mContext.setRealPath("build/junk", "./build/junk");
+        
+        setupVelocityProperties(mContext);
+    }
+    
+    /**
+     * ExportRss needs to load velocity.properties from ServletContext.
+     * For the mock implementation we need to set the 'resource stream'.
+     * @param mContext
+     * @throws IOException
+     */
+    private void setupVelocityProperties(MockServletContext mContext) throws IOException
+    {
+        InputStream is = this.getClass().getClassLoader().getResourceAsStream("velocity.properties");
+        if (is == null) fail("Unable to find velocity.properties");
+        BufferedInputStream bis = new BufferedInputStream(is, 1);
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        int buf = bis.read();
+        do
+        {
+            bos.write(buf);
+            buf = bis.read();
+        }
+        while(buf != -1);
+        
+        byte[] bytes = bos.toByteArray();
+        mContext.setResourceAsStream("/WEB-INF/velocity.properties", bytes);
+        try
+        {
+            bos.close();
+            bis.close();
+        }
+        catch (IOException e)
+        {
+            e.printStackTrace();
+        }
+    }
+
+    /*
+     * Need to reset the UploadPath after testing. 
+     * @see junit.framework.TestCase#tearDown()
+     */
+    public void tearDown() throws Exception
+    {
+        //getRoller().begin(UserData.SYSTEM_USER);
+        //RollerConfigData  rollerConfig = rollerContext.getRollerConfig();
+        //rollerConfig.setUploadPath(oldUploadPath);
+        //rollerConfig.save();
+        //getRoller().commit();
+        
+        super.tearDown();
+    }
+
+    public static Test suite() 
+    {
+        return new TestSuite(ExportRssTest.class);
+    }
+}

Added: incubator/roller/trunk/tests/org/apache/roller/presentation/velocity/plugins/smileys/SmileysTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/presentation/velocity/plugins/smileys/SmileysTest.java?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/presentation/velocity/plugins/smileys/SmileysTest.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/presentation/velocity/plugins/smileys/SmileysTest.java Mon May  1 15:28:43 2006
@@ -0,0 +1,52 @@
+/*
+ * Created on Jun 8, 2004
+ */
+package org.apache.roller.presentation.velocity.plugins.smileys;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.roller.presentation.MockRollerRequest;
+import org.apache.roller.presentation.VelocityServletTestBase;
+
+import com.mockrunner.mock.web.MockHttpServletRequest;
+import com.mockrunner.mock.web.MockServletContext;
+
+/**
+ * @author lance.lavandowska
+ */
+public class SmileysTest extends VelocityServletTestBase
+{
+    public void testSmileEmoticon() throws Exception
+    {
+        MockServletContext ctx = getMockFactory().getMockServletContext();
+        ctx.setServletContextName("/roller");      
+        
+        MockHttpServletRequest request = getMockFactory().getMockRequest();
+        request.setContextPath("/roller");
+       
+        doFilters();
+
+        SmileysPlugin plugin = new SmileysPlugin();
+        plugin.init(mWebsite, ctx, "/roller", null);
+        assertTrue( SmileysPlugin.smileyPatterns.length > 0 );
+
+        String test = "put on a happy :-) face";
+        String expected = 
+            "put on a happy <img src=\"/roller/images/smileys/smile.gif" +
+            "\" class=\"smiley\" alt=\":-)\" title=\":-)\"> face";
+        String result = plugin.render(test);
+        //System.out.println(result);
+        assertEquals(expected, result);
+    }
+        
+    public SmileysTest()
+    {
+        super();
+    }
+
+    public static Test suite() 
+    {
+        return new TestSuite(SmileysTest.class);
+    }
+}

Added: incubator/roller/trunk/tests/org/apache/roller/presentation/velocity/plugins/textile/TextileTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/presentation/velocity/plugins/textile/TextileTest.java?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/presentation/velocity/plugins/textile/TextileTest.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/presentation/velocity/plugins/textile/TextileTest.java Mon May  1 15:28:43 2006
@@ -0,0 +1 @@
+/*
 * Created on Oct 31, 2003
 */
package org.apache.roller.presentation.velocity.plugins.textile;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import org.apache.roller.presentation.bookmarks.BookmarksActionTest;
import org.apache.roller.model.PagePlugin;
import org.apache.roller.presentation.velocity.plugins.textile.TextilePlugin;

/**
 * We really need to solve webtesting to adequately test our Presentation classes.
 * 
 * @author lance
 */
public class TextileTest extends TestCase
{
    String textileStr = "*strong* plain _emphasis_ * _emphaticStrong_ * ";
    String expected = "<p><strong>strong</strong> plain <em>emphasis</em> <strong> <em>emphaticStrong</em> </strong></p>";
  
    /* 
     * This fails because Textile4J appears to place a tab (\t)
     * at the beginning of the result.  If the result is .trim()'ed
     * then it passes.
     */
    public void testTextile()
    {
        PagePlugin textile = new Text
 ilePlugin();
        
        String result = textile.render(textileStr);
        //System.out.println(expected);
        //System.out.println(result);
        assertEquals("this will fail until Textile4J is fixed.", expected, result);         
    }
    
	/* (non-Javadoc)
	 * @see junit.framework.TestCase#setUp()
	 */
	protected void setUp() throws Exception
	{
        super.setUp();	       
	}

	/* (non-Javadoc)
	 * @see junit.framework.TestCase#tearDown()
	 */
	protected void tearDown() throws Exception
	{
	   super.tearDown();
	}

    public static Test suite() 
    {
        return new TestSuite(TextileTest.class);
    }

}
\ No newline at end of file

Added: incubator/roller/trunk/tests/org/apache/roller/presentation/weblog/WeblogEntryActionTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/presentation/weblog/WeblogEntryActionTest.java?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/presentation/weblog/WeblogEntryActionTest.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/presentation/weblog/WeblogEntryActionTest.java Mon May  1 15:28:43 2006
@@ -0,0 +1,87 @@
+package org.apache.roller.presentation.weblog;
+
+import javax.servlet.http.HttpServletRequest;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.roller.RollerException;
+import org.apache.roller.model.UserManager;
+import org.apache.roller.pojos.UserData;
+import org.apache.roller.presentation.RollerRequest;
+import org.apache.roller.presentation.StrutsActionTestBase;
+import org.apache.roller.presentation.weblog.actions.WeblogEntryFormAction;
+import org.apache.roller.presentation.weblog.formbeans.WeblogEntryFormEx;
+
+import com.mockrunner.mock.web.MockActionMapping;
+import com.mockrunner.mock.web.MockHttpServletRequest;
+
+/**
+ * @author dave
+ */
+public class WeblogEntryActionTest extends StrutsActionTestBase
+{
+    public void testCreateWeblogEntry() 
+    {
+        MockHttpServletRequest mockRequest = getMockFactory().getMockRequest();
+        mockRequest.setContextPath("/dummy");        
+        doFilters();
+        
+        UserManager umgr = null;
+        UserData user = null; 
+        try
+        {
+            umgr = getRoller().getUserManager();
+            user = (UserData)umgr.getUsers(mWebsite, null).get(0);       
+            authenticateUser(user.getUserName(), "editor");
+        }
+        catch (RollerException e)
+        {
+            e.printStackTrace();
+            fail();
+        }
+        
+        // Setup mapping and request parameters
+        MockActionMapping mapping = strutsModule.getMockActionMapping();
+        mapping.setupForwards(new String[] {
+            "access-denied","weblogEdit.page","weblogEntryRemove.page"});
+        mapping.setParameter("method");  
+        strutsModule.addRequestParameter("weblog",mWebsite.getHandle()); 
+        strutsModule.addRequestParameter("method","create"); 
+        
+        // Setup form bean
+        WeblogEntryFormEx form = (WeblogEntryFormEx)
+            strutsModule.createActionForm(WeblogEntryFormEx.class);
+        form.setTitle("test_title");
+        form.setText("Test blog text");
+
+        try {
+            RollerRequest rreq = new RollerRequest(strutsModule.getMockPageContext());
+            rreq.setWebsite(mWebsite);
+            strutsModule.setRequestAttribute(RollerRequest.ROLLER_REQUEST, rreq);
+            strutsModule.actionPerform(WeblogEntryFormAction.class, form);        
+        } catch (Throwable t) {
+            t.printStackTrace();
+            fail();
+        }
+        // Test for success
+        strutsModule.verifyNoActionMessages();
+        strutsModule.verifyForward("weblogEdit.page");
+        
+        // Verify objects we put in context for JSP page
+        verifyPageContext();
+    }
+    
+    protected void verifyPageContext() 
+    {
+        HttpServletRequest req = (HttpServletRequest)
+            servletModule.getFilteredRequest();
+        assertNotNull(req.getAttribute("model"));
+    }
+
+    public static Test suite() 
+    {
+        return new TestSuite(WeblogEntryActionTest.class);
+    }
+
+}

Added: incubator/roller/trunk/tests/org/apache/roller/presentation/xmlrpc/RollerXmlRpcServerTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/presentation/xmlrpc/RollerXmlRpcServerTest.java?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/presentation/xmlrpc/RollerXmlRpcServerTest.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/presentation/xmlrpc/RollerXmlRpcServerTest.java Mon May  1 15:28:43 2006
@@ -0,0 +1,163 @@
+/*
+ * Created on Jun 15, 2004
+ */
+package org.apache.roller.presentation.xmlrpc;
+
+import com.mockrunner.mock.web.MockHttpServletRequest;
+import com.mockrunner.mock.web.MockHttpServletResponse;
+import com.mockrunner.mock.web.MockServletContext;
+import com.mockrunner.mock.web.WebMockObjectFactory;
+import com.mockrunner.servlet.ServletTestModule;
+
+import org.apache.roller.RollerTestBase;
+import org.apache.roller.presentation.MockRollerContext;
+import org.apache.roller.presentation.RollerRequest;
+import org.apache.roller.presentation.webservices.xmlrpc.RollerXMLRPCServlet;
+import org.apache.roller.util.RegexUtil;
+ 
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.regex.Pattern;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Makes calls to the RollerXmlRpcServer, which should handle a
+ * post just as it would with a real XML-RPC call.
+ * 
+ * @author lance.lavandowska
+ */
+public class RollerXmlRpcServerTest extends RollerTestBase
+{
+    private static HashMap typeMap = new HashMap();
+    static {
+        typeMap.put(Boolean.class, "boolean");
+        typeMap.put(Double.class, "double");
+        typeMap.put(Date.class, "dateTime.iso8601");
+        typeMap.put(Integer.class, "int");
+    }
+
+    protected WebMockObjectFactory mockFactory;
+    protected MockRollerContext rollerContext;
+    protected MockHttpServletRequest mockRequest;
+    protected ServletTestModule servletTestModule;
+
+    public void testBloggerGetRecentPosts()
+    {
+        ArrayList params = new ArrayList();
+        params.add("roller"); // appkey
+        params.add("testuser0"); // blogid
+        params.add("testuser0"); // userid
+        params.add("password"); // password
+        params.add(new Integer(5)); // numposts
+        String message = buildXmlRpcString("blogger.getRecentPosts", params);
+
+        mockRequest.setBodyContent(message);
+        servletTestModule.doPost();
+        MockHttpServletResponse response = mockFactory.getMockResponse();
+        String responseBody = response.getOutputStreamContent();
+
+        // assert no fault code
+        assertTrue(responseBody, 
+                responseBody.indexOf("<name>faultCode</name>") == -1);
+        
+        // make sure all/any userids returned belong to our test user
+        Pattern userPattern = 
+                Pattern.compile("<name>userid</name><value>(.*?)</value>");
+        ArrayList users = RegexUtil.getMatches(userPattern, responseBody, 1);
+        Iterator it = users.iterator();
+        while (it.hasNext()) 
+        {
+            String user = (String)it.next();
+            //System.out.println(user);
+            if (user.equals("testuser0"))
+            {
+                continue;
+            }
+            else
+            {
+                fail("getRecentPosts() returned entry for a user [" 
+                        + user + "] other than " + testUsername);
+            }
+        }
+    }
+    
+    /**
+     * Build an XML-RPC message from methodName and params.
+     * 
+     * @param methodName
+     * @param params
+     * @return
+     */
+    private String buildXmlRpcString(String methodName, ArrayList params)
+    {
+        StringBuffer buf = new StringBuffer("<?xml version=\"1.0\"?>");
+        buf.append("<methodCall>");
+        buf.append("<methodName>").append(methodName).append("</methodName>");
+        buf.append("<params>");
+        Iterator it = params.iterator();
+        while (it.hasNext()) {
+            buf.append("<param><value>");
+            Object param = it.next();
+            String paramType = (String)typeMap.get(param.getClass());
+            if (paramType != null)
+            {
+                buf.append("<").append(paramType).append(">")
+                   .append(param)
+                   .append("</").append(paramType).append(">");                    
+            }
+            else
+            {    
+                buf.append("<string>").append(param).append("</string>");
+            }
+            buf.append("</value></param>");
+        }
+        buf.append("</params> ");
+        buf.append("</methodCall>");
+        return buf.toString();
+    }
+    
+    //-----------------------------------------------------------------------
+    public void setUp() throws Exception
+    {
+        // must do super.setup() before creating MockRollerContext
+        super.setUp();
+        setUpTestWeblogs();
+
+        mockFactory = new WebMockObjectFactory();
+
+        // create mock RollerContext
+        MockServletContext ctx = mockFactory.getMockServletContext();
+        ctx.setRealPath("/", ".");
+        rollerContext = new MockRollerContext();
+        rollerContext.init(ctx);
+
+        mockRequest = mockFactory.getMockRequest();
+        mockRequest.setContextPath("/roller");
+        RollerRequest.getRollerRequest(
+                mockRequest, mockFactory.getMockServletContext());
+
+        servletTestModule = new ServletTestModule(mockFactory);
+        servletTestModule.createServlet(RollerXMLRPCServlet.class);
+    }
+
+    //-----------------------------------------------------------------------
+    public void tearDown() throws Exception
+    {
+        super.tearDown();
+        mockRequest = null;
+        servletTestModule.clearOutput();
+        servletTestModule.releaseFilters();
+        servletTestModule = null;
+        rollerContext = null;
+        mockFactory = null;
+    }
+
+    public static Test suite() 
+    {
+        return new TestSuite(RollerXmlRpcServerTest.class);
+    }
+}
\ No newline at end of file

Added: incubator/roller/trunk/tests/org/apache/roller/util/LRUCache2Test.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/util/LRUCache2Test.java?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/util/LRUCache2Test.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/util/LRUCache2Test.java Mon May  1 15:28:43 2006
@@ -0,0 +1,114 @@
+/*
+ * Created on Jun 15, 2004
+ */
+package org.apache.roller.util;
+
+import org.apache.roller.presentation.bookmarks.BookmarksActionTest;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * @author dmj
+ */
+public class LRUCache2Test extends TestCase
+{
+    /** 
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        // TODO Auto-generated method stub
+        super.setUp();
+    }
+    
+    public void testTimeout() 
+    {
+        // Create cache with 100 item limit and 15 second timeout
+        TestEnvironment env = new TestEnvironment();
+        LRUCache2 cache = new LRUCache2(env, 100, 15000);
+            
+        env.time = 1000;
+        cache.put("key1", "string1");
+        cache.put("key2", "string2");
+        cache.put("key3", "string3");
+        assertNotNull(cache.get("key1"));
+        assertNotNull(cache.get("key2"));
+        assertNotNull(cache.get("key3"));
+
+        env.time = 16000;
+        assertNull(cache.get("key1"));
+        assertNull(cache.get("key2"));
+        assertNull(cache.get("key3"));
+    }
+    
+    public void testLRU() 
+    {
+        // Create cache with 3 item limit and 15 second timeout
+        TestEnvironment env = new TestEnvironment();
+        LRUCache2 cache = new LRUCache2(env, 3, 15000);
+            
+        env.time = 1000;
+        cache.put("key1", "string1");
+        cache.put("key2", "string2");
+        cache.put("key3", "string3");
+        assertNotNull(cache.get("key1"));
+        assertNotNull(cache.get("key2"));
+        assertNotNull(cache.get("key3"));
+        
+        try { Thread.sleep(200); } catch (InterruptedException ignored) {}
+        
+        // accessing key1 and key2 will make key3 LRU
+        cache.get("key1");
+        cache.get("key2");
+        
+        // adding a forth key will push out the LRU entry
+        cache.put("key4", "string4");    
+        assertNull(cache.get("key3"));     
+    }
+    
+    public void testPurge() 
+    {
+        // Create cache with 100 item limit and 15 second timeout
+        TestEnvironment env = new TestEnvironment();
+        LRUCache2 cache = new LRUCache2(env, 100, 15000);
+            
+        env.time = 1000;
+        cache.put("key1", "string1");
+        cache.put("key2", "string2");
+        cache.put("key3", "string3");
+        assertNotNull(cache.get("key1"));
+        assertNotNull(cache.get("key2"));
+        assertNotNull(cache.get("key3"));
+        
+        cache.purge(new String[] {"key1", "key2"});
+        assertEquals(1, cache.size());
+        
+        cache.purge();
+        assertEquals(0, cache.size());
+    }
+    
+    /** 
+     * @see junit.framework.TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        // TODO Auto-generated method stub
+        super.tearDown();
+    }
+    
+    public static class TestEnvironment implements LRUCache2.Environment 
+	{
+    	public long time = 0;
+		public long getCurrentTimeInMillis() 
+		{
+			return time;
+		}
+	}
+
+    public static Test suite() 
+    {
+        return new TestSuite(LRUCache2Test.class);
+    }
+}

Added: incubator/roller/trunk/tests/org/apache/roller/util/LinkbackExtractorTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/util/LinkbackExtractorTest.java?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/util/LinkbackExtractorTest.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/util/LinkbackExtractorTest.java Mon May  1 15:28:43 2006
@@ -0,0 +1,73 @@
+
+package org.apache.roller.util;
+
+import org.apache.roller.presentation.bookmarks.BookmarksActionTest;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * @author davidj
+ */
+public class LinkbackExtractorTest extends TestCase
+{
+    /**
+     * Constructor for LinkbackExtractorTest.
+     * @param arg0
+     */
+    public LinkbackExtractorTest(String arg0)
+    {
+        super(arg0);
+    }
+
+    public static void main(String[] args)
+    {
+    }
+
+    /**
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+    }
+
+    /**
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+
+    public void testLinkbackExtractor() throws Exception
+    {
+		String[][] testrefs = new String[][] 
+		{
+            { 
+                "http://www.rollerweblogger.org/page/roller", 
+                "http://staff.develop.com/halloway/weblog/2003/01/23.html" 
+            },
+            { 
+                "http://postneo.com/", 
+                "http://www.rollerweblogger.org/page/roller/20030125" 
+            }
+		};
+		
+		for ( int i=0; i<testrefs.length; i++ )
+		{
+			String refurl = testrefs[i][0];
+			String requrl = testrefs[i][1];
+			LinkbackExtractor le = new LinkbackExtractor(refurl,requrl);
+			System.out.println(le.getTitle());
+			System.out.println(le.getPermalink());
+			System.out.println(le.getExcerpt());
+		}		
+    }
+
+    public static Test suite() 
+    {
+        return new TestSuite(LinkbackExtractorTest.class);
+    }
+}

Added: incubator/roller/trunk/tests/org/apache/roller/util/PropertyExpanderTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/util/PropertyExpanderTest.java?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/util/PropertyExpanderTest.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/util/PropertyExpanderTest.java Mon May  1 15:28:43 2006
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit test for org.apache.roller.util.PropertyExpander.
+ *
+ * @author <a href="mailto:anil@busybuddha.org">Anil Gangolli</a>
+ */
+public class PropertyExpanderTest extends TestCase
+{
+    private static final Map props = new HashMap();
+
+    static
+    {
+        props.put("defined.property.one", "value one");
+        props.put("defined.property.two", "value two");
+        props.put("defined.property.with.dollar.sign.in.value", "$2");
+    }
+
+    public void testExpansion() throws Exception
+    {
+        String expanded =
+            PropertyExpander.expandProperties("String with ${defined.property.one} and ${defined.property.two} and ${defined.property.with.dollar.sign.in.value} and ${undefined.property} and some stuff.", props);
+
+        assertEquals("Expanded string doesn't match expected",
+            "String with value one and value two and $2 and ${undefined.property} and some stuff.",
+            expanded);
+    }
+
+    public void testSystemProperty() throws Exception
+    {
+        String expanded =
+            PropertyExpander.expandSystemProperties("${java.home}");
+        assertEquals("Expanded string doesn't match expected",
+            System.getProperty("java.home"),
+            expanded);
+    }
+
+}

Added: incubator/roller/trunk/tests/org/apache/roller/util/RegexUtilTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/util/RegexUtilTest.java?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/util/RegexUtilTest.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/util/RegexUtilTest.java Mon May  1 15:28:43 2006
@@ -0,0 +1,82 @@
+/*
+ * Created on Nov 8, 2003
+ */
+package org.apache.roller.util;
+
+import org.apache.roller.presentation.bookmarks.BookmarksActionTest;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * @author lance
+ */
+public class RegexUtilTest extends TestCase
+{
+
+	/**
+	 * 
+	 */
+	public RegexUtilTest()
+	{
+		super();
+	}
+
+	/**
+	 * @param arg0
+	 */
+	public RegexUtilTest(String arg0)
+	{
+		super(arg0);
+	}
+
+    /**
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+    }
+
+    /**
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+    
+    public void testEncodingEmail()
+    {
+        // test mailto: escaping
+        String test = "test <a href='mailto:this@email.com'>email</a> string";
+        String expect = "test <a href='mailto:%74%68%69%73%40%65%6d%61%69%6c%2e%63%6f%6d'>email</a> string";
+        String result = RegexUtil.encodeEmail(test) ;
+        //System.out.println(result);
+        assertEquals(expect, result);        
+    }
+    
+    public void testObfuscateEmail()
+    {
+        // test "plaintext" escaping
+        String test = "this@email.com";
+        String expect = "this-AT-email-DOT-com";
+        String result = RegexUtil.encodeEmail(test);
+        assertEquals(expect, result);        
+    }
+    
+    public void testHexEmail()
+    {
+        // test hex & obfuscate together
+        String test = "test <a href='mailto:this@email.com'>this@email.com</a> string, and this@email.com";
+        String expect = "test <a href='mailto:%74%68%69%73%40%65%6d%61%69%6c%2e%63%6f%6d'>this-AT-email-DOT-com</a> string, and this-AT-email-DOT-com";
+        String result = RegexUtil.encodeEmail(test);
+        //System.out.println(result);
+        assertEquals(expect, result);
+    }
+
+    public static Test suite() 
+    {
+        return new TestSuite(RegexUtilTest.class);
+    }}

Added: incubator/roller/trunk/tests/org/apache/roller/util/UtilitiesTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/util/UtilitiesTest.java?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/util/UtilitiesTest.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/util/UtilitiesTest.java Mon May  1 15:28:43 2006
@@ -0,0 +1,96 @@
+/*
+ * Created on Nov 2, 2003
+ */
+package org.apache.roller.util;
+
+import org.apache.roller.presentation.bookmarks.BookmarksActionTest;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * @author lance
+ */
+public class UtilitiesTest extends TestCase
+{
+    /**
+     * Constructor for LinkbackExtractorTest.
+     * @param arg0
+     */
+    public UtilitiesTest(String arg0)
+    {
+        super(arg0);
+    }
+
+    public static void main(String[] args)
+    {
+    }
+
+    /**
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+    }
+
+    /**
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+    
+    public void testExtractHTML()
+    {
+        String test = "<a>keep me</a>";
+        String expect = "<a></a>";
+        String result = Utilities.extractHTML(test);
+        assertEquals(expect, result);
+    }
+    
+    public void testRemoveHTML()
+    {
+        String test = "<br><br><p>a <b>bold</b> sentence with a <a href=\"http://example.com\">link</a></p>";
+        String expect = "a bold sentence with a link";
+        String result = Utilities.removeHTML(test, false);
+        assertEquals(expect, result);
+    }
+        
+    public void testTruncateNicely1()
+    {
+        String test = "blah blah blah blah blah";
+        String expect = "blah blah blah";
+        String result = Utilities.truncateNicely(test, 11, 15, "");
+        assertEquals(expect, result);
+    }
+    
+    public void testTruncateNicely2()
+    {
+        String test = "<p><b>blah1 blah2</b> <i>blah3 blah4 blah5</i></p>";
+        String expect = "<p><b>blah1 blah2</b> <i>blah3</i></p>";
+        String result = Utilities.truncateNicely(test, 15, 20, "");
+        //System.out.println(result);
+        assertEquals(expect, result);
+    }
+
+    public void testAddNoFollow() {
+        String test1 = "<p>this some text with a <a href=\"http://example.com\">link</a>";
+        String expect1 = "<p>this some text with a <a href=\"http://example.com\" rel=\"nofollow\">link</a>";
+        String result1 = Utilities.addNofollow(test1);
+        assertEquals(expect1, result1);
+
+        String test2 = "<p>this some text with a <A href=\"http://example.com\">link</a>";
+        String expect2 = "<p>this some text with a <A href=\"http://example.com\" rel=\"nofollow\">link</a>";
+        String result2 = Utilities.addNofollow(test2);
+        assertEquals(expect2, result2);
+
+    }
+
+    public static Test suite() 
+    {
+        return new TestSuite(UtilitiesTest.class);
+    }
+}

Added: incubator/roller/trunk/tests/org/apache/roller/util/rome/DiskFeedInfoCacheTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/apache/roller/util/rome/DiskFeedInfoCacheTest.java?rev=398714&view=auto
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/util/rome/DiskFeedInfoCacheTest.java (added)
+++ incubator/roller/trunk/tests/org/apache/roller/util/rome/DiskFeedInfoCacheTest.java Mon May  1 15:28:43 2006
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2005 Sun Microsystems, Inc.
+ *
+ * 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.apache.roller.util.rome;
+
+import java.io.File;
+import java.net.URL;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.roller.business.FileManagerTest;
+import com.sun.syndication.fetcher.impl.SyndFeedInfo;
+
+/**
+ * @author David M Johnson
+ */
+public class DiskFeedInfoCacheTest extends TestCase
+{
+    public static void main(String[] args)
+    {
+        junit.textui.TestRunner.run(DiskFeedInfoCacheTest.class);
+    }
+
+    public void testCache() throws Exception  
+    {
+        URL url = new URL("http://cnn.com");
+        SyndFeedInfo info = new SyndFeedInfo();
+        info.setUrl(url);
+        
+        String buildDir = System.getProperty("ro.build");
+        assertNotNull("ro.build not null", buildDir);
+        assertTrue("ro.build not zero length", buildDir.trim().length() > 0);
+        if (!buildDir.startsWith("/")) buildDir = "..";
+        File file = new File(buildDir);
+        
+        assertTrue("buildDir exists", file.exists());
+        assertTrue("buildDir is directory", file.isDirectory());        
+        
+        DiskFeedInfoCache cache = 
+            new DiskFeedInfoCache(buildDir + "/tests/planet-cache");
+        cache.setFeedInfo(info.getUrl(), info);
+        
+        SyndFeedInfo info2 = cache.getFeedInfo(url);
+        assertNotNull(info2);
+        assertEquals(url, info2.getUrl());
+    }
+
+    public static Test suite()
+    {
+        return new TestSuite(DiskFeedInfoCacheTest.class);
+
+    }
+}