You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-dev@jakarta.apache.org by as...@apache.org on 2006/02/14 22:52:03 UTC

svn commit: r377847 - in /jakarta/jcs/trunk: ./ src/java/org/apache/jcs/access/exception/ src/java/org/apache/jcs/auxiliary/disk/ src/java/org/apache/jcs/auxiliary/disk/indexed/ src/java/org/apache/jcs/utils/struct/ src/test/org/apache/jcs/ src/test/or...

Author: asmuts
Date: Tue Feb 14 13:52:01 2006
New Revision: 377847

URL: http://svn.apache.org/viewcvs?rev=377847&view=rev
Log:
Removed dependencies from the core of jcs on commons collections and commons lang.
With the next version of JCS, the core will only depend on util concurrent and commons logging.

Organizing unit tests and moving to a new test naming convention.

Added:
    jakarta/jcs/trunk/src/test/org/apache/jcs/ConcurrentRemovalLoadTest.java
      - copied, changed from r377776, jakarta/jcs/trunk/src/test/org/apache/jcs/TestRemovalConcurrent.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/JCSCacheElementRetrievalUnitTest.java
      - copied, changed from r377789, jakarta/jcs/trunk/src/test/org/apache/jcs/TestCacheElementRetrieval.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/JCSLightLoadUnitTest.java
      - copied, changed from r377776, jakarta/jcs/trunk/src/test/org/apache/jcs/TestSimpleLoad.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/JCSRemovalSimpleConcurrentTest.java
      - copied, changed from r377776, jakarta/jcs/trunk/src/test/org/apache/jcs/TestRemovalSimple.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/JCSUniTest.java
      - copied, changed from r377776, jakarta/jcs/trunk/src/test/org/apache/jcs/TestJCS.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/JCSvsHashtablePerformanceTest.java
      - copied, changed from r377776, jakarta/jcs/trunk/src/test/org/apache/jcs/TestJCSvHashtablePerf.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/ZeroSizeCacheUnitTest.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheConcurrentNoDeadLockUnitTest.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheConcurrentUnitTest.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheNoMemoryUnitTest.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheRandomConcurrentTestUtil.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheSameRegionConcurrentUnitTest.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPConcurrentRandomTestUtil.java
      - copied, changed from r377776, jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPConcurrentRandom.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPFilterRemoveHashCodeUnitTest.java
      - copied, changed from r377784, jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPFilterRemoveHashCode.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPNoDeadLockConcurrentTest.java
      - copied, changed from r377776, jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPConcurrentForDeadLock.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheClientTester.java
      - copied, changed from r377784, jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheClientTest.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/engine/EventQueueConcurrentLoadTest.java
      - copied, changed from r377776, jakarta/jcs/trunk/src/test/org/apache/jcs/engine/EventQueueConcurrentUnitTest.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/lru/LRUMemoryCacheConcurrentUnitTest.java
      - copied, changed from r377776, jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/lru/TestLRUMemoryCache.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/util/struct/JCSvsCommonsLRUMapPerformanceTest.java
      - copied, changed from r377776, jakarta/jcs/trunk/src/test/org/apache/jcs/util/struct/TestLRUMapPerf.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/util/struct/LRUMapConcurrentTest.java
Removed:
    jakarta/jcs/trunk/src/test/org/apache/jcs/TestCacheElementRetrieval.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/TestDiskCache.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/TestDiskCacheConcurrent.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/TestDiskCacheConcurrentForDeadLock.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/TestDiskCacheConcurrentRandom.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/TestDiskCacheNoMemory.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/TestJCS.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/TestJCSvHashtablePerf.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/TestRemovalConcurrent.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/TestRemovalSimple.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/TestSimpleLoad.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/TestZeroSizeCache.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPConcurrentForDeadLock.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPConcurrentRandom.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPFilterRemoveHashCode.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheClientTest.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/engine/EventQueueConcurrentUnitTest.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/lru/TestLRUMemoryCache.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/util/struct/TestLRUMap.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/util/struct/TestLRUMapPerf.java
Modified:
    jakarta/jcs/trunk/project.properties
    jakarta/jcs/trunk/project.xml
    jakarta/jcs/trunk/src/java/org/apache/jcs/access/exception/CacheException.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/LRUMapJCS.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
    jakarta/jcs/trunk/src/java/org/apache/jcs/utils/struct/LRUMap.java
    jakarta/jcs/trunk/src/test/org/apache/jcs/utils/struct/LRUMapPerformanceTest.java

Modified: jakarta/jcs/trunk/project.properties
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/project.properties?rev=377847&r1=377846&r2=377847&view=diff
==============================================================================
--- jakarta/jcs/trunk/project.properties (original)
+++ jakarta/jcs/trunk/project.properties Tue Feb 14 13:52:01 2006
@@ -17,7 +17,7 @@
 # this only include *UnitTest.java by default
 # this allows us to keep performance tests out of jcoverage,
 # since instrumented perf tests will always fail.
-test=Unit
+test=
 
 
 maven.core.callback.post-compile.buildFile = build.xml

Modified: jakarta/jcs/trunk/project.xml
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/project.xml?rev=377847&r1=377846&r2=377847&view=diff
==============================================================================
--- jakarta/jcs/trunk/project.xml (original)
+++ jakarta/jcs/trunk/project.xml Tue Feb 14 13:52:01 2006
@@ -226,38 +226,6 @@
 		<unitTest>
 			<includes>
 				<include>**/*${test}Test.java</include>
-
-				<include>**/TestCacheElementRetrieval.java</include>
-				<include>**/TestDiskCacheNoMemory.java</include>
-				<include>**/TestJCS.java</include>
-				<include>**/TestSimpleLoad.java</include>
-				<include>**/TestDiskCache.java</include>
-				<include>**/TestDiskCacheConcurrent.java</include>
-				<include>
-					**/TestDiskCacheConcurrentForDeadLock.java
-				</include>
-				<include>**/TestTCPLateralCache.java</include>
-				<include>
-					**/TestLateralTCPFilterRemoveHashCode.java
-				</include>
-				<include>
-					**/TestLateralTCPIssueRemoveOnPut.java
-				</include>
-				<include>
-					**/TestLateralTCPConcurrentForDeadLock.java
-				</include>
-				<!--
-					<include>**/TestJCSvHashtablePerf.java</include>
-				-->
-				<include>**/TestEventQueueConcurrent.java</include>
-				<include>**/TestSimpleEventHandling.java</include>
-				<include>**/TestLRUArray.java</include>
-				<include>**/TestSortedPrefArray.java</include>
-				<include>**/TestRemovalConcurrent.java</include>
-				<include>**/TestRemovalSimple.java</include>
-				<include>**/TestUDPDiscovery.java</include>
-				<include>**/TestSystemPropertyUsage.java</include>
-				<include>**/TestCacheManagerStats.java</include>
 			</includes>
 
 			<resources>

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/access/exception/CacheException.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/access/exception/CacheException.java?rev=377847&r1=377846&r2=377847&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/access/exception/CacheException.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/access/exception/CacheException.java Tue Feb 14 13:52:01 2006
@@ -16,14 +16,15 @@
  * limitations under the License.
  */
 
-import org.apache.commons.lang.exception.NestableException;
+//import org.apache.commons.lang.exception.NestableException;
 
 /**
  * This is the most general exception the cache throws.
  *  
  */
 public class CacheException
-    extends NestableException
+    extends Exception
+    //extends NestableException
 {
 
     private static final long serialVersionUID = 8725795372935590265L;

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/LRUMapJCS.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/LRUMapJCS.java?rev=377847&r1=377846&r2=377847&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/LRUMapJCS.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/LRUMapJCS.java Tue Feb 14 13:52:01 2006
@@ -1,8 +1,9 @@
 package org.apache.jcs.auxiliary.disk;
 
-import org.apache.commons.collections.map.LRUMap;
+//import org.apache.commons.collections.map.LRUMap;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.jcs.utils.struct.LRUMap;
 
 /**
  * Extension of LRUMap for logging of removals. Can switch this back to a

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java?rev=377847&r1=377846&r2=377847&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java Tue Feb 14 13:52:01 2006
@@ -348,6 +348,9 @@
 
         IndexedDiskElementDescriptor ded = null;
 
+        // old element with same key
+        IndexedDiskElementDescriptor old = null;
+        
         try
         {
             ded = new IndexedDiskElementDescriptor();
@@ -361,7 +364,7 @@
             try
             {
 
-                IndexedDiskElementDescriptor old = (IndexedDiskElementDescriptor) keyHash.put( ce.getKey(), ded );
+                old = (IndexedDiskElementDescriptor) keyHash.put( ce.getKey(), ded );
 
                 // Item with the same key already exists in file.
                 // Try to reuse the location if possible.
@@ -426,7 +429,7 @@
         }
         catch ( Exception e )
         {
-            log.error( "Failure updating element, cacheName: " + cacheName + ", key: " + ce.getKey(), e );
+            log.error( "Failure updating element, cacheName: " + cacheName + ", key: " + ce.getKey() + " old: " + old, e );
         }
         return;
     }

Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/utils/struct/LRUMap.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/java/org/apache/jcs/utils/struct/LRUMap.java?rev=377847&r1=377846&r2=377847&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/utils/struct/LRUMap.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/utils/struct/LRUMap.java Tue Feb 14 13:52:01 2006
@@ -11,7 +11,6 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
 import org.apache.jcs.engine.control.group.GroupAttrName;
 import org.apache.jcs.engine.stats.StatElement;
 import org.apache.jcs.engine.stats.Stats;
@@ -21,9 +20,17 @@
 /**
  * This is a simple LRUMap. It implements most of the map methods. It is not
  * recommended that you use any but put, get, remove, and clear.
+ * <p>
+ * Children can implement the processRemovedLRU method if they want to handle
+ * the removal of the lest recently used item.
+ * <p>
+ * This class was abstracted out of the LRU Memory cache. Put, remove, and get
+ * should be thread safe. It uses a hashtable and our own double linked list.
+ * <p>
+ * Locking is done on the instance.
  * 
  * @author aaronsm
- *  
+ * 
  */
 public class LRUMap
     implements Map
@@ -45,19 +52,37 @@
 
     int putCnt = 0;
 
+    // if the max is less than 0, there is no limit!
     int maxObjects = -1;
 
     // make configurable
     private int chunkSize = 1;
 
     /**
+     * This creates an unbounded version. Setting the max objects will result in
+     * spooling on subsequent puts.
+     * 
      * @param maxObjects
      */
-    public LRUMap( int maxObjects )
+    public LRUMap()
     {
-        this.maxObjects = maxObjects;
         list = new DoubleLinkedList();
+        
+        // normal hshtable is faster for
+        // sequential keys.
         map = new Hashtable();
+        //map = new ConcurrentHashMap();
+    }
+
+    /**
+     * This sets the size limit.
+     * 
+     * @param maxObjects
+     */
+    public LRUMap( int maxObjects )
+    {
+        this();
+        this.maxObjects = maxObjects;
     }
 
     /*
@@ -151,6 +176,7 @@
      */
     public Set keySet()
     {
+        // TODO fix this, it needs to return the keys inside the wrappers.
         return map.keySet();
     }
 
@@ -188,7 +214,7 @@
             log.debug( "LRUMap miss for " + key );
         }
 
-        //verifyCache();
+        // verifyCache();
         return retVal;
     }
 
@@ -236,9 +262,11 @@
         if ( me != null )
         {
             list.remove( me );
+
+            return me.getPayload();
         }
 
-        return me;
+        return null;
     }
 
     /*
@@ -268,73 +296,79 @@
         int size = map.size();
         // If the element limit is reached, we need to spool
 
-        if ( size <= this.maxObjects )
+        if ( this.maxObjects >= 0 && size > this.maxObjects )
         {
-            return old;
-        }
-        log.debug( "In memory limit reached, spooling" );
+            if ( log.isDebugEnabled() )
+            {
+                log.debug( "In memory limit reached, removing least recently used." );
+            }
 
-        // Write the last 'chunkSize' items to disk.
-        int chunkSizeCorrected = Math.min( size, getChunkSize() );
+            // Write the last 'chunkSize' items to disk.
+            int chunkSizeCorrected = Math.min( size, getChunkSize() );
 
-        if ( log.isDebugEnabled() )
-        {
-            log.debug( "About to spool to disk cache, map size: " + size + ", max objects: " + this.maxObjects
-                + ", items to spool: " + chunkSizeCorrected );
-        }
+            if ( log.isDebugEnabled() )
+            {
+                log.debug( "About to remove the least recently used. map size: " + size + ", max objects: "
+                    + this.maxObjects + ", items to spool: " + chunkSizeCorrected );
+            }
 
-        // The spool will put them in a disk event queue, so there is no
-        // need to pre-queue the queuing. This would be a bit wasteful
-        // and wouldn't save much time in this synchronous call.
+            // The spool will put them in a disk event queue, so there is no
+            // need to pre-queue the queuing. This would be a bit wasteful
+            // and wouldn't save much time in this synchronous call.
 
-        for ( int i = 0; i < chunkSizeCorrected; i++ )
-        {
-            synchronized ( this )
+            for ( int i = 0; i < chunkSizeCorrected; i++ )
             {
-                if ( list.getLast() != null )
+                synchronized ( this )
                 {
-                    if ( ( (LRUElementDescriptor) list.getLast() ) != null )
+                    if ( list.getLast() != null )
                     {
-                        //cache.spoolToDisk( ( (LRUElementDescriptor)
-                        // list.getLast()).ce);
-                        if ( !map.containsKey( ( (LRUElementDescriptor) list.getLast() ).getKey() ) )
+                        if ( ( (LRUElementDescriptor) list.getLast() ) != null )
                         {
-                            log.error( "update: map does not contain key: "
-                                + ( (LRUElementDescriptor) list.getLast() ).getKey() );
-                            verifyCache();
+                            processRemovedLRU( ( (LRUElementDescriptor) list.getLast() ).getKey(),
+                                               ( (LRUElementDescriptor) list.getLast() ).getPayload() );
+                            if ( !map.containsKey( ( (LRUElementDescriptor) list.getLast() ).getKey() ) )
+                            {
+                                log.error( "update: map does not contain key: "
+                                    + ( (LRUElementDescriptor) list.getLast() ).getKey() );
+                                verifyCache();
+                            }
+                            if ( map.remove( ( (LRUElementDescriptor) list.getLast() ).getKey() ) == null )
+                            {
+                                log.warn( "update: remove failed for key: "
+                                    + ( (LRUElementDescriptor) list.getLast() ).getKey() );
+                                verifyCache();
+                            }
                         }
-                        if ( map.remove( ( (LRUElementDescriptor) list.getLast() ).getKey() ) == null )
+                        else
                         {
-                            log.warn( "update: remove failed for key: "
-                                + ( (LRUElementDescriptor) list.getLast() ).getKey() );
-                            verifyCache();
+                            throw new Error( "update: last.ce is null!" );
                         }
+                        list.removeLast();
                     }
                     else
                     {
-                        throw new Error( "update: last.ce is null!" );
+                        verifyCache();
+                        throw new Error( "update: last is null!" );
                     }
-                    list.removeLast();
-                }
-                else
-                {
-                    verifyCache();
-                    throw new Error( "update: last is null!" );
                 }
             }
-        }
 
-        if ( log.isDebugEnabled() )
-        {
-            log.debug( "update: After spool map size: " + map.size() );
+            if ( log.isDebugEnabled() )
+            {
+                log.debug( "update: After spool map size: " + map.size() );
+            }
+            if ( map.size() != dumpCacheSize() )
+            {
+                log.error( "update: After spool, size mismatch: map.size() = " + map.size() + ", linked list size = "
+                    + dumpCacheSize() );
+            }
         }
-        if ( map.size() != dumpCacheSize() )
+
+        if ( old != null )
         {
-            log.error( "update: After spool, size mismatch: map.size() = " + map.size() + ", linked list size = "
-                + dumpCacheSize() );
+            return old.getPayload();
         }
-
-        return old;
+        return null;
     }
 
     /**
@@ -370,7 +404,10 @@
         log.debug( "dumpingCacheEntries" );
         for ( LRUElementDescriptor me = (LRUElementDescriptor) list.getFirst(); me != null; me = (LRUElementDescriptor) me.next )
         {
-            log.debug( "dumpCacheEntries> key=" + me.getKey() + ", val=" + me.getPayload() );
+            if ( log.isDebugEnabled() )
+            {
+                log.debug( "dumpCacheEntries> key=" + me.getKey() + ", val=" + me.getPayload() );
+            }
         }
     }
 
@@ -384,14 +421,17 @@
         {
             Map.Entry e = (Map.Entry) itr.next();
             LRUElementDescriptor me = (LRUElementDescriptor) e.getValue();
-            log.debug( "dumpMap> key=" + e.getKey() + ", val=" + me.getPayload() );
+            if ( log.isDebugEnabled() )
+            {
+                log.debug( "dumpMap> key=" + e.getKey() + ", val=" + me.getPayload() );
+            }
         }
     }
 
     /**
      * Checks to see if all the items that should be in the cache are. Checks
      * consistency between List and map.
-     *  
+     * 
      */
     protected void verifyCache()
     {
@@ -505,6 +545,24 @@
         if ( !found )
         {
             log.error( "verifycache(key), couldn't find key! : " + key );
+        }
+    }
+
+    /**
+     * This is called when an item is removed from the LRU. We just log some
+     * information.
+     * <p>
+     * Children can implement this method for special behavior.
+     * 
+     * @param key
+     * @param value
+     */
+    protected void processRemovedLRU( Object key, Object value )
+    {
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( "Removing key: [" + key + "] from LRUMap store, value = [" + value + "]" );
+            log.debug( "LRUMap store size: '" + this.size() + "'." );
         }
     }
 

Copied: jakarta/jcs/trunk/src/test/org/apache/jcs/ConcurrentRemovalLoadTest.java (from r377776, jakarta/jcs/trunk/src/test/org/apache/jcs/TestRemovalConcurrent.java)
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/ConcurrentRemovalLoadTest.java?p2=jakarta/jcs/trunk/src/test/org/apache/jcs/ConcurrentRemovalLoadTest.java&p1=jakarta/jcs/trunk/src/test/org/apache/jcs/TestRemovalConcurrent.java&r1=377776&r2=377847&rev=377847&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/TestRemovalConcurrent.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/ConcurrentRemovalLoadTest.java Tue Feb 14 13:52:01 2006
@@ -23,7 +23,7 @@
 /**
  * Test which exercises the hierarchical removal when the cache is active.
  */
-public class TestRemovalConcurrent
+public class ConcurrentRemovalLoadTest
     extends TestCase
 {
     /**
@@ -31,7 +31,7 @@
      * 
      * @param testName
      */
-    public TestRemovalConcurrent( String testName )
+    public ConcurrentRemovalLoadTest( String testName )
     {
         super( testName );
     }

Copied: jakarta/jcs/trunk/src/test/org/apache/jcs/JCSCacheElementRetrievalUnitTest.java (from r377789, jakarta/jcs/trunk/src/test/org/apache/jcs/TestCacheElementRetrieval.java)
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/JCSCacheElementRetrievalUnitTest.java?p2=jakarta/jcs/trunk/src/test/org/apache/jcs/JCSCacheElementRetrievalUnitTest.java&p1=jakarta/jcs/trunk/src/test/org/apache/jcs/TestCacheElementRetrieval.java&r1=377789&r2=377847&rev=377847&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/TestCacheElementRetrieval.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/JCSCacheElementRetrievalUnitTest.java Tue Feb 14 13:52:01 2006
@@ -24,7 +24,7 @@
  * @author Aaron Smuts
  *  
  */
-public class TestCacheElementRetrieval
+public class JCSCacheElementRetrievalUnitTest
     extends TestCase
 {
 

Copied: jakarta/jcs/trunk/src/test/org/apache/jcs/JCSLightLoadUnitTest.java (from r377776, jakarta/jcs/trunk/src/test/org/apache/jcs/TestSimpleLoad.java)
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/JCSLightLoadUnitTest.java?p2=jakarta/jcs/trunk/src/test/org/apache/jcs/JCSLightLoadUnitTest.java&p1=jakarta/jcs/trunk/src/test/org/apache/jcs/TestSimpleLoad.java&r1=377776&r2=377847&rev=377847&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/TestSimpleLoad.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/JCSLightLoadUnitTest.java Tue Feb 14 13:52:01 2006
@@ -24,7 +24,7 @@
  * Description of the Class
  *  
  */
-public class TestSimpleLoad
+public class JCSLightLoadUnitTest
     extends TestCase
 {
 
@@ -46,7 +46,7 @@
      * @param testName
      *            Description of the Parameter
      */
-    public TestSimpleLoad( String testName )
+    public JCSLightLoadUnitTest( String testName )
     {
         super( testName );
     }
@@ -59,7 +59,7 @@
      */
     public static void main( String args[] )
     {
-        String[] testCaseName = { TestSimpleLoad.class.getName() };
+        String[] testCaseName = { JCSLightLoadUnitTest.class.getName() };
         junit.textui.TestRunner.main( testCaseName );
     }
 
@@ -70,7 +70,7 @@
      */
     public static Test suite()
     {
-        return new TestSuite( TestSimpleLoad.class );
+        return new TestSuite( JCSLightLoadUnitTest.class );
     }
 
     /**

Copied: jakarta/jcs/trunk/src/test/org/apache/jcs/JCSRemovalSimpleConcurrentTest.java (from r377776, jakarta/jcs/trunk/src/test/org/apache/jcs/TestRemovalSimple.java)
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/JCSRemovalSimpleConcurrentTest.java?p2=jakarta/jcs/trunk/src/test/org/apache/jcs/JCSRemovalSimpleConcurrentTest.java&p1=jakarta/jcs/trunk/src/test/org/apache/jcs/TestRemovalSimple.java&r1=377776&r2=377847&rev=377847&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/TestRemovalSimple.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/JCSRemovalSimpleConcurrentTest.java Tue Feb 14 13:52:01 2006
@@ -21,7 +21,7 @@
 /**
  * Verify that basic removal functionality works.
  */
-public class TestRemovalSimple
+public class JCSRemovalSimpleConcurrentTest
     extends TestCase
 {
     /**
@@ -29,7 +29,7 @@
      * 
      * @param testName
      */
-    public TestRemovalSimple( String testName )
+    public JCSRemovalSimpleConcurrentTest( String testName )
     {
         super( testName );
     }
@@ -51,7 +51,7 @@
      */
     public static void main( String args[] )
     {
-        String[] testCaseName = { TestRemovalSimple.class.getName() };
+        String[] testCaseName = { JCSRemovalSimpleConcurrentTest.class.getName() };
         junit.textui.TestRunner.main( testCaseName );
     }
 

Copied: jakarta/jcs/trunk/src/test/org/apache/jcs/JCSUniTest.java (from r377776, jakarta/jcs/trunk/src/test/org/apache/jcs/TestJCS.java)
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/JCSUniTest.java?p2=jakarta/jcs/trunk/src/test/org/apache/jcs/JCSUniTest.java&p1=jakarta/jcs/trunk/src/test/org/apache/jcs/TestJCS.java&r1=377776&r2=377847&rev=377847&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/TestJCS.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/JCSUniTest.java Tue Feb 14 13:52:01 2006
@@ -31,7 +31,7 @@
  * 
  * @version $Id$
  */
-public class TestJCS
+public class JCSUniTest
     extends TestCase
 {
     Random random = new Random();
@@ -39,7 +39,7 @@
     /**
      * @param testName
      */
-    public TestJCS( String testName )
+    public JCSUniTest( String testName )
     {
         super( testName );
     }
@@ -49,7 +49,7 @@
      */
     public static Test suite()
     {
-        return new TestSuite( TestJCS.class );
+        return new TestSuite( JCSUniTest.class );
     }
 
     /**
@@ -57,7 +57,7 @@
      */
     public static void main( String args[] )
     {
-        String[] testCaseName = { TestJCS.class.getName() };
+        String[] testCaseName = { JCSUniTest.class.getName() };
         junit.textui.TestRunner.main( testCaseName );
     }
 

Copied: jakarta/jcs/trunk/src/test/org/apache/jcs/JCSvsHashtablePerformanceTest.java (from r377776, jakarta/jcs/trunk/src/test/org/apache/jcs/TestJCSvHashtablePerf.java)
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/JCSvsHashtablePerformanceTest.java?p2=jakarta/jcs/trunk/src/test/org/apache/jcs/JCSvsHashtablePerformanceTest.java&p1=jakarta/jcs/trunk/src/test/org/apache/jcs/TestJCSvHashtablePerf.java&r1=377776&r2=377847&rev=377847&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/TestJCSvHashtablePerf.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/JCSvsHashtablePerformanceTest.java Tue Feb 14 13:52:01 2006
@@ -6,14 +6,18 @@
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jcs.engine.memory.lru.LRUMemoryCache;
+
 /**
  * This test ensures that basic memory operations are with a speficified order
  * of magnitude of the java.util.Hashtable.
  * <p>
  * Currenlty JCS is un 2x a hashtable for gets, and under 1.2x for puts.
- *  
+ * 
  */
-public class TestJCSvHashtablePerf
+public class JCSvsHashtablePerformanceTest
     extends TestCase
 {
 
@@ -30,7 +34,7 @@
     /**
      * @param testName
      */
-    public TestJCSvHashtablePerf( String testName )
+    public JCSvsHashtablePerformanceTest( String testName )
     {
         super( testName );
     }
@@ -42,7 +46,7 @@
      */
     public static Test suite()
     {
-        return new TestSuite( TestJCSvHashtablePerf.class );
+        return new TestSuite( JCSvsHashtablePerformanceTest.class );
     }
 
     /**
@@ -54,13 +58,25 @@
     public void testSimpleLoad()
         throws Exception
     {
+        Log log1 = LogFactory.getLog( LRUMemoryCache.class );
+        if ( log1.isDebugEnabled() )
+        {
+            System.out.println( "The log level must be at info or above for the a performance test." );
+            return;
+        }
+        Log log2 = LogFactory.getLog( JCS.class );
+        if ( log2.isDebugEnabled() )
+        {
+            System.out.println( "The log level must be at info or above for the a performance test." );
+            return;
+        }
         doWork();
         assertTrue( this.ratioPut < target );
         assertTrue( this.ratioGet < target );
     }
 
     /**
-     *  
+     * 
      */
     public void doWork()
     {
@@ -107,7 +123,7 @@
                 tPer = Float.intBitsToFloat( (int) time ) / Float.intBitsToFloat( tries );
                 System.out.println( name + " get time for " + tries + " = " + time + "; millis per = " + tPer );
 
-                ///////////////////////////////////////////////////////////////
+                // /////////////////////////////////////////////////////////////
                 name = "Hashtable";
                 Hashtable cache2 = new Hashtable();
                 start = System.currentTimeMillis();
@@ -168,7 +184,7 @@
      */
     public static void main( String args[] )
     {
-        TestJCSvHashtablePerf test = new TestJCSvHashtablePerf( "command" );
+        JCSvsHashtablePerformanceTest test = new JCSvsHashtablePerformanceTest( "command" );
         test.doWork();
     }
 

Added: jakarta/jcs/trunk/src/test/org/apache/jcs/ZeroSizeCacheUnitTest.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/ZeroSizeCacheUnitTest.java?rev=377847&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/ZeroSizeCacheUnitTest.java (added)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/ZeroSizeCacheUnitTest.java Tue Feb 14 13:52:01 2006
@@ -0,0 +1,77 @@
+package org.apache.jcs;
+
+import junit.framework.TestCase;
+
+/**
+ * 
+ * @author Aaron Smuts
+ *  
+ */
+public class ZeroSizeCacheUnitTest
+    extends TestCase
+{
+
+    private static int items = 20000;
+
+    /**
+     * Test setup
+     */
+    public void setUp()
+        throws Exception
+    {
+        JCS.setConfigFilename( "/TestZeroSizeCache.ccf" );
+        JCS.getInstance( "testCache1" );
+    }
+
+    /**
+     * Verify that a 0 size cache does not result in errors. You should be able
+     * to disable a region this way.
+     * @throws Exception 
+     *  
+     */
+    public void testPutGetRemove()
+        throws Exception
+    {
+        JCS jcs = JCS.getInstance( "testCache1" );
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            jcs.put( i + ":key", "data" + i );
+        }
+
+        // all the gets should be null
+        for ( int i = items; i >= 0; i-- )
+        {
+            String res = (String) jcs.get( i + ":key" );
+            if ( res == null )
+            {
+                assertNull( "[" + i + ":key] should be null", res );
+            }
+        }
+
+        // test removal, should be no exceptions
+        jcs.remove( "300:key" );
+
+        // allow the shrinker to run
+        Thread.sleep( 500 );
+
+        // do it again.
+        for ( int i = 0; i <= items; i++ )
+        {
+            jcs.put( i + ":key", "data" + i );
+        }
+
+        for ( int i = items; i >= 0; i-- )
+        {
+            String res = (String) jcs.get( i + ":key" );
+            if ( res == null )
+            {
+                assertNull( "[" + i + ":key] should be null", res );
+            }
+        }
+
+        System.out.println( jcs.getStats() );
+
+    }
+
+}

Added: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheConcurrentNoDeadLockUnitTest.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheConcurrentNoDeadLockUnitTest.java?rev=377847&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheConcurrentNoDeadLockUnitTest.java (added)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheConcurrentNoDeadLockUnitTest.java Tue Feb 14 13:52:01 2006
@@ -0,0 +1,138 @@
+package org.apache.jcs.auxiliary.indexed;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+import junit.extensions.ActiveTestSuite;
+import junit.framework.Test;
+import junit.framework.TestCase;
+
+import org.apache.jcs.JCS;
+import org.apache.jcs.engine.control.CompositeCacheManager;
+
+/**
+ * Test which exercises the indexed disk cache. Runs three threads against the
+ * same region.
+ * 
+ * @version $Id: TestDiskCacheConcurrentForDeadLock.java,v 1.2 2005/02/01
+ *          00:01:59 asmuts Exp $
+ */
+public class IndexedDiskCacheConcurrentNoDeadLockUnitTest
+    extends TestCase
+{
+    /**
+     * Constructor for the TestDiskCache object.
+     * 
+     * @param testName
+     */
+    public IndexedDiskCacheConcurrentNoDeadLockUnitTest( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * Main method passes this test to the text test runner.
+     * 
+     * @param args
+     */
+    public static void main( String args[] )
+    {
+        String[] testCaseName = { IndexedDiskCacheConcurrentNoDeadLockUnitTest.class.getName() };
+        junit.textui.TestRunner.main( testCaseName );
+    }
+
+    /**
+     * A unit test suite for JUnit
+     * 
+     * @return The test suite
+     */
+    public static Test suite()
+    {
+        ActiveTestSuite suite = new ActiveTestSuite();
+
+        suite.addTest( new IndexedDiskCacheRandomConcurrentTestUtil( "testIndexedDiskCache1" )
+        {
+            public void runTest()
+                throws Exception
+            {
+                this.runTestForRegion( "indexedRegion4", 0, 200, 1 );
+            }
+        } );
+
+        suite.addTest( new IndexedDiskCacheRandomConcurrentTestUtil( "testIndexedDiskCache2" )
+        {
+            public void runTest()
+                throws Exception
+            {
+                this.runTestForRegion( "indexedRegion4", 10000, 50000, 2 );
+            }
+        } );
+
+        suite.addTest( new IndexedDiskCacheRandomConcurrentTestUtil( "testIndexedDiskCache3" )
+        {
+            public void runTest()
+                throws Exception
+            {
+                this.runTestForRegion( "indexedRegion4", 10000, 50000, 3 );
+            }
+        } );
+
+        suite.addTest( new IndexedDiskCacheRandomConcurrentTestUtil( "testIndexedDiskCache4" )
+        {
+            public void runTest()
+                throws Exception
+            {
+                this.runTestForRegion( "indexedRegion4", 10000, 50000, 4 );
+            }
+        } );
+
+        suite.addTest( new IndexedDiskCacheRandomConcurrentTestUtil( "testIndexedDiskCache5" )
+        {
+            public void runTest()
+                throws Exception
+            {
+                this.runTestForRegion( "indexedRegion4", 10000, 50000, 5 );
+            }
+        } );
+
+        return suite;
+    }
+
+    /**
+     * Test setup
+     */
+    public void setUp()
+    {
+        JCS.setConfigFilename( "/TestDiskCacheCon.ccf" );
+    }
+
+    /**
+     * Test tearDown. Dispose of the cache.
+     */
+    public void tearDown()
+    {
+        try
+        {
+            CompositeCacheManager cacheMgr = CompositeCacheManager.getInstance();
+            cacheMgr.shutDown();
+        }
+        catch ( Exception e )
+        {
+            // log.error(e);
+        }
+    }
+
+}

Added: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheConcurrentUnitTest.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheConcurrentUnitTest.java?rev=377847&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheConcurrentUnitTest.java (added)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheConcurrentUnitTest.java Tue Feb 14 13:52:01 2006
@@ -0,0 +1,153 @@
+package org.apache.jcs.auxiliary.indexed;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+import junit.extensions.ActiveTestSuite;
+import junit.framework.Test;
+import junit.framework.TestCase;
+
+import org.apache.jcs.JCS;
+
+/**
+ * Test which exercises the indexed disk cache. This one uses three different
+ * regions for thre threads.
+ * 
+ * @version $Id: TestDiskCache.java 224346 2005-06-04 02:01:59Z asmuts $
+ */
+public class IndexedDiskCacheConcurrentUnitTest
+    extends TestCase
+{
+    /**
+     * Number of items to cache, twice the configured maxObjects for the memory
+     * cache regions.
+     */
+    private static int items = 200;
+
+    /**
+     * Constructor for the TestDiskCache object.
+     * 
+     * @param testName
+     */
+    public IndexedDiskCacheConcurrentUnitTest( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * Main method passes this test to the text test runner.
+     * 
+     * @param args
+     */
+    public static void main( String args[] )
+    {
+        String[] testCaseName = { IndexedDiskCacheConcurrentUnitTest.class.getName() };
+        junit.textui.TestRunner.main( testCaseName );
+    }
+
+    /**
+     * A unit test suite for JUnit
+     * 
+     * @return The test suite
+     */
+    public static Test suite()
+    {
+        ActiveTestSuite suite = new ActiveTestSuite();
+
+        suite.addTest( new IndexedDiskCacheConcurrentUnitTest( "testIndexedDiskCache1" )
+        {
+            public void runTest()
+                throws Exception
+            {
+                this.runTestForRegion( "indexedRegion1" );
+            }
+        } );
+
+        suite.addTest( new IndexedDiskCacheConcurrentUnitTest( "testIndexedDiskCache2" )
+        {
+            public void runTest()
+                throws Exception
+            {
+                this.runTestForRegion( "indexedRegion2" );
+            }
+        } );
+
+        suite.addTest( new IndexedDiskCacheConcurrentUnitTest( "testIndexedDiskCache3" )
+        {
+            public void runTest()
+                throws Exception
+            {
+                this.runTestForRegion( "indexedRegion3" );
+            }
+        } );
+
+        return suite;
+    }
+
+    /**
+     * Test setup
+     */
+    public void setUp()
+    {
+        JCS.setConfigFilename( "/TestDiskCache.ccf" );
+    }
+
+    /**
+     * Adds items to cache, gets them, and removes them. The item count is more
+     * than the size of the memory cache, so items should spool to disk.
+     * 
+     * @param region
+     *            Name of the region to access
+     * 
+     * @exception Exception
+     *                If an error occurs
+     */
+    public void runTestForRegion( String region )
+        throws Exception
+    {
+        JCS jcs = JCS.getInstance( region );
+
+        // Add items to cache
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            jcs.put( i + ":key", region + " data " + i );
+        }
+
+        // Test that all items are in cache
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            String value = (String) jcs.get( i + ":key" );
+
+            assertEquals( region + " data " + i, value );
+        }
+
+        // Remove all the items
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            jcs.remove( i + ":key" );
+        }
+
+        // Verify removal
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            assertNull( "Removed key should be null: " + i + ":key", jcs.get( i + ":key" ) );
+        }
+    }
+}

Added: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheNoMemoryUnitTest.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheNoMemoryUnitTest.java?rev=377847&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheNoMemoryUnitTest.java (added)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheNoMemoryUnitTest.java Tue Feb 14 13:52:01 2006
@@ -0,0 +1,157 @@
+package org.apache.jcs.auxiliary.indexed;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+import junit.extensions.ActiveTestSuite;
+import junit.framework.Test;
+import junit.framework.TestCase;
+
+import org.apache.jcs.JCS;
+
+/**
+ * Test which exercises the indexed disk cache. This one uses three different
+ * regions for thre threads. It uses a config file that specifies 0 items in
+ * memory.
+ * 
+ * @version $Id: TestDiskCacheNoMemory.java 224346 2005-06-04 02:01:59Z asmuts $
+ */
+public class IndexedDiskCacheNoMemoryUnitTest
+    extends TestCase
+{
+    /**
+     * Number of items to cache; the configured maxObjects for the memory cache
+     * regions is 0.
+     */
+    private static int items = 2000;
+
+    /**
+     * Constructor for the TestDiskCache object.
+     * 
+     * @param testName
+     */
+    public IndexedDiskCacheNoMemoryUnitTest( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * Main method passes this test to the text test runner.
+     * 
+     * @param args
+     */
+    public static void main( String args[] )
+    {
+        String[] testCaseName = { IndexedDiskCacheNoMemoryUnitTest.class.getName() };
+        junit.textui.TestRunner.main( testCaseName );
+    }
+
+    /**
+     * A unit test suite for JUnit
+     * 
+     * @return The test suite
+     */
+    public static Test suite()
+    {
+        ActiveTestSuite suite = new ActiveTestSuite();
+
+        suite.addTest( new IndexedDiskCacheNoMemoryUnitTest( "testIndexedDiskCache1" )
+        {
+            public void runTest()
+                throws Exception
+            {
+                this.runTestForRegion( "indexedRegion1" );
+            }
+        } );
+
+        suite.addTest( new IndexedDiskCacheNoMemoryUnitTest( "testIndexedDiskCache2" )
+        {
+            public void runTest()
+                throws Exception
+            {
+                this.runTestForRegion( "indexedRegion2" );
+            }
+        } );
+
+        suite.addTest( new IndexedDiskCacheNoMemoryUnitTest( "testIndexedDiskCache3" )
+        {
+            public void runTest()
+                throws Exception
+            {
+                this.runTestForRegion( "indexedRegion3" );
+            }
+        } );
+
+        return suite;
+    }
+
+    /**
+     * Test setup
+     */
+    public void setUp()
+    {
+        JCS.setConfigFilename( "/TestDiskCacheNoMemory.ccf" );
+    }
+
+    /**
+     * Adds items to cache, gets them, and removes them. The item count is more
+     * than the size of the memory cache, so items should spool to disk.
+     * 
+     * @param region
+     *            Name of the region to access
+     * 
+     * @exception Exception
+     *                If an error occurs
+     */
+    public void runTestForRegion( String region )
+        throws Exception
+    {
+        JCS jcs = JCS.getInstance( region );
+
+        // Add items to cache
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            jcs.put( i + ":key", region + " data " + i );
+        }
+
+        // Test that all items are in cache
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            String value = (String) jcs.get( i + ":key" );
+
+            assertEquals( region + " data " + i, value );
+        }
+
+        // Remove all the items
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            jcs.remove( i + ":key" );
+        }
+
+        // Verify removal
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            assertNull( "Removed key should be null: " + i + ":key", jcs.get( i + ":key" ) );
+        }
+
+        // dump the stats tot he report
+        System.out.println( jcs.getStats() );
+    }
+}

Added: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheRandomConcurrentTestUtil.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheRandomConcurrentTestUtil.java?rev=377847&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheRandomConcurrentTestUtil.java (added)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheRandomConcurrentTestUtil.java Tue Feb 14 13:52:01 2006
@@ -0,0 +1,66 @@
+package org.apache.jcs.auxiliary.indexed;
+
+import junit.framework.TestCase;
+
+import org.apache.jcs.JCS;
+import org.apache.jcs.access.TestCacheAccess;
+
+/**
+ * This is used by other tests to generate a random load on the disk cache.
+ */
+public class IndexedDiskCacheRandomConcurrentTestUtil
+    extends TestCase
+{
+
+    /**
+     * Constructor for the TestDiskCache object.
+     * 
+     * @param testName
+     */
+    public IndexedDiskCacheRandomConcurrentTestUtil( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * Randomly adds items to cache, gets them, and removes them. The range
+     * count is more than the size of the memory cache, so items should spool to
+     * disk.
+     * 
+     * @param region
+     *            Name of the region to access
+     * @param range
+     * @param numOps
+     * @param testNum
+     * 
+     * @exception Exception
+     *                If an error occurs
+     */
+    public void runTestForRegion( String region, int range, int numOps, int testNum )
+        throws Exception
+    {
+        // run a rondom operation test to detect deadlocks
+        TestCacheAccess tca = new TestCacheAccess( "/TestDiskCacheCon.ccf" );
+        tca.setRegion( region );
+        tca.random( range, numOps );
+
+        // make sure a simple put then get works
+        // this may fail if the other tests are flooding the disk cache
+        JCS jcs = JCS.getInstance( region );
+        String key = "testKey" + testNum;
+        String data = "testData" + testNum;
+        jcs.put( key, data );
+        String value = (String) jcs.get( key );
+        assertEquals( data, value );
+
+    }
+
+    /**
+     * Test setup
+     */
+    public void setUp()
+    {
+        JCS.setConfigFilename( "/TestDiskCacheCon.ccf" );
+    }
+
+}

Added: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheSameRegionConcurrentUnitTest.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheSameRegionConcurrentUnitTest.java?rev=377847&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheSameRegionConcurrentUnitTest.java (added)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/indexed/IndexedDiskCacheSameRegionConcurrentUnitTest.java Tue Feb 14 13:52:01 2006
@@ -0,0 +1,184 @@
+package org.apache.jcs.auxiliary.indexed;
+
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+import junit.extensions.ActiveTestSuite;
+import junit.framework.Test;
+import junit.framework.TestCase;
+
+import org.apache.jcs.JCS;
+
+/**
+ * Test which exercises the indexed disk cache. Runs three threads against the
+ * same region.
+ * 
+ * @version $Id: TestDiskCacheConcurrent.java,v 1.8 2005/02/01 00:01:59 asmuts
+ *          Exp $
+ */
+public class IndexedDiskCacheSameRegionConcurrentUnitTest
+    extends TestCase
+{
+    /**
+     * Constructor for the TestDiskCache object.
+     * 
+     * @param testName
+     */
+    public IndexedDiskCacheSameRegionConcurrentUnitTest( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * Main method passes this test to the text test runner.
+     * 
+     * @param args
+     */
+    public static void main( String args[] )
+    {
+        String[] testCaseName = { IndexedDiskCacheSameRegionConcurrentUnitTest.class.getName() };
+        junit.textui.TestRunner.main( testCaseName );
+    }
+
+    /**
+     * A unit test suite for JUnit
+     * 
+     * @return The test suite
+     */
+    public static Test suite()
+    {
+        ActiveTestSuite suite = new ActiveTestSuite();
+
+        suite.addTest( new IndexedDiskCacheSameRegionConcurrentUnitTest( "testIndexedDiskCache1" )
+        {
+            public void runTest()
+                throws Exception
+            {
+                this.runTestForRegion( "indexedRegion4", 0, 200 );
+            }
+        } );
+
+        suite.addTest( new IndexedDiskCacheSameRegionConcurrentUnitTest( "testIndexedDiskCache2" )
+        {
+            public void runTest()
+                throws Exception
+            {
+                this.runTestForRegion( "indexedRegion4", 1000, 1200 );
+            }
+        } );
+
+        suite.addTest( new IndexedDiskCacheSameRegionConcurrentUnitTest( "testIndexedDiskCache3" )
+        {
+            public void runTest()
+                throws Exception
+            {
+                this.runTestForRegion( "indexedRegion4", 2000, 2200 );
+            }
+        } );
+
+        suite.addTest( new IndexedDiskCacheSameRegionConcurrentUnitTest( "testIndexedDiskCache4" )
+        {
+            public void runTest()
+                throws Exception
+            {
+                this.runTestForRegion( "indexedRegion4", 2200, 5200 );
+            }
+        } );
+
+        suite.addTest( new IndexedDiskCacheSameRegionConcurrentUnitTest( "testIndexedDiskCache5" )
+        {
+            public void runTest()
+                throws Exception
+            {
+                this.runTestForRegion( "indexedRegion4", 0, 5200 );
+            }
+        } );
+
+        return suite;
+    }
+
+    /**
+     * Test setup
+     */
+    public void setUp()
+    {
+        JCS.setConfigFilename( "/TestDiskCacheCon.ccf" );
+    }
+
+    // /**
+    // * Tests the region which uses the indexed disk cache
+    // */
+    // public void testIndexedDiskCache()
+    // throws Exception
+    // {
+    // runTestForRegion( "indexedRegion" );
+    // }
+    //
+    // /**
+    // * Tests the region which uses the indexed disk cache
+    // */
+    // public void testIndexedDiskCache2()
+    // throws Exception
+    // {
+    // runTestForRegion( "indexedRegion2" );
+    // }
+
+    /**
+     * Adds items to cache, gets them, and removes them. The item count is more
+     * than the size of the memory cache, so items should spool to disk.
+     * 
+     * @param region
+     *            Name of the region to access
+     * @param start
+     * @param end
+     * 
+     * @exception Exception
+     *                If an error occurs
+     */
+    public void runTestForRegion( String region, int start, int end )
+        throws Exception
+    {
+        JCS jcs = JCS.getInstance( region );
+
+        // Add items to cache
+
+        for ( int i = start; i <= end; i++ )
+        {
+            jcs.put( i + ":key", region + " data " + i );
+        }
+
+        // Test that all items are in cache
+
+        for ( int i = start; i <= end; i++ )
+        {
+            String value = (String) jcs.get( i + ":key" );
+
+            assertEquals( region + " data " + i, value );
+        }
+
+        /*
+         * // you can't remove in one thread and expect them to be in another //
+         * Remove all the items
+         * 
+         * for ( int i = start; i <= end; i++ ) { jcs.remove( i + ":key" ); } //
+         * Verify removal
+         * 
+         * for ( int i = start; i <= end; i++ ) { assertNull( "Removed key
+         * should be null: " + i + ":key", jcs.get( i + ":key" ) ); }
+         */
+
+    }
+}

Copied: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPConcurrentRandomTestUtil.java (from r377776, jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPConcurrentRandom.java)
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPConcurrentRandomTestUtil.java?p2=jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPConcurrentRandomTestUtil.java&p1=jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPConcurrentRandom.java&r1=377776&r2=377847&rev=377847&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPConcurrentRandom.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPConcurrentRandomTestUtil.java Tue Feb 14 13:52:01 2006
@@ -11,7 +11,7 @@
 /**
  * @author asmuts
  */
-public class TestLateralTCPConcurrentRandom
+public class LateralTCPConcurrentRandomTestUtil
     extends TestCase
 {
 
@@ -24,7 +24,7 @@
      * 
      * @param testName
      */
-    public TestLateralTCPConcurrentRandom( String testName )
+    public LateralTCPConcurrentRandomTestUtil( String testName )
     {
         super( testName );
     }

Copied: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPFilterRemoveHashCodeUnitTest.java (from r377784, jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPFilterRemoveHashCode.java)
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPFilterRemoveHashCodeUnitTest.java?p2=jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPFilterRemoveHashCodeUnitTest.java&p1=jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPFilterRemoveHashCode.java&r1=377784&r2=377847&rev=377847&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPFilterRemoveHashCode.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPFilterRemoveHashCodeUnitTest.java Tue Feb 14 13:52:01 2006
@@ -11,7 +11,7 @@
 /**
  * @author asmuts
  */
-public class TestLateralTCPFilterRemoveHashCode
+public class LateralTCPFilterRemoveHashCodeUnitTest
     extends TestCase
 {
 
@@ -24,7 +24,7 @@
      * 
      * @param testName
      */
-    public TestLateralTCPFilterRemoveHashCode( String testName )
+    public LateralTCPFilterRemoveHashCodeUnitTest( String testName )
     {
         super( testName );
     }

Copied: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPNoDeadLockConcurrentTest.java (from r377776, jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPConcurrentForDeadLock.java)
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPNoDeadLockConcurrentTest.java?p2=jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPNoDeadLockConcurrentTest.java&p1=jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPConcurrentForDeadLock.java&r1=377776&r2=377847&rev=377847&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPConcurrentForDeadLock.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPNoDeadLockConcurrentTest.java Tue Feb 14 13:52:01 2006
@@ -28,7 +28,7 @@
  * same region and two against other regions.
  * 
  */
-public class TestLateralTCPConcurrentForDeadLock
+public class LateralTCPNoDeadLockConcurrentTest
     extends TestCase
 {
     /**
@@ -36,7 +36,7 @@
      * 
      * @param testName
      */
-    public TestLateralTCPConcurrentForDeadLock( String testName )
+    public LateralTCPNoDeadLockConcurrentTest( String testName )
     {
         super( testName );
     }
@@ -48,7 +48,7 @@
      */
     public static void main( String args[] )
     {
-        String[] testCaseName = { TestLateralTCPConcurrentForDeadLock.class.getName() };
+        String[] testCaseName = { LateralTCPNoDeadLockConcurrentTest.class.getName() };
         junit.textui.TestRunner.main( testCaseName );
     }
 
@@ -64,7 +64,7 @@
         
         ActiveTestSuite suite = new ActiveTestSuite();
 
-        suite.addTest( new TestLateralTCPConcurrentRandom( "testLateralTCPCache1" )
+        suite.addTest( new LateralTCPConcurrentRandomTestUtil( "testLateralTCPCache1" )
         {
             public void runTest()
                 throws Exception
@@ -73,7 +73,7 @@
             }
         } );
 
-        suite.addTest( new TestLateralTCPConcurrentRandom( "testLateralTCPCache2" )
+        suite.addTest( new LateralTCPConcurrentRandomTestUtil( "testLateralTCPCache2" )
         {
             public void runTest()
                 throws Exception
@@ -82,7 +82,7 @@
             }
         } );
 
-        suite.addTest( new TestLateralTCPConcurrentRandom( "testLateralTCPCache3" )
+        suite.addTest( new LateralTCPConcurrentRandomTestUtil( "testLateralTCPCache3" )
         {
             public void runTest()
                 throws Exception
@@ -91,7 +91,7 @@
             }
         } );
 
-        suite.addTest( new TestLateralTCPConcurrentRandom( "testLateralTCPCache4" )
+        suite.addTest( new LateralTCPConcurrentRandomTestUtil( "testLateralTCPCache4" )
         {
             public void runTest()
                 throws Exception
@@ -100,7 +100,7 @@
             }
         } );
 
-        suite.addTest( new TestLateralTCPConcurrentRandom( "testLateralTCPCache5" )
+        suite.addTest( new LateralTCPConcurrentRandomTestUtil( "testLateralTCPCache5" )
         {
             public void runTest()
                 throws Exception

Copied: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheClientTester.java (from r377784, jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheClientTest.java)
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheClientTester.java?p2=jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheClientTester.java&p1=jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheClientTest.java&r1=377784&r2=377847&rev=377847&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheClientTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheClientTester.java Tue Feb 14 13:52:01 2006
@@ -40,7 +40,7 @@
  * @author asmuts
  * @created January 15, 2002
  */
-public class RemoteCacheClientTest
+public class RemoteCacheClientTester
     implements IRemoteCacheListener, IRemoteCacheConstants
 {
 
@@ -78,7 +78,7 @@
      * @exception NotBoundException
      * @exception IOException
      */
-    public RemoteCacheClientTest( int count )
+    public RemoteCacheClientTester( int count )
         throws MalformedURLException, NotBoundException, IOException
     {
         this( count, true, true, false );
@@ -95,7 +95,7 @@
      * @exception NotBoundException
      * @exception IOException
      */
-    public RemoteCacheClientTest( int count, boolean write, boolean read, boolean delete )
+    public RemoteCacheClientTester( int count, boolean write, boolean read, boolean delete )
         throws MalformedURLException, NotBoundException, IOException
     {
         this( "", Registry.REGISTRY_PORT, count, write, read, delete );
@@ -114,7 +114,7 @@
      * @exception NotBoundException
      * @exception IOException
      */
-    public RemoteCacheClientTest( String host, int port, int count, boolean write, boolean read, boolean delete )
+    public RemoteCacheClientTester( String host, int port, int count, boolean write, boolean read, boolean delete )
         throws MalformedURLException, NotBoundException, IOException
     {
         this.count = count;
@@ -265,7 +265,7 @@
                 count = Integer.parseInt( args[i] );
             }
         }
-        new RemoteCacheClientTest( count, write, read, delete );
+        new RemoteCacheClientTester( count, write, read, delete );
     }
 
     /**

Copied: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/EventQueueConcurrentLoadTest.java (from r377776, jakarta/jcs/trunk/src/test/org/apache/jcs/engine/EventQueueConcurrentUnitTest.java)
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/EventQueueConcurrentLoadTest.java?p2=jakarta/jcs/trunk/src/test/org/apache/jcs/engine/EventQueueConcurrentLoadTest.java&p1=jakarta/jcs/trunk/src/test/org/apache/jcs/engine/EventQueueConcurrentUnitTest.java&r1=377776&r2=377847&rev=377847&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/engine/EventQueueConcurrentUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/engine/EventQueueConcurrentLoadTest.java Tue Feb 14 13:52:01 2006
@@ -33,7 +33,7 @@
  * 
  * @author Aaron Smuts
  */
-public class EventQueueConcurrentUnitTest
+public class EventQueueConcurrentLoadTest
     extends TestCase
 {
 
@@ -53,7 +53,7 @@
      * 
      * @param testName
      */
-    public EventQueueConcurrentUnitTest( String testName )
+    public EventQueueConcurrentLoadTest( String testName )
     {
         super( testName );
     }
@@ -65,7 +65,7 @@
      */
     public static void main( String args[] )
     {
-        String[] testCaseName = { EventQueueConcurrentUnitTest.class.getName() };
+        String[] testCaseName = { EventQueueConcurrentLoadTest.class.getName() };
         junit.textui.TestRunner.main( testCaseName );
     }
 
@@ -79,7 +79,7 @@
 
         ActiveTestSuite suite = new ActiveTestSuite();
 
-        suite.addTest( new EventQueueConcurrentUnitTest( "testRunPutTest1" )
+        suite.addTest( new EventQueueConcurrentLoadTest( "testRunPutTest1" )
         {
             public void runTest()
                 throws Exception
@@ -88,7 +88,7 @@
             }
         } );
 
-        suite.addTest( new EventQueueConcurrentUnitTest( "testRunPutTest2" )
+        suite.addTest( new EventQueueConcurrentLoadTest( "testRunPutTest2" )
         {
             public void runTest()
                 throws Exception
@@ -97,7 +97,7 @@
             }
         } );
 
-        suite.addTest( new EventQueueConcurrentUnitTest( "testRunRemoveTest1" )
+        suite.addTest( new EventQueueConcurrentLoadTest( "testRunRemoveTest1" )
         {
             public void runTest()
                 throws Exception
@@ -106,7 +106,7 @@
             }
         } );
 
-        suite.addTest( new EventQueueConcurrentUnitTest( "testStopProcessing1" )
+        suite.addTest( new EventQueueConcurrentLoadTest( "testStopProcessing1" )
         {
             public void runTest()
                 throws Exception
@@ -115,7 +115,7 @@
             }
         } );
 
-        suite.addTest( new EventQueueConcurrentUnitTest( "testRunPutTest4" )
+        suite.addTest( new EventQueueConcurrentLoadTest( "testRunPutTest4" )
         {
             public void runTest()
                 throws Exception
@@ -124,7 +124,7 @@
             }
         } );
 
-        suite.addTest( new EventQueueConcurrentUnitTest( "testRunRemoveTest2" )
+        suite.addTest( new EventQueueConcurrentLoadTest( "testRunRemoveTest2" )
         {
             public void runTest()
                 throws Exception
@@ -133,7 +133,7 @@
             }
         } );
 
-        suite.addTest( new EventQueueConcurrentUnitTest( "testStopProcessing2" )
+        suite.addTest( new EventQueueConcurrentLoadTest( "testStopProcessing2" )
         {
             public void runTest()
                 throws Exception
@@ -142,7 +142,7 @@
             }
         } );
 
-        suite.addTest( new EventQueueConcurrentUnitTest( "testRunPutDelayTest" )
+        suite.addTest( new EventQueueConcurrentLoadTest( "testRunPutDelayTest" )
         {
             public void runTest()
                 throws Exception

Copied: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/lru/LRUMemoryCacheConcurrentUnitTest.java (from r377776, jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/lru/TestLRUMemoryCache.java)
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/lru/LRUMemoryCacheConcurrentUnitTest.java?p2=jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/lru/LRUMemoryCacheConcurrentUnitTest.java&p1=jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/lru/TestLRUMemoryCache.java&r1=377776&r2=377847&rev=377847&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/lru/TestLRUMemoryCache.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/lru/LRUMemoryCacheConcurrentUnitTest.java Tue Feb 14 13:52:01 2006
@@ -31,7 +31,7 @@
  * 
  * @version $Id$
  */
-public class TestLRUMemoryCache
+public class LRUMemoryCacheConcurrentUnitTest
     extends TestCase
 {
     /**
@@ -45,7 +45,7 @@
      * 
      * @param testName
      */
-    public TestLRUMemoryCache( String testName )
+    public LRUMemoryCacheConcurrentUnitTest( String testName )
     {
         super( testName );
     }
@@ -57,7 +57,7 @@
      */
     public static void main( String args[] )
     {
-        String[] testCaseName = { TestLRUMemoryCache.class.getName() };
+        String[] testCaseName = { LRUMemoryCacheConcurrentUnitTest.class.getName() };
         junit.textui.TestRunner.main( testCaseName );
     }
 
@@ -70,7 +70,7 @@
     {
         ActiveTestSuite suite = new ActiveTestSuite();
 
-        suite.addTest( new TestLRUMemoryCache( "testLRUMemoryCache" )
+        suite.addTest( new LRUMemoryCacheConcurrentUnitTest( "testLRUMemoryCache" )
         {
             public void runTest()
                 throws Exception

Copied: jakarta/jcs/trunk/src/test/org/apache/jcs/util/struct/JCSvsCommonsLRUMapPerformanceTest.java (from r377776, jakarta/jcs/trunk/src/test/org/apache/jcs/util/struct/TestLRUMapPerf.java)
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/util/struct/JCSvsCommonsLRUMapPerformanceTest.java?p2=jakarta/jcs/trunk/src/test/org/apache/jcs/util/struct/JCSvsCommonsLRUMapPerformanceTest.java&p1=jakarta/jcs/trunk/src/test/org/apache/jcs/util/struct/TestLRUMapPerf.java&r1=377776&r2=377847&rev=377847&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/util/struct/TestLRUMapPerf.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/util/struct/JCSvsCommonsLRUMapPerformanceTest.java Tue Feb 14 13:52:01 2006
@@ -6,7 +6,9 @@
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
-import org.apache.jcs.TestJCSvHashtablePerf;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jcs.JCSvsHashtablePerformanceTest;
 import org.apache.jcs.utils.struct.LRUMap;
 
 /**
@@ -14,9 +16,9 @@
  * version. It has been testing at .6 to .7 times the commons LRU.
  * 
  * @author aaronsm
- *  
+ * 
  */
-public class TestLRUMapPerf
+public class JCSvsCommonsLRUMapPerformanceTest
     extends TestCase
 {
 
@@ -33,7 +35,7 @@
     /**
      * @param testName
      */
-    public TestLRUMapPerf( String testName )
+    public JCSvsCommonsLRUMapPerformanceTest( String testName )
     {
         super( testName );
     }
@@ -45,7 +47,7 @@
      */
     public static Test suite()
     {
-        return new TestSuite( TestLRUMapPerf.class );
+        return new TestSuite( JCSvsCommonsLRUMapPerformanceTest.class );
     }
 
     /**
@@ -57,13 +59,20 @@
     public void testSimpleLoad()
         throws Exception
     {
+        Log log = LogFactory.getLog( LRUMap.class );
+        if ( log.isDebugEnabled() )
+        {
+            System.out.println( "The log level must be at info or above for the a performance test." );
+            return;
+        }
+
         doWork();
         assertTrue( this.ratioPut < target );
         assertTrue( this.ratioGet < target );
     }
 
     /**
-     *  
+     * 
      */
     public void doWork()
     {
@@ -112,12 +121,12 @@
                 tPer = Float.intBitsToFloat( (int) time ) / Float.intBitsToFloat( tries );
                 System.out.println( name + " get time for " + tries + " = " + time + "; millis per = " + tPer );
 
-                ///////////////////////////////////////////////////////////////
-                cache2Name = "LRUMapJCS (commons)";
-                //or LRUMapJCS
+                // /////////////////////////////////////////////////////////////
+                cache2Name = "Commons  ";
+                // or LRUMapJCS
                 Map cache2 = new org.apache.commons.collections.map.LRUMap( tries );
-                //cache2Name = "Hashtable";
-                //Hashtable cache2 = new Hashtable();
+                // cache2Name = "Hashtable";
+                // Hashtable cache2 = new Hashtable();
                 start = System.currentTimeMillis();
                 for ( int i = 0; i < tries; i++ )
                 {
@@ -178,7 +187,7 @@
      */
     public static void main( String args[] )
     {
-        TestJCSvHashtablePerf test = new TestJCSvHashtablePerf( "command" );
+        JCSvsHashtablePerformanceTest test = new JCSvsHashtablePerformanceTest( "command" );
         test.doWork();
     }
 

Added: jakarta/jcs/trunk/src/test/org/apache/jcs/util/struct/LRUMapConcurrentTest.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/util/struct/LRUMapConcurrentTest.java?rev=377847&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/util/struct/LRUMapConcurrentTest.java (added)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/util/struct/LRUMapConcurrentTest.java Tue Feb 14 13:52:01 2006
@@ -0,0 +1,277 @@
+package org.apache.jcs.util.struct;
+
+import java.util.Iterator;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.jcs.utils.struct.LRUMap;
+
+/**
+ * Tests the LRUMap
+ * 
+ * @author aaronsm
+ *  
+ */
+public class LRUMapConcurrentTest
+    extends TestCase
+{
+
+    private static int items = 20000;
+
+    /**
+     * Constructor for the TestSimpleLoad object
+     * 
+     * @param testName
+     *            Description of the Parameter
+     */
+    public LRUMapConcurrentTest( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * Description of the Method
+     * 
+     * @param args
+     *            Description of the Parameter
+     */
+    public static void main( String args[] )
+    {
+        String[] testCaseName = { LRUMapConcurrentTest.class.getName() };
+        junit.textui.TestRunner.main( testCaseName );
+    }
+
+    /**
+     * A unit test suite for JUnit
+     * 
+     * @return The test suite
+     */
+    public static Test suite()
+    {
+        // run the basic tests
+        TestSuite suite = new TestSuite( LRUMapConcurrentTest.class );
+
+        // run concurrent tests
+        final LRUMap map = new LRUMap( 2000 );
+        suite.addTest( new LRUMapConcurrentTest( "conc1" )
+        {
+            public void runTest()
+                throws Exception
+            {
+                this.runConcurrentPutGetTests( map, 2000 );
+            }
+        } );
+        suite.addTest( new LRUMapConcurrentTest( "conc2" )
+        {
+            public void runTest()
+                throws Exception
+            {
+                this.runConcurrentPutGetTests( map, 2000 );
+            }
+        } );
+        suite.addTest( new LRUMapConcurrentTest( "conc3" )
+        {
+            public void runTest()
+                throws Exception
+            {
+                this.runConcurrentPutGetTests( map, 2000 );
+            }
+        } );
+
+        // run more concurrent tests
+        final int max2 = 20000;
+        final LRUMap map2 = new LRUMap( max2 );
+        suite.addTest( new LRUMapConcurrentTest( "concB1" )
+        {
+            public void runTest()
+                throws Exception
+            {
+                this.runConcurrentRangeTests( map2, 10000, max2 );
+            }
+        } );
+        suite.addTest( new LRUMapConcurrentTest( "concB1" )
+        {
+            public void runTest()
+                throws Exception
+            {
+                this.runConcurrentRangeTests( map2, 0, 9999 );
+            }
+        } );
+
+        return suite;
+    }
+
+    /**
+     * Just test that we can put, get and remove as expected.
+     * 
+     * @exception Exception
+     *                Description of the Exception
+     */
+    public void testSimpleLoad()
+        throws Exception
+    {
+        LRUMap map = new LRUMap( items );
+
+        for ( int i = 0; i < items; i++ )
+        {
+            map.put( i + ":key", "data" + i );
+        }
+
+        for ( int i = items - 1; i >= 0; i-- )
+        {
+            String res = (String) map.get( i + ":key" );
+            if ( res == null )
+            {
+                assertNotNull( "[" + i + ":key] should not be null", res );
+            }
+        }
+
+        // test removal
+        map.remove( "300:key" );
+        assertNull( map.get( "300:key" ) );
+
+    }
+
+    /**
+     * Just make sure that the LRU functions int he most simple case.
+     * 
+     * @exception Exception
+     *                Description of the Exception
+     */
+    public void testLRURemoval()
+        throws Exception
+    {
+        int total = 10;
+        LRUMap map = new LRUMap( total );
+        map.setChunkSize( 1 );
+
+        // put the max in
+        for ( int i = 0; i < total; i++ )
+        {
+            map.put( i + ":key", "data" + i );
+        }
+
+        Iterator it = map.entrySet().iterator();
+        while ( it.hasNext() )
+        {
+            System.out.println( it.next() );
+        }
+        System.out.println( map.getStatistics() );
+
+        // get the max out backwards
+        for ( int i = total - 1; i >= 0; i-- )
+        {
+            String res = (String) map.get( i + ":key" );
+            if ( res == null )
+            {
+                assertNotNull( "[" + i + ":key] should not be null", res );
+            }
+        }
+
+        System.out.println( map.getStatistics() );
+
+        //since we got them backwards the total should be at the end.
+        // add one confirm that total is gone.
+        map.put( ( total ) + ":key", "data" + ( total ) );
+        assertNull( map.get( ( total - 1 ) + ":key" ) );
+
+    }
+
+    /**
+     * @throws Exception
+     */
+    public void testLRURemovalAgain()
+        throws Exception
+    {
+        int total = 10000;
+        LRUMap map = new LRUMap( total );
+        map.setChunkSize( 1 );
+
+        // put the max in
+        for ( int i = 0; i < total * 2; i++ )
+        {
+            map.put( i + ":key", "data" + i );
+        }
+
+        // get the total number, these shoukld be null
+        for ( int i = total - 1; i >= 0; i-- )
+        {
+            assertNull( map.get( i + ":key" ) );
+
+        }
+
+        // get the total to total *2 items out, these should be foufn.
+        for ( int i = ( total * 2 ) - 1; i >= total; i-- )
+        {
+            String res = (String) map.get( i + ":key" );
+            if ( res == null )
+            {
+                assertNotNull( "[" + i + ":key] should not be null", res );
+            }
+        }
+
+        System.out.println( map.getStatistics() );
+
+    }
+
+    /**
+     * Just make sure that we can put and get concurrently
+     * 
+     * @param map
+     * @param items
+     * @throws Exception
+     */
+    public void runConcurrentPutGetTests( LRUMap map, int items )
+        throws Exception
+    {
+        for ( int i = 0; i < items; i++ )
+        {
+            map.put( i + ":key", "data" + i );
+        }
+
+        for ( int i = items - 1; i >= 0; i-- )
+        {
+            String res = (String) map.get( i + ":key" );
+            if ( res == null )
+            {
+                assertNotNull( "[" + i + ":key] should not be null", res );
+            }
+        }
+
+    }
+
+    /**
+     * Put, get, and remove from a range. This should occur at a range that is
+     * not touched by other tests.
+     * 
+     * @param map
+     * @param start
+     * @param end
+     * @throws Exception
+     */
+    public void runConcurrentRangeTests( LRUMap map, int start, int end )
+        throws Exception
+    {
+        for ( int i = start; i < end; i++ )
+        {
+            map.put( i + ":key", "data" + i );
+        }
+
+        for ( int i = end - 1; i >= start; i-- )
+        {
+            String res = (String) map.get( i + ":key" );
+            if ( res == null )
+            {
+                assertNotNull( "[" + i + ":key] should not be null", res );
+            }
+        }
+
+        // test removal
+        map.remove( start + ":key" );
+        assertNull( map.get( start + ":key" ) );
+
+    }
+
+}
\ No newline at end of file

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/utils/struct/LRUMapPerformanceTest.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/utils/struct/LRUMapPerformanceTest.java?rev=377847&r1=377846&r2=377847&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/utils/struct/LRUMapPerformanceTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/utils/struct/LRUMapPerformanceTest.java Tue Feb 14 13:52:01 2006
@@ -6,7 +6,7 @@
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
-import org.apache.jcs.TestJCSvHashtablePerf;
+import org.apache.jcs.JCSvsHashtablePerformanceTest;
 import org.apache.jcs.utils.struct.LRUMap;
 
 /**
@@ -178,7 +178,7 @@
      */
     public static void main( String args[] )
     {
-        TestJCSvHashtablePerf test = new TestJCSvHashtablePerf( "command" );
+        JCSvsHashtablePerformanceTest test = new JCSvsHashtablePerformanceTest( "command" );
         test.doWork();
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-dev-help@jakarta.apache.org