This is an automated email from the ASF dual-hosted git repository. asf-gitbox-commits pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-jcs.git
commit c69344076170ad688bec4f5cb716a77093400299 Author: Thomas Vandahl <[email protected]> AuthorDate: Tue Sep 8 21:36:31 2026 +0200 Use thread pool, also test FIFO Cache --- .../apache/commons/jcs4/JCSConcurrentCacheAccessUnitTest.java | 11 ++++++++++- commons-jcs4-core/src/test/test-conf/TestJCS-73.ccf | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/JCSConcurrentCacheAccessUnitTest.java b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/JCSConcurrentCacheAccessUnitTest.java index 41c3ef6d..42b5bdc8 100644 --- a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/JCSConcurrentCacheAccessUnitTest.java +++ b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/JCSConcurrentCacheAccessUnitTest.java @@ -24,6 +24,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; @@ -111,6 +113,11 @@ class JCSConcurrentCacheAccessUnitTest private final static int THREADS = 20; private final static int LOOPS = 10000; + /** + * the thread pool + */ + protected ExecutorService pool; + /** * the group name */ @@ -131,6 +138,7 @@ class JCSConcurrentCacheAccessUnitTest throws Exception { JCS.setConfigFilename( "/TestJCS-73.ccf" ); + pool = Executors.newFixedThreadPool(THREADS); errcount = new AtomicInteger(); valueMismatchList = new CopyOnWriteArrayList<>(); } @@ -146,7 +154,7 @@ class JCSConcurrentCacheAccessUnitTest for (int i = 0; i < THREADS; i++) { final String threadName = "Thread-" + i; - new Thread(() -> work(cache, threadName, latch)).start(); + pool.execute(() -> work(cache, threadName, latch)); } latch.await(THREADS, TimeUnit.SECONDS); @@ -177,6 +185,7 @@ class JCSConcurrentCacheAccessUnitTest testConcurrentAccess("soft_cache"); testConcurrentAccess("lru_cache"); testConcurrentAccess("mru_cache"); + testConcurrentAccess("fifo_cache"); testConcurrentAccess("lru_cache_with_disk"); } } diff --git a/commons-jcs4-core/src/test/test-conf/TestJCS-73.ccf b/commons-jcs4-core/src/test/test-conf/TestJCS-73.ccf index f31d7f43..d0b1e9bb 100644 --- a/commons-jcs4-core/src/test/test-conf/TestJCS-73.ccf +++ b/commons-jcs4-core/src/test/test-conf/TestJCS-73.ccf @@ -33,6 +33,9 @@ jcs.region.lru_cache_with_disk.cacheattributes.MaxObjects=10000 jcs.region.mru_cache= jcs.region.mru_cache.cacheattributes.MemoryCacheName=org.apache.commons.jcs4.engine.memory.mru.MRUMemoryCache +jcs.region.fifo_cache= +jcs.region.fifo_cache.cacheattributes.MemoryCacheName=org.apache.commons.jcs4.engine.memory.fifo.FIFOMemoryCache + jcs.region.lhm_cache= jcs.region.lhm_cache.cacheattributes.MemoryCacheName=org.apache.commons.jcs4.engine.memory.lru.LHMLRUMemoryCache
