org.apache.ojb.broker
Class ObjectCacheTest

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended byorg.apache.ojb.broker.ObjectCacheTest
All Implemented Interfaces:
junit.framework.Test

public class ObjectCacheTest
extends junit.framework.TestCase

Do some basic tests using ObjectCache implementations.

Version:
$Id: ObjectCacheTest.java,v 1.13 2004/01/04 23:51:40 arminw Exp $
Author:
Armin Waibel, Thomas Mahler

Nested Class Summary
static class ObjectCacheTest.CacheFilterObject
          in class-descriptor CacheFilter attribute 'cacheable=false' is declared
static class ObjectCacheTest.CacheObject
           
static class ObjectCacheTest.TestObjectDefaultCache
           
static class ObjectCacheTest.TestObjectEmptyCache
          in class-descriptor ObjectCacheEmptyImpl class is declared as cache implementation.
 
Field Summary
(package private)  java.lang.String[] cacheFilter
           
(package private) static java.lang.String EXCLUDE_PACKAGE
           
(package private) static java.lang.String EXCLUDE_PACKAGE_NOT_EXIST
           
(package private)  java.lang.Class[] objectCacheImpls
           
(package private)  java.lang.String[] old_CacheFilter
           
(package private)  java.lang.Class old_ObjectCache
           
 
Constructor Summary
ObjectCacheTest(java.lang.String s)
           
 
Method Summary
static void main(java.lang.String[] args)
           
protected  void setUp()
           
protected  void tearDown()
           
 void testCacheFilterFunctions()
          This test check the CacheFilter feature and the two standard implementations enable per class and per package out-filtering of objects.
 void testJCSPerClassObjectCacheImplementation()
          Test the JCS cache implementation.
 void testObjectCacheDefaultImpl()
           
 void testObjectCacheDefaultImplTimeout()
           
 void testPerClassCache()
          Test per class ObjectCache declaration.
 void testPerDatabaseCache()
          Read a specific jdbc-connction-descriptor at runtime, merge it with current ConnectionRepository, lookup a specific PersistenceBroker instance, get ObjectCache.
 void testSimpleObjectCacheFunctions()
          Check base caching functions of some cache implementations.
 void YYYtestCacheIsolation()
          This test checks if the caches of two different brokers are properly isolated.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EXCLUDE_PACKAGE

static final java.lang.String EXCLUDE_PACKAGE
See Also:
Constant Field Values

EXCLUDE_PACKAGE_NOT_EXIST

static final java.lang.String EXCLUDE_PACKAGE_NOT_EXIST
See Also:
Constant Field Values

objectCacheImpls

java.lang.Class[] objectCacheImpls

cacheFilter

java.lang.String[] cacheFilter

old_ObjectCache

java.lang.Class old_ObjectCache

old_CacheFilter

java.lang.String[] old_CacheFilter
Constructor Detail

ObjectCacheTest

public ObjectCacheTest(java.lang.String s)
Method Detail

main

public static void main(java.lang.String[] args)

setUp

protected void setUp()
              throws java.lang.Exception
Throws:
java.lang.Exception

tearDown

protected void tearDown()
                 throws java.lang.Exception
Throws:
java.lang.Exception

testJCSPerClassObjectCacheImplementation

public void testJCSPerClassObjectCacheImplementation()
                                              throws java.lang.Exception
Test the JCS cache implementation. In JCS config file the following properties are set:
jcs.region.org.apache.ojb.broker.ObjectCacheTest$CacheObject.cacheattributes.MaxObjects=3 jcs.region.org.apache.ojb.broker.ObjectCacheTest$CacheObject.cacheattributes.MaxMemoryIdleTimeSeconds=2 jcs.region.org.apache.ojb.broker.ObjectCacheTest$CacheObject.cacheattributes.UseMemoryShrinker=true jcs.region.org.apache.ojb.broker.ObjectCacheTest$CacheObject.cacheattributes.ShrinkerIntervalSeconds=1

Throws:
java.lang.Exception

testObjectCacheDefaultImplTimeout

public void testObjectCacheDefaultImplTimeout()
                                       throws java.lang.Exception
Throws:
java.lang.Exception

testObjectCacheDefaultImpl

public void testObjectCacheDefaultImpl()
                                throws java.lang.Exception
Throws:
java.lang.Exception

testCacheFilterFunctions

public void testCacheFilterFunctions()
                              throws java.lang.Exception
This test check the CacheFilter feature and the two standard implementations enable per class and per package out-filtering of objects.

Throws:
java.lang.Exception

testSimpleObjectCacheFunctions

public void testSimpleObjectCacheFunctions()
                                    throws java.lang.Exception
Check base caching functions of some cache implementations.

Throws:
java.lang.Exception

testPerClassCache

public void testPerClassCache()
                       throws java.lang.Exception
Test per class ObjectCache declaration. 'TestObjectEmptyCache' class metadata declare an 'empty ObjectCache' implementation as cache, CacheObject use the default ObjectCache implementation. Thus we should found 'CacheObject' instance in cache, but NOT found 'TestObjectEmptyCache' instance.

Throws:
java.lang.Exception

testPerDatabaseCache

public void testPerDatabaseCache()
Read a specific jdbc-connction-descriptor at runtime, merge it with current ConnectionRepository, lookup a specific PersistenceBroker instance, get ObjectCache. This should be ObjectCacheEmptyImpl, because this is declared at jdbc-connection-descriptor level.


YYYtestCacheIsolation

public void YYYtestCacheIsolation()
                           throws java.lang.Exception
This test checks if the caches of two different brokers are properly isolated. changes made to an object in tx1 should not be visible in tx2 ! TODO: once we work without global cache only (e.g. intern temporary cache), this test should pass!

Throws:
java.lang.Exception


Authors: Thomas Mahler and others. (C) 2000 - 2003 Apache Software Foundation
All rights reserved. Published under the Apache License.
http://db.apache.org/ojb
Version: 1.0.rc5, 2003-12-14