asmuts 2004/11/15 23:36:35
Added: src/test/org/apache/jcs TestDiskCacheNoMemory.java
src/test TestDiskCacheNoMemory.ccf
src/test-conf TestDiskCacheNoMemory.ccf
Log:
Added new test for disk cache with memory set to 0. I can't produce any
problems so far.
Revision Changes Path
1.1
jakarta-turbine-jcs/src/test/org/apache/jcs/TestDiskCacheNoMemory.java
Index: TestDiskCacheNoMemory.java
===================================================================
package org.apache.jcs;
/*
* 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;
/**
* 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,v 1.1 2004/11/16 07:36:20 asmuts
Exp $
*/
public class TestDiskCacheNoMemory 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.
*/
public TestDiskCacheNoMemory( String testName )
{
super( testName );
}
/**
* Main method passes this test to the text test runner.
*/
public static void main( String args[] )
{
String[] testCaseName = {TestDiskCacheNoMemory.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 TestDiskCacheNoMemory( "testIndexedDiskCache1" )
{
public void runTest() throws Exception
{
this.runTestForRegion( "indexedRegion1" );
}
} );
suite.addTest( new TestDiskCacheNoMemory( "testIndexedDiskCache2" )
{
public void runTest() throws Exception
{
this.runTestForRegion( "indexedRegion2" );
}
} );
suite.addTest( new TestDiskCacheNoMemory( "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" );
this.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() );
}
}
1.1 jakarta-turbine-jcs/src/test/TestDiskCacheNoMemory.ccf
Index: TestDiskCacheNoMemory.ccf
===================================================================
# Cache configuration for the 'TestDiskCacheNoMemory' test. The memory cache
has a
# a maximum of 0 objects, so objects should get pushed into the disk cache
jcs.default=indexedDiskCache
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=0
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
# SYSTEM GROUP ID CACHE
jcs.system.groupIdCache=indexedDiskCache
jcs.system.groupIdCache.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.system.groupIdCache.cacheattributes.MaxObjects=0
jcs.system.groupIdCache.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
##### CACHE REGIONS FOR TEST
jcs.region.indexedRegion1=indexedDiskCache
jcs.region.indexedRegion1.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.indexedRegion1.cacheattributes.MaxObjects=0
jcs.region.indexedRegion1.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.indexedRegion2=indexedDiskCache
jcs.region.indexedRegion2.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.indexedRegion2.cacheattributes.MaxObjects=0
jcs.region.indexedRegion2.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.indexedRegion3=indexedDiskCache
jcs.region.indexedRegion3.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.indexedRegion3.cacheattributes.MaxObjects=0
jcs.region.indexedRegion3.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.indexedRegion4=indexedDiskCache2
jcs.region.indexedRegion4.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.indexedRegion4.cacheattributes.MaxObjects=0
jcs.region.indexedRegion4.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
##### AUXILIARY CACHES
# Indexed Disk Cache
jcs.auxiliary.indexedDiskCache=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
jcs.auxiliary.indexedDiskCache.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
jcs.auxiliary.indexedDiskCache.attributes.DiskPath=target/test-sandbox/indexed-disk-cache-nomemory
# Indexed Disk Cache
jcs.auxiliary.indexedDiskCache2=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
jcs.auxiliary.indexedDiskCache2.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
jcs.auxiliary.indexedDiskCache2.attributes.DiskPath=target/test-sandbox/indexed-disk-cache2-nomemory
1.1
jakarta-turbine-jcs/src/test-conf/TestDiskCacheNoMemory.ccf
Index: TestDiskCacheNoMemory.ccf
===================================================================
# Cache configuration for the 'TestDiskCacheNoMemory' test. The memory cache
has a
# a maximum of 0 objects, so objects should get pushed into the disk cache
jcs.default=indexedDiskCache
jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=0
jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
# SYSTEM GROUP ID CACHE
jcs.system.groupIdCache=indexedDiskCache
jcs.system.groupIdCache.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.system.groupIdCache.cacheattributes.MaxObjects=0
jcs.system.groupIdCache.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
##### CACHE REGIONS FOR TEST
jcs.region.indexedRegion1=indexedDiskCache
jcs.region.indexedRegion1.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.indexedRegion1.cacheattributes.MaxObjects=0
jcs.region.indexedRegion1.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.indexedRegion2=indexedDiskCache
jcs.region.indexedRegion2.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.indexedRegion2.cacheattributes.MaxObjects=0
jcs.region.indexedRegion2.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.indexedRegion3=indexedDiskCache
jcs.region.indexedRegion3.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.indexedRegion3.cacheattributes.MaxObjects=0
jcs.region.indexedRegion3.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
jcs.region.indexedRegion4=indexedDiskCache2
jcs.region.indexedRegion4.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
jcs.region.indexedRegion4.cacheattributes.MaxObjects=0
jcs.region.indexedRegion4.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
##### AUXILIARY CACHES
# Indexed Disk Cache
jcs.auxiliary.indexedDiskCache=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
jcs.auxiliary.indexedDiskCache.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
jcs.auxiliary.indexedDiskCache.attributes.DiskPath=target/test-sandbox/indexed-disk-cache-nomemory
# Indexed Disk Cache
jcs.auxiliary.indexedDiskCache2=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
jcs.auxiliary.indexedDiskCache2.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
jcs.auxiliary.indexedDiskCache2.attributes.DiskPath=target/test-sandbox/indexed-disk-cache2-nomemory
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]