net.sourceforge.rcache
Class BaseCacheTest

java.lang.Object
  extended by net.sourceforge.rcache.BaseCacheTest
Direct Known Subclasses:
SoftCacheTest, WeakCacheTest

public abstract class BaseCacheTest
extends java.lang.Object

Base class for deriving other test-cases.

Author:
Rodrigo Ruiz

Constructor Summary
BaseCacheTest()
           
 
Method Summary
protected  void check(double[] a1, double[] a2)
          Tests two arrays for equality.
protected  void check(long[] a1, long[] a2)
          Tests two arrays for equality.
protected abstract  BaseCache<java.lang.Integer,java.lang.Object> createCache()
          Creates a cache instance.
protected abstract  BaseCache<java.lang.Integer,java.lang.Object> createCache(int capacity)
          Creates a cache instance.
protected abstract  BaseCache<java.lang.Integer,java.lang.Object> createCache(int capacity, float factor)
          Creates a cache instance.
protected abstract  BaseCache<java.lang.Integer,java.lang.Object> createCache(int capacity, float factor, int level)
          Creates a cache instance.
protected  void forcePurge()
          Utility method that forces caches to be purged by demanding a huge amount of memory.
 void testGet()
          Test for Cache.get(Object).
 void testObjectMethods()
          Test for some methods inherited from Object.
 void testProfiler()
          Test for CacheProfiler.
 void testPurge()
          Tests that the cache has the correct number of items after a purge().
 void testRemove()
          Test for Cache.remove(Object).
 void testRemoveAndPut()
          Tests that the following sequence: cache.put(key, x) cache.remove(key) cache.put(key, y) Is safe.
 void testUnsupported()
          Test for unsupported methods in BaseCache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseCacheTest

public BaseCacheTest()
Method Detail

createCache

protected abstract BaseCache<java.lang.Integer,java.lang.Object> createCache()
Creates a cache instance.

Returns:
A Cache instance

createCache

protected abstract BaseCache<java.lang.Integer,java.lang.Object> createCache(int capacity)
Creates a cache instance.

Parameters:
capacity - Initial capacity
Returns:
A Cache instance

createCache

protected abstract BaseCache<java.lang.Integer,java.lang.Object> createCache(int capacity,
                                                                             float factor)
Creates a cache instance.

Parameters:
capacity - Initial capacity
factor - Load factor
Returns:
A Cache instance

createCache

protected abstract BaseCache<java.lang.Integer,java.lang.Object> createCache(int capacity,
                                                                             float factor,
                                                                             int level)
Creates a cache instance.

Parameters:
capacity - Initial capacity
factor - Load factor
level - Concurrency level
Returns:
A Cache instance

testGet

public final void testGet()
Test for Cache.get(Object).


testRemove

public final void testRemove()
Test for Cache.remove(Object).


testPurge

public final void testPurge()
Tests that the cache has the correct number of items after a purge().


testUnsupported

public final void testUnsupported()
Test for unsupported methods in BaseCache.


testRemoveAndPut

public final void testRemoveAndPut()
Tests that the following sequence: Is safe. This is, after a purge(), the cache MUST still maintain the association [key, y].


testObjectMethods

public final void testObjectMethods()
Test for some methods inherited from Object.


testProfiler

public final void testProfiler()
Test for CacheProfiler.


forcePurge

protected final void forcePurge()
Utility method that forces caches to be purged by demanding a huge amount of memory.


check

protected final void check(long[] a1,
                           long[] a2)
Tests two arrays for equality.

Parameters:
a1 - Left array
a2 - Right array

check

protected final void check(double[] a1,
                           double[] a2)
Tests two arrays for equality.

Parameters:
a1 - Left array
a2 - Right array


© 2007-2009 Rodrigo Ruiz
This site is hosted by