Package de.hybris.platform.test
Class AbstractCacheUnitThreadTest
- java.lang.Object
-
- de.hybris.platform.testframework.HybrisJUnit4Test
-
- de.hybris.platform.test.AbstractCacheUnitThreadTest
-
- All Implemented Interfaces:
JaloSessionHolder
public class AbstractCacheUnitThreadTest extends HybrisJUnit4Test
TestAbstractCacheUnit
andCache
behavior, especially in multi-threaded mode.
-
-
Field Summary
-
Fields inherited from class de.hybris.platform.testframework.HybrisJUnit4Test
jaloSession
-
-
Constructor Summary
Constructors Constructor Description AbstractCacheUnitThreadTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
testExclusiveComputation()
Tests whetherAbstractCacheUnit.compute()
is really working exclusively whenCache.isForceExclusiveComputation()
is switched on.void
testExclusiveUnitAddToCache()
Tests whetherCache.getOrAddUnit(AbstractCacheUnit)
is ensuring that only one unit per key is being added even if multiple threads are trying that at the same time.void
testMultiThreadedAccessAndMemory()
Tests multiple threads accessingAbstractCacheUnit
and implicitelyCache
, without testing for correctness! Instead it compares the memory before access, after filling up and after clearing the cache.-
Methods inherited from class de.hybris.platform.testframework.HybrisJUnit4Test
establishJaloSession, finish, getOrCreateCurrency, getOrCreateLanguage, init, intenseChecksActivated, takeJaloSession
-
-
-
-
Method Detail
-
testMultiThreadedAccessAndMemory
public void testMultiThreadedAccessAndMemory() throws java.lang.InterruptedException
Tests multiple threads accessingAbstractCacheUnit
and implicitelyCache
, without testing for correctness! Instead it compares the memory before access, after filling up and after clearing the cache. The test will fail if after clear the memory gain is higher than a allowed gain (atm 50 bytes per thread, which is 5000 bytes for 100 threads).- Throws:
java.lang.InterruptedException
-
testExclusiveUnitAddToCache
public void testExclusiveUnitAddToCache() throws java.lang.InterruptedException
Tests whetherCache.getOrAddUnit(AbstractCacheUnit)
is ensuring that only one unit per key is being added even if multiple threads are trying that at the same time. To enforce potential errors the test runs several turns of all threads trying to add a unit with the same key per turn.- Throws:
java.lang.InterruptedException
-
testExclusiveComputation
public void testExclusiveComputation() throws java.lang.InterruptedException
Tests whetherAbstractCacheUnit.compute()
is really working exclusively whenCache.isForceExclusiveComputation()
is switched on. To test this we let many threads try to access the cache using one unit per thread having the same key.- Throws:
java.lang.InterruptedException
-
-