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/06/25 21:33:53 UTC

svn commit: r417044 [3/3] - in /incubator/roller/branches/roller_3.0: ./ metadata/database/ src/org/apache/roller/business/ src/org/apache/roller/business/hibernate/ src/org/apache/roller/pojos/ src/org/apache/roller/ui/core/ src/org/apache/roller/ui/r...

Modified: incubator/roller/branches/roller_3.0/tests/org/apache/roller/ui/authoring/struts/actions/BookmarksActionTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/tests/org/apache/roller/ui/authoring/struts/actions/BookmarksActionTest.java?rev=417044&r1=417043&r2=417044&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/tests/org/apache/roller/ui/authoring/struts/actions/BookmarksActionTest.java (original)
+++ incubator/roller/branches/roller_3.0/tests/org/apache/roller/ui/authoring/struts/actions/BookmarksActionTest.java Sun Jun 25 12:33:50 2006
@@ -1,39 +1,46 @@
 /*
-* 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.
-*/
+ * 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.
+ */
 /*
  * Created on Oct 27, 2003
  */
 package org.apache.roller.ui.authoring.struts.actions;
 
 
+
+import com.mockrunner.mock.web.MockActionMapping;
+import com.mockrunner.mock.web.MockHttpServletRequest;
+import com.mockrunner.mock.web.MockServletContext;
+
 import javax.servlet.http.HttpServletRequest;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import org.apache.roller.RollerException;
+import org.apache.roller.TestUtils;
+import org.apache.roller.model.RollerFactory;
 import org.apache.roller.model.UserManager;
 import org.apache.roller.pojos.FolderData;
 import org.apache.roller.pojos.UserData;
-
-import com.mockrunner.mock.web.MockActionMapping;
-import com.mockrunner.mock.web.MockHttpServletRequest;
-import com.mockrunner.mock.web.MockServletContext;
+import org.apache.roller.pojos.WebsiteData;
 import org.apache.roller.ui.StrutsActionTestBase;
 import org.apache.roller.ui.authoring.struts.formbeans.BookmarksForm;
 import org.apache.roller.ui.core.BasePageModel;
@@ -43,46 +50,72 @@
  * Test BookmarkAction (proof-of-concept for Mockrunner Struts testing)
  * @author Dave Johnson
  */
-public class BookmarksActionTest extends StrutsActionTestBase
-{
-    public void testSelectFolder() 
-    {       
+public class BookmarksActionTest extends StrutsActionTestBase {
+    private WebsiteData testWeblog = null;
+    private UserData testUser = null;
+    public static Log log = LogFactory.getLog(BookmarksActionTest.class);
+    
+    /**
+     * All tests in this suite require a user and a weblog.
+     */
+    public void setUp() throws Exception {
+        super.setUp();
+        try {
+            testUser = TestUtils.setupUser("bkmrkTestUser");
+            testWeblog = TestUtils.setupWeblog("bkmrkTestWeblog", testUser);
+            TestUtils.endSession(true);
+        } catch (Exception ex) {
+            log.error(ex);
+            throw new Exception("Test setup failed", ex);
+        }
+    }
+    
+    public void tearDown() throws Exception {
+        super.tearDown();
+        try {
+            TestUtils.teardownWeblog(testWeblog.getId());
+            TestUtils.teardownUser(testUser.getId());
+            TestUtils.endSession(true);
+        } catch (Exception ex) {
+            log.error(ex);
+            throw new Exception("Test teardown failed", ex);
+        }
+    }
+    
+    public void testSelectFolder() {
         MockServletContext ctx = getMockFactory().getMockServletContext();
-        ctx.setServletContextName("/roller");        
+        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, 0, Integer.MAX_VALUE).get(0);       
+        UserData user = null;
+        try {
+            umgr = RollerFactory.getRoller().getUserManager();
+            user = (UserData)umgr.getUsers(testWeblog, null, 0, Integer.MAX_VALUE).get(0);
             doFilters();
             authenticateUser(user.getUserName(), "editor");
-        }
-        catch (RollerException e)
-        {
+        } catch (RollerException e) {
             e.printStackTrace();
             fail();
         }
-
+        
         // Setup form bean
         BookmarksForm form = (BookmarksForm)
-            strutsModule.createActionForm(BookmarksForm.class);
-
+        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"); 
-                
+        mapping.setParameter("method");
+        strutsModule.addRequestParameter("weblog",testWeblog.getHandle());
+        strutsModule.addRequestParameter("method","selectFolder");
+        
         try {
             RollerRequest rreq = new RollerRequest(strutsModule.getMockPageContext());
-            rreq.setWebsite(mWebsite);
+            rreq.setWebsite(testWeblog);
             strutsModule.setRequestAttribute(RollerRequest.ROLLER_REQUEST, rreq);
-            strutsModule.actionPerform(BookmarksAction.class, form);        
+            strutsModule.actionPerform(BookmarksAction.class, form);
         } catch (Throwable e) {
             e.printStackTrace();
             fail();
@@ -95,16 +128,15 @@
         verifyPageContext();
     }
     
-    protected void 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() 
-    {
+    
+    public static Test suite() {
         return new TestSuite(BookmarksActionTest.class);
     }
+    
 }

Modified: incubator/roller/branches/roller_3.0/tests/org/apache/roller/ui/authoring/struts/actions/WeblogEntryActionTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/tests/org/apache/roller/ui/authoring/struts/actions/WeblogEntryActionTest.java?rev=417044&r1=417043&r2=417044&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/tests/org/apache/roller/ui/authoring/struts/actions/WeblogEntryActionTest.java (original)
+++ incubator/roller/branches/roller_3.0/tests/org/apache/roller/ui/authoring/struts/actions/WeblogEntryActionTest.java Sun Jun 25 12:33:50 2006
@@ -1,33 +1,40 @@
 /*
-* 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.
-*/
+ * 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.ui.authoring.struts.actions;
 
+
+import com.mockrunner.mock.web.MockActionMapping;
+import com.mockrunner.mock.web.MockHttpServletRequest;
+
 import javax.servlet.http.HttpServletRequest;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import org.apache.roller.RollerException;
+import org.apache.roller.TestUtils;
+import org.apache.roller.model.RollerFactory;
 import org.apache.roller.model.UserManager;
 import org.apache.roller.pojos.UserData;
-
-import com.mockrunner.mock.web.MockActionMapping;
-import com.mockrunner.mock.web.MockHttpServletRequest;
+import org.apache.roller.pojos.WebsiteData;
 import org.apache.roller.ui.StrutsActionTestBase;
 import org.apache.roller.ui.authoring.struts.formbeans.WeblogEntryFormEx;
 import org.apache.roller.ui.core.RollerRequest;
@@ -35,24 +42,49 @@
 /**
  * @author dave
  */
-public class WeblogEntryActionTest extends StrutsActionTestBase
-{
-    public void testCreateWeblogEntry() 
-    {
+public class WeblogEntryActionTest extends StrutsActionTestBase {
+    private WebsiteData testWeblog = null;
+    private UserData testUser = null;
+    public static Log log = LogFactory.getLog(WeblogEntryActionTest.class);
+    
+    /**
+     * All tests in this suite require a user and a weblog.
+     */
+    public void setUp() throws Exception {
+        super.setUp();
+        try {
+            testUser = TestUtils.setupUser("bkmrkTestUser");
+            testWeblog = TestUtils.setupWeblog("bkmrkTestWeblog", testUser);
+            TestUtils.endSession(true);
+        } catch (Exception ex) {
+            log.error(ex);
+            throw new Exception("Test setup failed", ex);
+        }
+    }
+    
+    public void tearDown() throws Exception {
+        super.tearDown();
+        try {
+            TestUtils.teardownWeblog(testWeblog.getId());
+            TestUtils.teardownUser(testUser.getId());
+            TestUtils.endSession(true);
+        } catch (Exception ex) {
+            log.error(ex);
+            throw new Exception("Test teardown failed", ex);
+        }
+    }
+    public void testCreateWeblogEntry() {
         MockHttpServletRequest mockRequest = getMockFactory().getMockRequest();
-        mockRequest.setContextPath("/dummy");        
+        mockRequest.setContextPath("/dummy");
         doFilters();
         
         UserManager umgr = null;
-        UserData user = null; 
-        try
-        {
-            umgr = getRoller().getUserManager();
-            user = (UserData)umgr.getUsers(mWebsite, null, 0, Integer.MAX_VALUE).get(0);       
+        UserData user = null;
+        try {
+            umgr = RollerFactory.getRoller().getUserManager();
+            user = (UserData)umgr.getUsers(testWeblog, null, 0, -1).get(0);
             authenticateUser(user.getUserName(), "editor");
-        }
-        catch (RollerException e)
-        {
+        } catch (RollerException e) {
             e.printStackTrace();
             fail();
         }
@@ -61,21 +93,21 @@
         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"); 
+        mapping.setParameter("method");
+        strutsModule.addRequestParameter("weblog",testWeblog.getHandle());
+        strutsModule.addRequestParameter("method","create");
         
         // Setup form bean
         WeblogEntryFormEx form = (WeblogEntryFormEx)
-            strutsModule.createActionForm(WeblogEntryFormEx.class);
+        strutsModule.createActionForm(WeblogEntryFormEx.class);
         form.setTitle("test_title");
         form.setText("Test blog text");
-
+        
         try {
             RollerRequest rreq = new RollerRequest(strutsModule.getMockPageContext());
-            rreq.setWebsite(mWebsite);
+            rreq.setWebsite(testWeblog);
             strutsModule.setRequestAttribute(RollerRequest.ROLLER_REQUEST, rreq);
-            strutsModule.actionPerform(WeblogEntryFormAction.class, form);        
+            strutsModule.actionPerform(WeblogEntryFormAction.class, form);
         } catch (Throwable t) {
             t.printStackTrace();
             fail();
@@ -88,16 +120,14 @@
         verifyPageContext();
     }
     
-    protected void verifyPageContext() 
-    {
+    protected void verifyPageContext() {
         HttpServletRequest req = (HttpServletRequest)
-            servletModule.getFilteredRequest();
+        servletModule.getFilteredRequest();
         assertNotNull(req.getAttribute("model"));
     }
-
-    public static Test suite() 
-    {
+    
+    public static Test suite() {
         return new TestSuite(WeblogEntryActionTest.class);
     }
-
+    
 }

Modified: incubator/roller/branches/roller_3.0/tests/org/apache/roller/ui/rendering/velocity/plugins/smileys/SmileysTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/tests/org/apache/roller/ui/rendering/velocity/plugins/smileys/SmileysTest.java?rev=417044&r1=417043&r2=417044&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/tests/org/apache/roller/ui/rendering/velocity/plugins/smileys/SmileysTest.java (original)
+++ incubator/roller/branches/roller_3.0/tests/org/apache/roller/ui/rendering/velocity/plugins/smileys/SmileysTest.java Sun Jun 25 12:33:50 2006
@@ -1,70 +1,96 @@
 /*
-* 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.
-*/
+ * 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.
+ */
 /*
  * Created on Jun 8, 2004
  */
 package org.apache.roller.ui.rendering.velocity.plugins.smileys;
 
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.apache.roller.ui.core.MockRollerRequest;
-import org.apache.roller.ui.rendering.velocity.VelocityServletTestBase;
 
 import com.mockrunner.mock.web.MockHttpServletRequest;
 import com.mockrunner.mock.web.MockServletContext;
-import org.apache.roller.presentation.velocity.plugins.smileys.*;
+
+import junit.framework.Test;
+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.pojos.UserData;
+import org.apache.roller.pojos.WebsiteData;
+import org.apache.roller.presentation.velocity.plugins.smileys.SmileysPlugin;
+import org.apache.roller.ui.authoring.struts.actions.WeblogEntryActionTest;
+import org.apache.roller.ui.ServletTestBase;
 
 /**
  * @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");
-       
+public class SmileysTest extends ServletTestBase {
+    private WebsiteData testWeblog = null;
+    private UserData testUser = null;
+    public static Log log = LogFactory.getLog(WeblogEntryActionTest.class);
+    
+    /**
+     * All tests in this suite require a user and a weblog.
+     */
+    public void setUp() throws Exception {
+        super.setUp();
+        try {
+            testUser = TestUtils.setupUser("bkmrkTestUser");
+            testWeblog = TestUtils.setupWeblog("bkmrkTestWeblog", testUser);
+            TestUtils.endSession(true);
+        } catch (Exception ex) {
+            log.error(ex);
+            throw new Exception("Test setup failed", ex);
+        }
+    }
+    
+    public void tearDown() throws Exception {
+        super.tearDown();
+        try {
+            TestUtils.teardownWeblog(testWeblog.getId());
+            TestUtils.teardownUser(testUser.getId());
+            TestUtils.endSession(true);
+        } catch (Exception ex) {
+            log.error(ex);
+            throw new Exception("Test teardown failed", ex);
+        }
+    }
+    
+    public void testSmileEmoticon() throws Exception {
         doFilters();
-
+        
         SmileysPlugin plugin = new SmileysPlugin();
-        plugin.init(mWebsite, null);
+        plugin.init(testWeblog, 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 expected =
+                "put on a happy <img src=\"http://localhost:8080/roller/images/smileys/smile.gif" +
+                "\" class=\"smiley\" alt=\":-)\" title=\":-)\" /> face";
         String result = plugin.render(null, test);
-        //System.out.println(result);
         assertEquals(expected, result);
     }
-        
-    public SmileysTest()
-    {
+    
+    public SmileysTest() {
         super();
     }
-
-    public static Test suite() 
-    {
+    
+    public static Test suite() {
         return new TestSuite(SmileysTest.class);
     }
 }

Modified: incubator/roller/branches/roller_3.0/tests/org/apache/roller/ui/rendering/velocity/plugins/textile/TextileTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/tests/org/apache/roller/ui/rendering/velocity/plugins/textile/TextileTest.java?rev=417044&r1=417043&r2=417044&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/tests/org/apache/roller/ui/rendering/velocity/plugins/textile/TextileTest.java (original)
+++ incubator/roller/branches/roller_3.0/tests/org/apache/roller/ui/rendering/velocity/plugins/textile/TextileTest.java Sun Jun 25 12:33:50 2006
@@ -1 +1 @@
-/*
* 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.
*/
/*
 * Created on Oct 31, 2003
 */
package org.apache.roller.ui.rendering.velocity.plugins.textile;

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

import org.apache.roller.ui.authoring.struts.actions.BookmarksActionTest;
import org.apache.roller.model.WeblogEntryPlugin;import org.apache.roller.presentation.velocity.plugins.textile.*;

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()
    {
        WeblogEntryPlugin textile = new TextilePlugin();
        
        String result = textile.render(null, 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
+/*
 * 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.
 */
/*
 * Created on Oct 31, 2003
 */
package org.apache.roller.ui.rendering.velocity.plugins.textile;

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

import org.apache.roller.model.WeblogEntryPlugin;

import org.apache.roller.presentation.velocity.plugins.textile.TextilePlugin;

import org.apache.roller.ui.authoring.struts.actions.BookmarksActionTest;

/**
 * Text textile plugin, current fails due to Textile4J bug.
 */
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() {
        WeblogEntryPlugin textile = new TextilePlugin();        
        String result = textile.render(null, textileStr);
        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

Copied: incubator/roller/branches/roller_3.0/tests/org/apache/roller/util/BlacklistTest.java (from r416919, incubator/roller/branches/roller_3.0/tests/org/apache/roller/BlacklistTest.java)
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/tests/org/apache/roller/util/BlacklistTest.java?p2=incubator/roller/branches/roller_3.0/tests/org/apache/roller/util/BlacklistTest.java&p1=incubator/roller/branches/roller_3.0/tests/org/apache/roller/BlacklistTest.java&r1=416919&r2=417044&rev=417044&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/tests/org/apache/roller/BlacklistTest.java (original)
+++ incubator/roller/branches/roller_3.0/tests/org/apache/roller/util/BlacklistTest.java Sun Jun 25 12:33:50 2006
@@ -18,13 +18,12 @@
 /*
  * Created on Nov 12, 2003
  */
-package org.apache.roller;
+package org.apache.roller.util;
 
 import java.io.File;
 
 import org.apache.roller.business.FileManagerTest;
 import org.apache.roller.config.RollerConfig;
-import org.apache.roller.util.Blacklist;
 
 import junit.framework.Test;
 import junit.framework.TestCase;

Modified: incubator/roller/branches/roller_3.0/tests/org/apache/roller/webservices/xmlrpc/RollerXmlRpcServerTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/tests/org/apache/roller/webservices/xmlrpc/RollerXmlRpcServerTest.java?rev=417044&r1=417043&r2=417044&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/tests/org/apache/roller/webservices/xmlrpc/RollerXmlRpcServerTest.java (original)
+++ incubator/roller/branches/roller_3.0/tests/org/apache/roller/webservices/xmlrpc/RollerXmlRpcServerTest.java Sun Jun 25 12:33:50 2006
@@ -1,20 +1,20 @@
 /*
-* 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.
-*/
+ * 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.
+ */
 /*
  * Created on Jun 15, 2004
  */
@@ -26,9 +26,8 @@
 import com.mockrunner.mock.web.WebMockObjectFactory;
 import com.mockrunner.servlet.ServletTestModule;
 
-import org.apache.roller.RollerTestBase;
-import org.apache.roller.util.RegexUtil;
- 
+import java.sql.Timestamp;
+
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
@@ -36,18 +35,30 @@
 import java.util.regex.Pattern;
 
 import junit.framework.Test;
+import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import org.apache.roller.ui.core.MockRollerContext;
+
+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.pojos.UserData;
+import org.apache.roller.pojos.WeblogEntryData;
+import org.apache.roller.pojos.WebsiteData;
+import org.apache.roller.ui.MockRollerContext;
 import org.apache.roller.ui.core.RollerRequest;
+import org.apache.roller.util.RegexUtil;
 
 /**
  * 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
-{
+public class RollerXmlRpcServerTest extends TestCase {
+    public static Log log = LogFactory.getLog(RollerXmlRpcServerTest.class);
+    UserData testUser = null;
+    WebsiteData testWeblog = null;
     private static HashMap typeMap = new HashMap();
     static {
         typeMap.put(Boolean.class, "boolean");
@@ -55,61 +66,55 @@
         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()
-    {
+    
+    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(testWeblog.getHandle()); // blogid
+        params.add(testUser.getUserName()); // userid
+        params.add(testUser.getPassword()); // 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);
+        assertTrue(responseBody,
+            responseBody.indexOf("<name>faultCode</name>") == -1);
         
         // make sure all/any userids returned belong to our test user
-        Pattern userPattern = 
+        Pattern userPattern =
                 Pattern.compile("<name>userid</name><value>(.*?)</value>");
         ArrayList users = RegexUtil.getMatches(userPattern, responseBody, 1);
         Iterator it = users.iterator();
-        while (it.hasNext()) 
-        {
+        while (it.hasNext()) {
             String user = (String)it.next();
             //System.out.println(user);
-            if (user.equals("testuser0"))
-            {
+            if (user.equals(testUser.getUserName())) {
                 continue;
-            }
-            else
-            {
-                fail("getRecentPosts() returned entry for a user [" 
-                        + user + "] other than " + testUsername);
+            } else {
+                fail("getRecentPosts() returned entry for a user ["
+                        + user + "] other than " + testUser.getUserName());
             }
         }
     }
     
     /**
      * Build an XML-RPC message from methodName and params.
-     * 
+     *
      * @param methodName
      * @param params
      * @return
      */
-    private String buildXmlRpcString(String methodName, ArrayList params)
-    {
+    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>");
@@ -119,14 +124,11 @@
             buf.append("<param><value>");
             Object param = it.next();
             String paramType = (String)typeMap.get(param.getClass());
-            if (paramType != null)
-            {
+            if (paramType != null) {
                 buf.append("<").append(paramType).append(">")
-                   .append(param)
-                   .append("</").append(paramType).append(">");                    
-            }
-            else
-            {    
+                .append(param)
+                .append("</").append(paramType).append(">");
+            } else {
                 buf.append("<string>").append(param).append("</string>");
             }
             buf.append("</value></param>");
@@ -137,43 +139,97 @@
     }
     
     //-----------------------------------------------------------------------
-    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);
+    
+    /**
+     * All tests in this suite require a user and a weblog.
+     */
+    public void setUp() throws Exception {
+        
+        try {
+            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);
+        
+            testUser = TestUtils.setupUser("entryTestUser");
+            testWeblog = TestUtils.setupWeblog("entryTestWeblog", testUser);
+            
+            WeblogEntryData testEntry1 = new WeblogEntryData();
+            testEntry1.setTitle("entryTestEntry1");
+            testEntry1.setLink("testEntryLink1");
+            testEntry1.setText("blah blah entry1");
+            testEntry1.setAnchor("testEntryAnchor1");
+            testEntry1.setPubTime(new Timestamp(new Date().getTime()));
+            testEntry1.setUpdateTime(new Timestamp(new Date().getTime()));
+            testEntry1.setWebsite(testWeblog);
+            testEntry1.setCreator(testUser);
+            testEntry1.setCategory(testWeblog.getDefaultCategory());
+            RollerFactory.getRoller().getWeblogManager().saveWeblogEntry(testEntry1);
+
+            WeblogEntryData testEntry2 = new WeblogEntryData();
+            testEntry2.setTitle("entryTestEntry2");
+            testEntry2.setLink("testEntryLink2");
+            testEntry2.setText("blah blah entry2");
+            testEntry2.setAnchor("testEntryAnchor2");
+            testEntry2.setPubTime(new Timestamp(new Date().getTime()));
+            testEntry2.setUpdateTime(new Timestamp(new Date().getTime()));
+            testEntry2.setWebsite(testWeblog);
+            testEntry2.setCreator(testUser);
+            testEntry2.setCategory(testWeblog.getDefaultCategory());
+            RollerFactory.getRoller().getWeblogManager().saveWeblogEntry(testEntry1);
+
+            WeblogEntryData testEntry3 = new WeblogEntryData();
+            testEntry3.setTitle("entryTestEntry3");
+            testEntry3.setLink("testEntryLink3");
+            testEntry3.setText("blah blah entry3");
+            testEntry3.setAnchor("testEntryAnchor3");
+            testEntry3.setPubTime(new Timestamp(new Date().getTime()));
+            testEntry3.setUpdateTime(new Timestamp(new Date().getTime()));
+            testEntry3.setWebsite(testWeblog);
+            testEntry3.setCreator(testUser);
+            testEntry3.setCategory(testWeblog.getDefaultCategory());           
+            RollerFactory.getRoller().getWeblogManager().saveWeblogEntry(testEntry1);
+
+            TestUtils.endSession(true);
+            
+        } catch (Exception ex) {
+            log.error(ex);
+            throw new Exception("Test setup failed", ex);
+        }
     }
-
-    //-----------------------------------------------------------------------
-    public void tearDown() throws Exception
-    {
-        super.tearDown();
-        mockRequest = null;
-        servletTestModule.clearOutput();
-        servletTestModule.releaseFilters();
-        servletTestModule = null;
-        rollerContext = null;
-        mockFactory = null;
+    
+    public void tearDown() throws Exception {
+        
+        try {
+            TestUtils.teardownWeblog(testWeblog.getId());
+            TestUtils.teardownUser(testUser.getId());
+            TestUtils.endSession(true);
+            
+            mockRequest = null;
+            servletTestModule.clearOutput();
+            servletTestModule.releaseFilters();
+            servletTestModule = null;
+            rollerContext = null;
+            mockFactory = null;
+        
+        } catch (Exception ex) {
+            log.error(ex);
+            throw new Exception("Test teardown failed", ex);
+        }
     }
-
-    public static Test suite() 
-    {
+    
+    public static Test suite() {
         return new TestSuite(RollerXmlRpcServerTest.class);
     }
 }

Modified: incubator/roller/branches/roller_3.0/web/WEB-INF/classes/ApplicationResources.properties
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/web/WEB-INF/classes/ApplicationResources.properties?rev=417044&r1=417043&r2=417044&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/web/WEB-INF/classes/ApplicationResources.properties (original)
+++ incubator/roller/branches/roller_3.0/web/WEB-INF/classes/ApplicationResources.properties Sun Jun 25 12:33:50 2006
@@ -275,7 +275,8 @@
 these are <i>runtime</i> properties only. Please refer to the Roller documentation \
 for information on overriding Roller's <i>startup</i> properties (in the \
 roller.properties file).
-
+configForm.frontpageWeblogHandle=Handle of weblog to serve as frontpage blog
+configForm.frontpageWeblogAggregated=Enable aggregated frontpage feeds
 configForm.siteSettings=Site Settings
 configForm.siteName=Site Name (for main page and RSS feed)
 configForm.shortName=Short name (shown in site banner)

Modified: incubator/roller/branches/roller_3.0/web/WEB-INF/classes/roller.properties
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/web/WEB-INF/classes/roller.properties?rev=417044&r1=417043&r2=417044&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/web/WEB-INF/classes/roller.properties (original)
+++ incubator/roller/branches/roller_3.0/web/WEB-INF/classes/roller.properties Sun Jun 25 12:33:50 2006
@@ -48,15 +48,6 @@
 groupblogging.enabled=true
 
 #---------------------------------
-# Front-page blog settings
-
-# Handle of weblog that is to serve as the main page of the site
-frontpage.weblog.handle=main
-
-# True if front page weblog feeds should be site-wide
-frontpage.weblog.aggregatedFeeds=true
-
-#---------------------------------
 # Property expansion settings
 
 # Values of the properties in this list get system property expansion 

Modified: incubator/roller/branches/roller_3.0/web/WEB-INF/classes/rollerRuntimeConfigDefs.xml
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/web/WEB-INF/classes/rollerRuntimeConfigDefs.xml?rev=417044&r1=417043&r2=417044&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/web/WEB-INF/classes/rollerRuntimeConfigDefs.xml (original)
+++ incubator/roller/branches/roller_3.0/web/WEB-INF/classes/rollerRuntimeConfigDefs.xml Sun Jun 25 12:33:50 2006
@@ -59,6 +59,14 @@
       <property-def  name="site.description"  key="configForm.siteDescription">
          <type>string</type>
 	     <default-value>A default install of the Roller Weblogger open source blog server</default-value>
+      </property-def>      
+      <property-def  name="site.frontpage.weblog.handle"  key="configForm.frontpageWeblogHandle">
+         <type>string</type>
+         <default-value></default-value>
+      </property-def>      
+      <property-def  name="site.frontpage.weblog.aggregated"  key="configForm.frontpageWeblogAggregated">
+         <type>string</type>
+         <default-value>false</default-value>
       </property-def>
       <property-def  name="site.adminemail"  key="configForm.siteAdminEmail">
          <type>string</type>