[infinispan-dev] Creating cache managers in your unit tests

Mircea Markus mircea.markus at jboss.com
Fri Jan 8 10:00:21 EST 2010


On Jan 8, 2010, at 1:52 PM, Vladimir Blagojevic wrote:

> 
> On 2010-01-04, at 1:02 PM, Mircea Markus wrote:
> 
>> 
>> As long as the CM are created through TestCacheManagersFactory, this should will soon not be an issue: https://jira.jboss.org/jira/browse/ISPN-314
> 
> It still is an issue when tests do not kill cache managers, is it not!
After https://jira.jboss.org/jira/browse/ISPN-314 will be implemented this should no longer be an issue.
> 
> However, we can still leverage the fact that we use TestCacheManagersFactory throughout.  
> 
> We can track all DefaultCacheManager(s) we create from TestCacheManagersFactory. We can use hashmap keyed by test class name
stop right here! :)
this is tricky with TestNG when it comes to inheritance.
BaseTest {
   testMethod() {
     TestCacheManagersFactory.getCacheManager(); 
   }
}

OtherTest extends BasteTest {
}

when running OtherTest.testMethod, the TestCacheManagersFactory.getCacheManager will appear as being called from BaseTest rather than the actual class which is OtherTest. This is why, in JBC , we pass the actual .class as a parameter to TestCacheManagersFactory.getCacheManager  

> and a value which is a list of all created DefaultCacheManager (in all test methods of a test class). Since lifecycle of DefaultCacheManager never spans across test classes we can find these cache manager and reclaim them in AbstractInfinispanTest @afterClass method.
> 
> 
> 
> _______________________________________________
> infinispan-dev mailing list
> infinispan-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/infinispan-dev





More information about the infinispan-dev mailing list