You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by br...@apache.org on 2002/02/03 17:11:05 UTC

cvs commit: jakarta-turbine-2/src/rttest/org/apache/turbine/services/cache TurbineCacheTest.java

brekke      02/02/03 08:11:05

  Modified:    src/rttest/org/apache/turbine/services/cache
                        TurbineCacheTest.java
  Log:
  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.2       +12 -25    jakarta-turbine-2/src/rttest/org/apache/turbine/services/cache/TurbineCacheTest.java
  
  Index: TurbineCacheTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/src/rttest/org/apache/turbine/services/cache/TurbineCacheTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TurbineCacheTest.java	1 Feb 2002 03:20:00 -0000	1.1
  +++ TurbineCacheTest.java	3 Feb 2002 16:11:05 -0000	1.2
  @@ -74,7 +74,7 @@
    * TurbineCacheTest
    *
    * @author <a href="paulsp@apache.org">Paul Spencer</a>
  - * @version $Id: TurbineCacheTest.java,v 1.1 2002/02/01 03:20:00 brekke Exp $
  + * @version $Id: TurbineCacheTest.java,v 1.2 2002/02/03 16:11:05 brekke Exp $
    */
   public class TurbineCacheTest extends ServletTestCase {
       
  @@ -347,43 +347,30 @@
   
       /**
        * Verify the Cache count is correct.
  -     *
  -     * This test can take serveral minutes.
  -     *
        * @throws Exception
        */    
       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 );
  -        
  -        // Wait 2 Refresh to allow for remove object to be deleted
  -        Thread.sleep(TURBINE_CACHE_REFRESH * 2);
  -        assertEquals("Initial Object Count", 0, globalCache.getNumberOfObjects());
  +        assertNotNull("Could not retrive cache service.", globalCache);
   
  -        // 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 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 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 2 more refreshes
  +        Thread.sleep((TURBINE_CACHE_REFRESH * 2) + TURBINE_CACHE_REFRESH/3);
  +        assertEquals("After three refreshes", 0, globalCache.getNumberOfObjects());
       }
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>