Class AbstractCacheUnitThreadTest

java.lang.Object
de.hybris.platform.testframework.HybrisJUnit4Test
de.hybris.platform.test.AbstractCacheUnitThreadTest
All Implemented Interfaces:
JaloSessionHolder

public class AbstractCacheUnitThreadTest extends HybrisJUnit4Test
Test AbstractCacheUnit and Cache behavior, especially in multi-threaded mode.
  • Constructor Details

    • AbstractCacheUnitThreadTest

      public AbstractCacheUnitThreadTest()
  • Method Details

    • testMultiThreadedAccessAndMemory

      public void testMultiThreadedAccessAndMemory() throws InterruptedException
      Tests multiple threads accessing AbstractCacheUnit and implicitely Cache, 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:
      InterruptedException
    • testExclusiveUnitAddToCache

      public void testExclusiveUnitAddToCache() throws InterruptedException
      Tests whether Cache.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:
      InterruptedException
    • testExclusiveComputation

      public void testExclusiveComputation() throws InterruptedException
      Tests whether AbstractCacheUnit.compute() is really working exclusively when Cache.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:
      InterruptedException