Class AbstractCacheUnitThreadTest

    • Constructor Detail

      • AbstractCacheUnitThreadTest

        public AbstractCacheUnitThreadTest()
    • Method Detail

      • testMultiThreadedAccessAndMemory

        public void testMultiThreadedAccessAndMemory()
                                              throws java.lang.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:
        java.lang.InterruptedException
      • testExclusiveUnitAddToCache

        public void testExclusiveUnitAddToCache()
                                         throws java.lang.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:
        java.lang.InterruptedException
      • testExclusiveComputation

        public void testExclusiveComputation()
                                      throws java.lang.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:
        java.lang.InterruptedException