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 2005/12/19 03:49:15 UTC

svn commit: r357619 - in /incubator/roller/trunk: src/org/roller/business/PlanetManagerImpl.java src/org/roller/config/RollerConfig.java tests/org/roller/business/PlanetManagerTest.java

Author: snoopdave
Date: Sun Dec 18 18:49:12 2005
New Revision: 357619

URL: http://svn.apache.org/viewcvs?rev=357619&view=rev
Log:
Even more unit test fixes

Modified:
    incubator/roller/trunk/src/org/roller/business/PlanetManagerImpl.java
    incubator/roller/trunk/src/org/roller/config/RollerConfig.java
    incubator/roller/trunk/tests/org/roller/business/PlanetManagerTest.java

Modified: incubator/roller/trunk/src/org/roller/business/PlanetManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/business/PlanetManagerImpl.java?rev=357619&r1=357618&r2=357619&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/business/PlanetManagerImpl.java (original)
+++ incubator/roller/trunk/src/org/roller/business/PlanetManagerImpl.java Sun Dec 18 18:49:12 2005
@@ -1,16 +1,18 @@
 package org.roller.business;
 
 import java.net.URL;
+import java.text.MessageFormat;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.Set;
 import java.util.TreeSet;
-import java.text.MessageFormat;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.roller.RollerException;
+import org.roller.config.RollerRuntimeConfig;
 import org.roller.model.PlanetManager;
 import org.roller.model.Roller;
 import org.roller.pojos.PlanetConfigData;
@@ -24,7 +26,6 @@
 import com.sun.syndication.fetcher.impl.FeedFetcherCache;
 import com.sun.syndication.fetcher.impl.HttpURLFeedFetcher;
 import com.sun.syndication.fetcher.impl.SyndFeedInfo;
-import org.roller.config.RollerRuntimeConfig;
 
 /**
  * Base class for PlanetManager implementations.
@@ -82,7 +83,7 @@
             Set newEntries = null;
             int count = 0;
             PlanetSubscriptionData sub = (PlanetSubscriptionData)subs.next();
-            if (sub.getFeedUrl().startsWith(localURL)) {
+            if (!StringUtils.isEmpty(localURL) && sub.getFeedUrl().startsWith(localURL)) {
                 newEntries = getNewEntriesLocal(sub, feedFetcher, feedInfoCache);
             } else {
                 newEntries = getNewEntriesRemote(sub, feedFetcher, feedInfoCache);

Modified: incubator/roller/trunk/src/org/roller/config/RollerConfig.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/config/RollerConfig.java?rev=357619&r1=357618&r2=357619&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/config/RollerConfig.java (original)
+++ incubator/roller/trunk/src/org/roller/config/RollerConfig.java Sun Dec 18 18:49:12 2005
@@ -1,7 +1,4 @@
-/*
- * RollerConfig.java
- *
- */
+/* RollerConfig.java */
 
 package org.roller.config;
 
@@ -17,9 +14,7 @@
 
 
 /**
- * This is the single entry point for accessing configuration properties
- * in Roller.
- *
+ * This is the single entry point for accessing configuration properties in Roller.
  * @author Allen Gilliland
  */
 public class RollerConfig {
@@ -168,30 +163,40 @@
     /**
      * Set the "uploads.dir" property at runtime.
      *
-     * Properties are meant to be read-only, but we make this one exception
-     * for now because we know that some people are still writing their
-     * uploads to the webapp context and we can only get that path at runtime.
+     * Properties are meant to be read-only, but we make this exception because we 
+     * know that some people are still writing their uploads to the webapp context 
+     * and we can only get that path at runtime (and for unit testing).
+     * 
+     * This property is *not* persisted in any way.
      */
     public static void setUploadsDir(String path) {
-
         // only do this if the user wants to use the webapp context
         if("${webapp.context}".equals(mConfig.getProperty("uploads.dir")))
             mConfig.setProperty("uploads.dir", path);
     }
 
-
     /**
      * Set the "context.realpath" property at runtime.
      *
-     * Properties are meant to be read-only, but we make this one exception
-     * for now because there are some classes which rely on having filesystem
-     * access to files in the roller webapp context.
+     * Properties are meant to be read-only, but we make this  exception because 
+     * there are some classes which rely on having filesystem access to files in the 
+     * roller webapp context (and for unit testing).
      *
      * This property is *not* persisted in any way.
      */
     public static void setContextRealPath(String path) {
-
         mConfig.setProperty("context.realpath", path);
     }
     
+    /**
+     * Set the "context.realpath" property at runtime.
+     *
+     * Properties are meant to be read-only, but we make this exception to make it
+     * possible for unit tests to control the cache directory.
+     *
+     * This property is *not* persisted in any way.
+     */
+    public static void setPlanetCachePath(String path) {
+        mConfig.setProperty("planet.aggregator.cache.dir", path);
+    }
 }

Modified: incubator/roller/trunk/tests/org/roller/business/PlanetManagerTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/tests/org/roller/business/PlanetManagerTest.java?rev=357619&r1=357618&r2=357619&view=diff
==============================================================================
--- incubator/roller/trunk/tests/org/roller/business/PlanetManagerTest.java (original)
+++ incubator/roller/trunk/tests/org/roller/business/PlanetManagerTest.java Sun Dec 18 18:49:12 2005
@@ -15,6 +15,7 @@
  */
 package org.roller.business;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.Iterator;
@@ -26,6 +27,7 @@
 import junit.framework.TestSuite;
 
 import org.roller.RollerException;
+import org.roller.config.RollerConfig;
 import org.roller.model.PlanetManager;
 import org.roller.model.Roller;
 import org.roller.model.RollerFactory;
@@ -34,6 +36,7 @@
 import org.roller.pojos.PlanetGroupData;
 import org.roller.pojos.PlanetSubscriptionData;
 import org.roller.pojos.UserData;
+import org.roller.util.Blacklist;
 
 /**
  * Test database implementation of PlanetManager.
@@ -48,6 +51,18 @@
         junit.textui.TestRunner.run(PlanetManagerTest.class);
     }
 
+    /**
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();        
+        RollerConfig.setPlanetCachePath(
+            System.getProperty("ro.build") 
+            + File.separator + "tests" 
+            + File.separator + "planet-cache");
+    }
+    
     public void testConfigurationStorage() throws Exception
     {
         Roller roller = getRoller();
@@ -59,7 +74,7 @@
             roller.begin();
             
             PlanetConfigData config = new PlanetConfigData();
-            config.setCacheDir("test_cache_dir");
+            //config.setCacheDir(cacheDir);
             config.setTitle("test_title");
             config.setAdminEmail("test_admin_email");
 
@@ -270,7 +285,7 @@
             {   
                 roller.begin();
                 PlanetConfigData config = new PlanetConfigData();
-                config.setCacheDir("/tmp"); // TODO use real temp dir
+                //config.setCacheDir(cacheDir); 
                 config.setTitle("test_title");
                 config.setAdminEmail("test_admin_email");
                 planet.saveConfiguration(config);
@@ -297,7 +312,7 @@
                 
                 roller.begin();
                 PlanetSubscriptionData sub = planet.getSubscription(feed_url1);
-                assertTrue(sub.getEntries().size() > 0);
+                int entriesSize = sub.getEntries().size();
           
                 PlanetGroupData group = planet.getGroup("test_handle");
                 assertNotNull(group);
@@ -308,6 +323,8 @@
                 PlanetConfigData config = planet.getConfiguration();
                 config.remove();
                 roller.commit();
+
+                assertTrue(entriesSize > 0);
             }
         }
         catch (Exception e) 
@@ -329,7 +346,7 @@
             {   
                 roller.begin();
                 PlanetConfigData config = new PlanetConfigData();
-                config.setCacheDir("/tmp"); // TODO use real temp dir
+                //config.setCacheDir(cacheDir); 
                 config.setTitle("test_title");
                 config.setAdminEmail("test_admin_email");
                 planet.saveConfiguration(config);