roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r395325 - in /incubator/roller/branches/roller-newbackend: src/org/roller/business/hibernate/ src/org/roller/model/ src/org/roller/presentation/website/actions/ tests/org/roller/ tests/org/roller/business/
Date Wed, 19 Apr 2006 18:00:51 GMT
Author: agilliland
Date: Wed Apr 19 11:00:49 2006
New Revision: 395325

URL: http://svn.apache.org/viewcvs?rev=395325&view=rev
Log:
manager method name refactorings for PropertiesManager.

storeXXX() -> saveXXX()
retrieveXXX() -> getXXX()
createXXX() -> addXXX() (or is removed)


Modified:
    incubator/roller/branches/roller-newbackend/src/org/roller/business/hibernate/HibernatePropertiesManagerImpl.java
    incubator/roller/branches/roller-newbackend/src/org/roller/model/PropertiesManager.java
    incubator/roller/branches/roller-newbackend/src/org/roller/presentation/website/actions/RollerPropertiesAction.java
    incubator/roller/branches/roller-newbackend/tests/org/roller/RollerTestBase.java
    incubator/roller/branches/roller-newbackend/tests/org/roller/business/FileManagerTest.java
    incubator/roller/branches/roller-newbackend/tests/org/roller/business/PropertiesTest.java
    incubator/roller/branches/roller-newbackend/tests/org/roller/business/RefererManagerTest.java

Modified: incubator/roller/branches/roller-newbackend/src/org/roller/business/hibernate/HibernatePropertiesManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/business/hibernate/HibernatePropertiesManagerImpl.java?rev=395325&r1=395324&r2=395325&view=diff
==============================================================================
--- incubator/roller/branches/roller-newbackend/src/org/roller/business/hibernate/HibernatePropertiesManagerImpl.java
(original)
+++ incubator/roller/branches/roller-newbackend/src/org/roller/business/hibernate/HibernatePropertiesManagerImpl.java
Wed Apr 19 11:00:49 2006
@@ -105,7 +105,7 @@
     /**
      * Save a single property.
      */
-    public void store(RollerPropertyData property) throws RollerException {
+    public void saveProperty(RollerPropertyData property) throws RollerException {
         
         this.strategy.store(property);
     }
@@ -114,9 +114,9 @@
     /**
      * Save all properties.
      */
-    public void store(Map properties) throws RollerException {
+    public void saveProperties(Map properties) throws RollerException {
         
-        // just go through the list and store each property
+        // just go through the list and saveProperties each property
         Iterator props = properties.values().iterator();
         while (props.hasNext()) {
             this.strategy.store((RollerPropertyData) props.next());
@@ -139,7 +139,7 @@
             }
             
             // save our changes
-            this.store(props);
+            this.saveProperties(props);
         } catch (Exception e) {
             log.fatal("Failed to initialize runtime configuration properties."+
                     "Please check that the database has been upgraded!", e);

Modified: incubator/roller/branches/roller-newbackend/src/org/roller/model/PropertiesManager.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/model/PropertiesManager.java?rev=395325&r1=395324&r2=395325&view=diff
==============================================================================
--- incubator/roller/branches/roller-newbackend/src/org/roller/model/PropertiesManager.java
(original)
+++ incubator/roller/branches/roller-newbackend/src/org/roller/model/PropertiesManager.java
Wed Apr 19 11:00:49 2006
@@ -6,15 +6,15 @@
 
 package org.roller.model;
 
-import java.io.Serializable;
 import java.util.Map;
 import org.roller.RollerException;
 import org.roller.pojos.RollerPropertyData;
 
+
 /**
  * Manages global properties for Roller.
  */
-public interface PropertiesManager extends Serializable {
+public interface PropertiesManager {
     
     /**
      * Release all resources associated with Roller session.
@@ -25,13 +25,13 @@
     /** 
      * Save a single property 
      */
-    public void store(RollerPropertyData property) throws RollerException;
+    public void saveProperty(RollerPropertyData property) throws RollerException;
     
     
     /** 
      * Save a list of properties 
      */
-    public void store(Map properties) throws RollerException;
+    public void saveProperties(Map properties) throws RollerException;
     
     
     /** 

Modified: incubator/roller/branches/roller-newbackend/src/org/roller/presentation/website/actions/RollerPropertiesAction.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/presentation/website/actions/RollerPropertiesAction.java?rev=395325&r1=395324&r2=395325&view=diff
==============================================================================
--- incubator/roller/branches/roller-newbackend/src/org/roller/presentation/website/actions/RollerPropertiesAction.java
(original)
+++ incubator/roller/branches/roller-newbackend/src/org/roller/presentation/website/actions/RollerPropertiesAction.java
Wed Apr 19 11:00:49 2006
@@ -160,7 +160,7 @@
                 }
                 
                 // save it
-                propsManager.store(props);
+                propsManager.saveProperties(props);
                 RollerFactory.getRoller().flush();
                 
                 // this operation causes OutOfMemory exceptions on sites with 

Modified: incubator/roller/branches/roller-newbackend/tests/org/roller/RollerTestBase.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/tests/org/roller/RollerTestBase.java?rev=395325&r1=395324&r2=395325&view=diff
==============================================================================
--- incubator/roller/branches/roller-newbackend/tests/org/roller/RollerTestBase.java (original)
+++ incubator/roller/branches/roller-newbackend/tests/org/roller/RollerTestBase.java Wed Apr
19 11:00:49 2006
@@ -125,7 +125,7 @@
         RollerPropertyData prop =
                 (RollerPropertyData)props.get("site.absoluteurl");
         prop.setValue("http://localhost:8080/roller");
-        propmgr.store(props);
+        propmgr.saveProperties(props);
         
         PlanetManager planet = getRoller().getPlanetManager();
         PlanetConfigData config = config = new PlanetConfigData();

Modified: incubator/roller/branches/roller-newbackend/tests/org/roller/business/FileManagerTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/tests/org/roller/business/FileManagerTest.java?rev=395325&r1=395324&r2=395325&view=diff
==============================================================================
--- incubator/roller/branches/roller-newbackend/tests/org/roller/business/FileManagerTest.java
(original)
+++ incubator/roller/branches/roller-newbackend/tests/org/roller/business/FileManagerTest.java
Wed Apr 19 11:00:49 2006
@@ -71,7 +71,7 @@
         ((RollerPropertyData)config.get("uploads.enabled")).setValue("false");
         ((RollerPropertyData)config.get("uploads.types.forbid")).setValue("gif");
         ((RollerPropertyData)config.get("uploads.dir.maxsize")).setValue("1.00");
-        pmgr.store(config);
+        pmgr.saveProperties(config);
         TestUtils.endSession(true);
         
         // test quota functionality
@@ -89,7 +89,7 @@
         ((RollerPropertyData)config.get("uploads.enabled")).setValue("true");
         ((RollerPropertyData)config.get("uploads.types.allowed")).setValue("opml");
         ((RollerPropertyData)config.get("uploads.dir.maxsize")).setValue("1.00");
-        pmgr.store(config);
+        pmgr.saveProperties(config);
         TestUtils.endSession(true);
         
         /* NOTE: upload dir for unit tests is set in

Modified: incubator/roller/branches/roller-newbackend/tests/org/roller/business/PropertiesTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/tests/org/roller/business/PropertiesTest.java?rev=395325&r1=395324&r2=395325&view=diff
==============================================================================
--- incubator/roller/branches/roller-newbackend/tests/org/roller/business/PropertiesTest.java
(original)
+++ incubator/roller/branches/roller-newbackend/tests/org/roller/business/PropertiesTest.java
Wed Apr 19 11:00:49 2006
@@ -61,7 +61,7 @@
         
         // update a property
         prop.setValue("testtest");
-        mgr.store(prop);
+        mgr.saveProperty(prop);
         TestUtils.endSession(true);
         
         // make sure property was updated
@@ -80,7 +80,7 @@
         prop.setValue("foofoo");
         prop = (RollerPropertyData) props.get("site.description");
         prop.setValue("blahblah");
-        mgr.store(props);
+        mgr.saveProperties(props);
         TestUtils.endSession(true);
         
         // make sure all properties were updated

Modified: incubator/roller/branches/roller-newbackend/tests/org/roller/business/RefererManagerTest.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/tests/org/roller/business/RefererManagerTest.java?rev=395325&r1=395324&r2=395325&view=diff
==============================================================================
--- incubator/roller/branches/roller-newbackend/tests/org/roller/business/RefererManagerTest.java
(original)
+++ incubator/roller/branches/roller-newbackend/tests/org/roller/business/RefererManagerTest.java
Wed Apr 19 11:00:49 2006
@@ -1 +1 @@
-package org.roller.business;

import java.sql.Timestamp;
import java.util.Calendar;
import
java.util.Date;
import java.util.List;
import junit.framework.Test;
import junit.framework.TestCase;
import
junit.framework.TestSuite;import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import
org.roller.RollerException;
import org.roller.model.PropertiesManager;
import org.roller.model.RefererManager;
import
org.roller.pojos.RollerPropertyData;
import org.roller.pojos.UserData;
import org.roller.pojos.WebsiteData;
import
org.roller.util.DateUtil;
import org.roller.TestUtils;
import org.roller.model.RollerFactory;
import
org.roller.model.UserManager;


/**
 * Test Roller Referer Management.
 */
public class RefererManagerTest
extends TestCase {
    
    public static Log log = LogFactory.getLog(RefererManagerTest.class);
   
    UserData testUser = null;
    WebsiteData testWeblog = null;
    
    int count =
20;
    String testDay;
    String origSpa
 mWords;
    
    
    public RefererManagerTest(String name) {
        super(name);
    }
   
    
    public static Test suite() {
        return new TestSuite(RefererManagerTest.class);
   }
    
    
    /**
     * All tests in this suite require a user and a weblog.
     */
   public void setUp() throws Exception {
        
        try {
            testUser = TestUtils.setupUser("referTestUser");
           testWeblog = TestUtils.setupWeblog("referTestWeblog", testUser);
            
           // add "spamtest" to refererSpamWords
            PropertiesManager pmgr = RollerFactory.getRoller().getPropertiesManager();
           RollerPropertyData spamprop = pmgr.getProperty("spam.blacklist");
            this.origSpamWords
= spamprop.getValue();
            spamprop.setValue(spamprop.getValue() + ", spamtest");
           pmgr.store(spamprop);
            
            // add a number of referers to play
with
            RefererManager rmgr = RollerFactory.getRoll
 er().getRefererManager();
            Calendar lCalendar = Calendar.getInstance();
     
      lCalendar.setTime(new Date());
            for (int i = 0; i < count; i++) {
   
            lCalendar.add(Calendar.DATE, -1);
                Timestamp day = new Timestamp(lCalendar.getTime().getTime());
               testDay = DateUtil.format8chars(day);
                
                rmgr.processReferrer("http://test"+i,
"http://test"+i,
                        testWeblog.getHandle(), null, testDay);
        
   }
            
            TestUtils.endSession(true);
            
        } catch (Exception
ex){
            log.error(ex);
            throw new Exception("Test setup failed", ex);
       }
    }
    
    public void tearDown() throws Exception {
        
        try {
           // reset refererSpamWords to original value
            PropertiesManager pmgr
= RollerFactory.getRoller().getPropertiesManager();
            RollerPropertyData spamprop
= pmgr.getPro
 perty("spam.blacklist");
            spamprop.setValue(this.origSpamWords);
            pmgr.store(spamprop);
           
            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 testGetReferersToDate() throws Exception {
        
  
     RefererManager rmgr = RollerFactory.getRoller().getRefererManager();
        
      
 List referers = rmgr.getReferersToDate(testWeblog, testDay);
        assertEquals("Should
be one Referer.", referers.size(), 1);
    }
    
    
    public void testRefererProcessing()
throws RollerException {
        
        RefererManager rmgr = RollerFactory.getRoller().getRefererManager();
       
        List refs = rmgr.getReferers(testWeblog);
        assertEquals("number of
refer
 ers should equal count", count, refs.size());
        
        int hits = rmgr.getDayHits(testWeblog);
       assertEquals("There should be one fewer hits than referers", count, hits);
    }
 
  
    
    public void testApplyRefererFilters() throws Exception {
        
        log.info("Test
apply referers (global)");
        
        RefererManager rmgr = RollerFactory.getRoller().getRefererManager();
       
        List refs = rmgr.getReferers(testWeblog);
        assertEquals(count, refs.size());
       
        PropertiesManager pmgr = RollerFactory.getRoller().getPropertiesManager();
       RollerPropertyData spamprop = pmgr.getProperty("spam.blacklist");
        String origWords
= spamprop.getValue();
        spamprop.setValue(spamprop.getValue() + ", test");
       
pmgr.store(spamprop);
        TestUtils.endSession(true);
        
        rmgr.applyRefererFilters();
       TestUtils.endSession(true);
        
        refs = rmgr.getReferers(testWeblog);
     
   assertEquals(0, refs.size());
        
        spamprop = pmgr.getProperty("spam.blacklist");
       spamprop.setValue(origWords);
        pmgr.store(spamprop);
        TestUtils.endSession(true);
   }
    
    
    public void testApplyRefererFiltersWebsite() throws Exception {
      
 
        log.info("Test apply referers (weblog)");
        
        RefererManager rmgr =
RollerFactory.getRoller().getRefererManager();
        
        List refs = rmgr.getReferers(testWeblog);
       assertEquals(count, refs.size());
        String origWords = null;
        
      
 UserManager umgr = RollerFactory.getRoller().getUserManager();
        testWeblog = umgr.getWebsite(testWeblog.getId());
       origWords = testWeblog.getBlacklist();
        testWeblog.setBlacklist("test");
  
     umgr.saveWebsite(testWeblog);
        TestUtils.endSession(true);
        
        rmgr.applyRefererFilters();
       TestUtils.endSession(true);
        
        refs = rmgr.getReferers(test
 Weblog);
        assertEquals(0, refs.size());
    }
    
}
\ No newline at end of file
+package org.roller.business;

import java.sql.Timestamp;
import java.util.Calendar;
import
java.util.Date;
import java.util.List;
import junit.framework.Test;
import junit.framework.TestCase;
import
junit.framework.TestSuite;import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import
org.roller.RollerException;
import org.roller.model.PropertiesManager;
import org.roller.model.RefererManager;
import
org.roller.pojos.RollerPropertyData;
import org.roller.pojos.UserData;
import org.roller.pojos.WebsiteData;
import
org.roller.util.DateUtil;
import org.roller.TestUtils;
import org.roller.model.RollerFactory;
import
org.roller.model.UserManager;


/**
 * Test Roller Referer Management.
 */
public class RefererManagerTest
extends TestCase {
    
    public static Log log = LogFactory.getLog(RefererManagerTest.class);
   
    UserData testUser = null;
    WebsiteData testWeblog = null;
    
    int count =
20;
    String testDay;
    String origSpa
 mWords;
    
    
    public RefererManagerTest(String name) {
        super(name);
    }
   
    
    public static Test suite() {
        return new TestSuite(RefererManagerTest.class);
   }
    
    
    /**
     * All tests in this suite require a user and a weblog.
     */
   public void setUp() throws Exception {
        
        try {
            testUser = TestUtils.setupUser("referTestUser");
           testWeblog = TestUtils.setupWeblog("referTestWeblog", testUser);
            
           // add "spamtest" to refererSpamWords
            PropertiesManager pmgr = RollerFactory.getRoller().getPropertiesManager();
           RollerPropertyData spamprop = pmgr.getProperty("spam.blacklist");
            this.origSpamWords
= spamprop.getValue();
            spamprop.setValue(spamprop.getValue() + ", spamtest");
           pmgr.saveProperty(spamprop);
            
            // add a number of referers
to play with
            RefererManager rmgr = RollerFactory.
 getRoller().getRefererManager();
            Calendar lCalendar = Calendar.getInstance();
           lCalendar.setTime(new Date());
            for (int i = 0; i < count; i++) {
               lCalendar.add(Calendar.DATE, -1);
                Timestamp day = new Timestamp(lCalendar.getTime().getTime());
               testDay = DateUtil.format8chars(day);
                
                rmgr.processReferrer("http://test"+i,
"http://test"+i,
                        testWeblog.getHandle(), null, testDay);
        
   }
            
            TestUtils.endSession(true);
            
        } catch (Exception
ex){
            log.error(ex);
            throw new Exception("Test setup failed", ex);
       }
    }
    
    public void tearDown() throws Exception {
        
        try {
           // reset refererSpamWords to original value
            PropertiesManager pmgr
= RollerFactory.getRoller().getPropertiesManager();
            RollerPropertyData spamprop
= pmgr
 .getProperty("spam.blacklist");
            spamprop.setValue(this.origSpamWords);
     
      pmgr.saveProperty(spamprop);
            
            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 testGetReferersToDate() throws
Exception {
        
        RefererManager rmgr = RollerFactory.getRoller().getRefererManager();
       
        List referers = rmgr.getReferersToDate(testWeblog, testDay);
        assertEquals("Should
be one Referer.", referers.size(), 1);
    }
    
    
    public void testRefererProcessing()
throws RollerException {
        
        RefererManager rmgr = RollerFactory.getRoller().getRefererManager();
       
        List refs = rmgr.getReferers(testWeblog);
        assertEquals("n
 umber of referers should equal count", count, refs.size());
        
        int hits = rmgr.getDayHits(testWeblog);
       assertEquals("There should be one fewer hits than referers", count, hits);
    }
 
  
    
    public void testApplyRefererFilters() throws Exception {
        
        log.info("Test
apply referers (global)");
        
        RefererManager rmgr = RollerFactory.getRoller().getRefererManager();
       
        List refs = rmgr.getReferers(testWeblog);
        assertEquals(count, refs.size());
       
        PropertiesManager pmgr = RollerFactory.getRoller().getPropertiesManager();
       RollerPropertyData spamprop = pmgr.getProperty("spam.blacklist");
        String origWords
= spamprop.getValue();
        spamprop.setValue(spamprop.getValue() + ", test");
       
pmgr.saveProperty(spamprop);
        TestUtils.endSession(true);
        
        rmgr.applyRefererFilters();
       TestUtils.endSession(true);
        
        refs = rmgr.getReferer
 s(testWeblog);
        assertEquals(0, refs.size());
        
        spamprop = pmgr.getProperty("spam.blacklist");
       spamprop.setValue(origWords);
        pmgr.saveProperty(spamprop);
        TestUtils.endSession(true);
   }
    
    
    public void testApplyRefererFiltersWebsite() throws Exception {
      
 
        log.info("Test apply referers (weblog)");
        
        RefererManager rmgr =
RollerFactory.getRoller().getRefererManager();
        
        List refs = rmgr.getReferers(testWeblog);
       assertEquals(count, refs.size());
        String origWords = null;
        
      
 UserManager umgr = RollerFactory.getRoller().getUserManager();
        testWeblog = umgr.getWebsite(testWeblog.getId());
       origWords = testWeblog.getBlacklist();
        testWeblog.setBlacklist("test");
  
     umgr.saveWebsite(testWeblog);
        TestUtils.endSession(true);
        
        rmgr.applyRefererFilters();
       TestUtils.endSession(true);
        
        
 refs = rmgr.getReferers(testWeblog);
        assertEquals(0, refs.size());
    }
    
}
\ No newline at end of file



Mime
View raw message