portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pau...@apache.org
Subject cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/services/portletcache TestTurbineCache.java
Date Mon, 04 Feb 2002 19:54:40 GMT
paulsp      02/02/04 11:54:40

  Modified:    src/java/org/apache/jetspeed/services/portletcache
                        TestTurbineCache.java
  Log:
  Apply a Jetspeed version of the turbine patch commited by Jeff Brekke.  Below the log
  message from Jeff's commit
  
     Updated test case to work on even slower or heavily loaded machines.  This was
     not an issue with what was being tested, rather how soon the test was looking
     for information.
  
  Revision  Changes    Path
  1.4       +13 -22    jakarta-jetspeed/src/java/org/apache/jetspeed/services/portletcache/TestTurbineCache.java
  
  Index: TestTurbineCache.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/portletcache/TestTurbineCache.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestTurbineCache.java	2 Feb 2002 05:25:01 -0000	1.3
  +++ TestTurbineCache.java	4 Feb 2002 19:54:40 -0000	1.4
  @@ -72,7 +72,7 @@
    * TestTurbineCache
    *
    * @author <a href="paulsp@apache.org">Paul Spencer</a>
  - * @version $Id: TestTurbineCache.java,v 1.3 2002/02/02 05:25:01 paulsp Exp $
  + * @version $Id: TestTurbineCache.java,v 1.4 2002/02/04 19:54:40 paulsp Exp $
    */
   public class TestTurbineCache extends ServletTestCase {
       
  @@ -313,36 +313,27 @@
        */    
       
       public void testObjectCount() throws Exception {
  -        String testString = new String( "This is a test");
  -        Object retrievedObject = null;
  -        CachedObject cacheObject = null;
   
           GlobalCacheService globalCache = (GlobalCacheService)TurbineServices
           .getInstance()
           .getService( GlobalCacheService.SERVICE_NAME );
  +        assertNotNull("Could not retrive cache service.", globalCache);
           
  -        // Wait 2 Refresh to allow for remove object to be deleted
  -        Thread.sleep(TURBINE_CACHE_REFRESH * 2);
  -        assertEquals("Initial Object Count", 0, globalCache.getNumberOfObjects());
  -
  -        // Create and add Object that expires in 1 turbine Refresh + 1 millis 
  -        cacheObject = new CachedObject(testString, TURBINE_CACHE_REFRESH  + 1);
  +        // Create and add Object that expires in 1.5 turbine Refresh
  +        long expireTime = TURBINE_CACHE_REFRESH + TURBINE_CACHE_REFRESH/2;
  +        CachedObject cacheObject = new CachedObject("This is a test", expireTime);
           assertNotNull( "Failed to create a cachable object", cacheObject);
  -        long addTime = System.currentTimeMillis();
  +
           globalCache.addObject(cacheKey, cacheObject);
  -        
           assertEquals("After adding 1 Object", 1, globalCache.getNumberOfObjects());
           
  -        // Wait 1 Refresh
  -        Thread.sleep(TURBINE_CACHE_REFRESH + 1);
  -        assertEquals("After refresh", 1, globalCache.getNumberOfObjects());
  -
  -        // Wait 2 additional Refresh
  -        Thread.sleep((TURBINE_CACHE_REFRESH * 2) + 1);
  -        assertEquals("After refresh", 0, globalCache.getNumberOfObjects());
  -
  -        // Remove objects
  -        globalCache.removeObject(cacheKey);
  +        // Wait until we're passed 1 refresh, but not half way.
  +        Thread.sleep(TURBINE_CACHE_REFRESH + TURBINE_CACHE_REFRESH/3);
  +        assertEquals("After one refresh", 1, globalCache.getNumberOfObjects());
  +
  +        // Wait until we're passed 2 more refreshes
  +        Thread.sleep((TURBINE_CACHE_REFRESH * 2) + TURBINE_CACHE_REFRESH/3);
  +        assertEquals("After three refreshes", 0, globalCache.getNumberOfObjects());
       }
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <mailto:jetspeed-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:jetspeed-dev-help@jakarta.apache.org>


Mime
View raw message