This is an automated email from the ASF dual-hosted git repository.

tv pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-jcs.git

commit 8acc64ddac52be1555593a662ec2cfe296b1672c
Author: Thomas Vandahl <[email protected]>
AuthorDate: Mon Feb 9 16:25:14 2026 +0100

    Move test-related methods to test code
---
 .../jcs4/engine/CompositeCacheAttributes.java      | 123 +------------------
 .../commons/jcs4/engine/ElementAttributes.java     | 136 +--------------------
 .../jcs4/engine/behavior/IElementAttributes.java   |  14 ---
 .../serialization/SerializationConversionUtil.java |   7 --
 .../commons/jcs4/access/CacheAccessUnitTest.java   |  28 ++---
 .../disk/block/AbstractBlockDiskCacheUnitTest.java |   9 +-
 .../indexed/AbstractIndexDiskCacheUnitTest.java    |  12 +-
 .../indexed/IndexedDiskCacheKeyStoreUnitTest.java  |   9 +-
 .../remote/RemoteCacheListenerUnitTest.java        |   7 +-
 .../jcs4/engine/ElementAttributesUtils.java        |  30 -----
 .../jcs4/engine/TestCompositeCacheAttributes.java  | 118 ++++++++++++++++++
 .../commons/jcs4/engine/TestElementAttributes.java |  76 ++++++++++++
 .../control/CompositeCacheDiskUsageUnitTest.java   |  37 +++---
 .../engine/control/CompositeCacheUnitTest.java     |  31 ++---
 .../memory/fifo/FIFOMemoryCacheUnitTest.java       |  15 ++-
 .../memory/shrinking/ShrinkerThreadUnitTest.java   | 101 ++++++---------
 .../SerializationConversionUtilUnitTest.java       |  13 +-
 17 files changed, 304 insertions(+), 462 deletions(-)

diff --git 
a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/CompositeCacheAttributes.java
 
b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/CompositeCacheAttributes.java
index 5fecf458..83348105 100644
--- 
a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/CompositeCacheAttributes.java
+++ 
b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/CompositeCacheAttributes.java
@@ -119,8 +119,7 @@ public record CompositeCacheAttributes(
     /**
      * Sets the name of the cache, referenced by the appropriate manager.
      *
-     * @param s
-     *            The new cacheName value
+     * @param s The new cacheName value
      */
     @Override
     public CompositeCacheAttributes withCacheName(String s)
@@ -138,126 +137,6 @@ public record CompositeCacheAttributes(
                 spoolChunkSize());
     }
 
-    /**
-     * Sets the size of the cache.
-     *
-     * @param maxObjects the new maxObjects value
-     */
-    public CompositeCacheAttributes withMaxObjects(int maxObjects)
-    {
-        return new CompositeCacheAttributes(cacheName(),
-                maxObjects,
-                useLateral(),
-                useDisk(),
-                useMemoryShrinker(),
-                shrinkerIntervalSeconds(),
-                maxSpoolPerRun(),
-                maxMemoryIdleTimeSeconds(),
-                memoryCacheName(),
-                diskUsagePattern(),
-                spoolChunkSize());
-    }
-
-    /**
-     * Sets the maximum number of elements to spool per shrinker run.
-     *
-     * @param maxSpoolPerRun the new maxSpoolPerRun value
-     */
-    public CompositeCacheAttributes withMaxSpoolPerRun(int maxSpoolPerRun)
-    {
-        return new CompositeCacheAttributes(cacheName(),
-                maxObjects(),
-                useLateral(),
-                useDisk(),
-                useMemoryShrinker(),
-                shrinkerIntervalSeconds(),
-                maxSpoolPerRun,
-                maxMemoryIdleTimeSeconds(),
-                memoryCacheName(),
-                diskUsagePattern(),
-                spoolChunkSize());
-    }
-
-    /**
-     * Sets the maximum memory idle-time in seconds of the cache.
-     *
-     * @param maxMemoryIdleTimeSeconds the new maxMemoryIdleTimeSeconds value
-     */
-    public CompositeCacheAttributes withMaxMemoryIdleTimeSeconds(long 
maxMemoryIdleTimeSeconds)
-    {
-        return new CompositeCacheAttributes(cacheName(),
-                maxObjects(),
-                useLateral(),
-                useDisk(),
-                useMemoryShrinker(),
-                shrinkerIntervalSeconds(),
-                maxSpoolPerRun(),
-                maxMemoryIdleTimeSeconds,
-                memoryCacheName(),
-                diskUsagePattern(),
-                spoolChunkSize());
-    }
-
-    /**
-     * Sets the memory cache name of the cache.
-     *
-     * @param memoryCacheName the new memoryCacheName value
-     */
-    public CompositeCacheAttributes withMemoryCacheName(String memoryCacheName)
-    {
-        return new CompositeCacheAttributes(cacheName(),
-                maxObjects(),
-                useLateral(),
-                useDisk(),
-                useMemoryShrinker(),
-                shrinkerIntervalSeconds(),
-                maxSpoolPerRun(),
-                maxMemoryIdleTimeSeconds(),
-                memoryCacheName,
-                diskUsagePattern(),
-                spoolChunkSize());
-    }
-
-    /**
-     * Sets the disk usage pattern of the cache.
-     *
-     * @param diskUsagePattern the new diskUsagePattern value
-     */
-    public CompositeCacheAttributes withDiskUsagePattern(DiskUsagePattern 
diskUsagePattern)
-    {
-        return new CompositeCacheAttributes(cacheName(),
-                maxObjects(),
-                useLateral(),
-                useDisk(),
-                useMemoryShrinker(),
-                shrinkerIntervalSeconds(),
-                maxSpoolPerRun(),
-                maxMemoryIdleTimeSeconds(),
-                memoryCacheName(),
-                diskUsagePattern,
-                spoolChunkSize());
-    }
-
-    /**
-     * Sets the spool chunk size of the cache.
-     *
-     * @param spoolChunkSize the new spoolChunkSize value
-     */
-    public CompositeCacheAttributes withSpoolChunkSize(int spoolChunkSize)
-    {
-        return new CompositeCacheAttributes(cacheName(),
-                maxObjects(),
-                useLateral(),
-                useDisk(),
-                useMemoryShrinker(),
-                shrinkerIntervalSeconds(),
-                maxSpoolPerRun(),
-                maxMemoryIdleTimeSeconds(),
-                memoryCacheName(),
-                diskUsagePattern(),
-                spoolChunkSize);
-    }
-
     /**
      * Dumps the core attributes.
      *
diff --git 
a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/ElementAttributes.java
 
b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/ElementAttributes.java
index 01a05c5f..d56a424d 100644
--- 
a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/ElementAttributes.java
+++ 
b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/ElementAttributes.java
@@ -20,7 +20,6 @@ package org.apache.commons.jcs4.engine;
  */
 
 import java.util.ArrayList;
-import java.util.List;
 import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.commons.jcs4.engine.behavior.IElementAttributes;
@@ -63,9 +62,6 @@ public record ElementAttributes(
          */
         long maxIdleTime,
 
-        /** The byte size of the field. Must be manually set. */
-        int size,
-
         /** The creation time. This is used to enforce the max life. */
         long createTime,
 
@@ -112,7 +108,6 @@ public record ElementAttributes(
             DEFAULT_MAX_LIFE,
             DEFAULT_MAX_IDLE_TIME,
             0,
-            0,
             new AtomicLong(),
             DEFAULT_TIME_FACTOR,
             new ArrayList<>());
@@ -145,7 +140,6 @@ public record ElementAttributes(
              from.isEternal(),
              from.maxLife(),
              from.maxIdleTime(),
-             from.size(),
              System.currentTimeMillis(),
              new AtomicLong(from.lastAccessTime()),
              from.timeFactorForMilliseconds(),
@@ -165,119 +159,13 @@ public record ElementAttributes(
             long timeFactorForMilliseconds
           )
     {
-        this(isSpool, isLateral, isRemote, isEternal, maxLife, maxIdleTime, 0,
+        this(isSpool, isLateral, isRemote, isEternal, maxLife, maxIdleTime,
                 System.currentTimeMillis(), new AtomicLong(), 
timeFactorForMilliseconds,
                 new ArrayList<>());
 
         this.atomicLastAccessTime.set(createTime());
     }
 
-    /**
-     * Sets the isSpool attribute of the ElementAttributes object
-     * @param val The new isSpool value
-     */
-    public ElementAttributes withIsSpool( boolean val )
-    {
-        return new ElementAttributes(
-                val,
-                isLateral(),
-                isRemote(),
-                isEternal(),
-                maxLife(),
-                maxIdleTime(),
-                size(),
-                System.currentTimeMillis(),
-                new AtomicLong(lastAccessTime()),
-                timeFactorForMilliseconds(),
-                new ArrayList<>(elementEventHandlers()));
-    }
-
-    /**
-     * Sets the isEternal attribute of the ElementAttributes object
-     * @param val The new isEternal value
-     */
-    public ElementAttributes withIsEternal( boolean val )
-    {
-        return new ElementAttributes(
-                isSpool(),
-                isLateral(),
-                isRemote(),
-                val,
-                maxLife(),
-                maxIdleTime(),
-                size(),
-                System.currentTimeMillis(),
-                new AtomicLong(lastAccessTime()),
-                timeFactorForMilliseconds(),
-                new ArrayList<>(elementEventHandlers()));
-    }
-
-    /**
-     * Sets the maxLife attribute of the ElementAttributes object.
-     *
-     * @param mls The new MaxLifeSeconds value
-     */
-    public ElementAttributes withMaxLife(long mls)
-    {
-        return new ElementAttributes(
-                isSpool(),
-                isLateral(),
-                isRemote(),
-                isEternal(),
-                mls,
-                maxIdleTime(),
-                size(),
-                System.currentTimeMillis(),
-                new AtomicLong(lastAccessTime()),
-                timeFactorForMilliseconds(),
-                new ArrayList<>(elementEventHandlers()));
-    }
-
-    /**
-     * Sets the idleTime attribute of the ElementAttributes object. This is 
the maximum time the item can
-     * be idle in the cache, that is not accessed.
-     * <p>
-     * If this is exceeded the element will not be returned, instead it will 
be removed. It will be
-     * removed on retrieval, or removed actively if the memory shrinker is 
turned on.
-     * @param idle The new idleTime value
-     */
-    public ElementAttributes withMaxIdleTime(long idle)
-    {
-        return new ElementAttributes(
-                isSpool(),
-                isLateral(),
-                isRemote(),
-                isEternal(),
-                maxLife(),
-                idle,
-                size(),
-                System.currentTimeMillis(),
-                new AtomicLong(lastAccessTime()),
-                timeFactorForMilliseconds(),
-                new ArrayList<>(elementEventHandlers()));
-    }
-
-    /**
-     * Sets the size attribute of the ElementAttributes object.
-     *
-     * @param size The new size value
-     */
-    public ElementAttributes withSize(int size)
-    {
-        return new ElementAttributes(
-                isSpool(),
-                isLateral(),
-                isRemote(),
-                isEternal(),
-                maxLife(),
-                maxIdleTime(),
-                size,
-                System.currentTimeMillis(),
-                new AtomicLong(lastAccessTime()),
-                timeFactorForMilliseconds(),
-                new ArrayList<>(elementEventHandlers()));
-    }
-
     /**
      * Adds a ElementEventHandler. Handler's can be registered for multiple 
events. A registered
      * handler will be called at every recognized event.
@@ -293,28 +181,6 @@ public record ElementAttributes(
         this.elementEventHandlers.add( eventHandler );
     }
 
-    /**
-     * Sets the eventHandlers of the IElementAttributes object.
-     * <p>
-     * This add the references to the local list. Subsequent changes in the 
caller's list will not
-     * be reflected.
-     *
-     * @param eventHandlers List of IElementEventHandler objects
-     */
-    @Override
-    public void addElementEventHandlers( final List<IElementEventHandler> 
eventHandlers )
-    {
-        if ( eventHandlers == null )
-        {
-            return;
-        }
-
-        for (final IElementEventHandler handler : eventHandlers)
-        {
-            addElementEventHandler(handler);
-        }
-    }
-
     /**
      * Gets the LastAccess attribute of the IAttributes object.
      *
diff --git 
a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/IElementAttributes.java
 
b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/IElementAttributes.java
index aff279eb..5e5af150 100644
--- 
a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/IElementAttributes.java
+++ 
b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/engine/behavior/IElementAttributes.java
@@ -21,7 +21,6 @@ package org.apache.commons.jcs4.engine.behavior;
 
 import java.io.Serializable;
 import java.util.ArrayList;
-import java.util.List;
 
 import 
org.apache.commons.jcs4.engine.control.event.behavior.IElementEventHandler;
 
@@ -39,12 +38,6 @@ public interface IElementAttributes extends Serializable
      */
     void addElementEventHandler( IElementEventHandler eventHandler );
 
-    /**
-     * Sets the eventHandlers of the IElementAttributes object
-     * @param eventHandlers value
-     */
-    void addElementEventHandlers( List<IElementEventHandler> eventHandlers );
-
     /**
      * Gets the elementEventHandlers.
      * <p>
@@ -118,13 +111,6 @@ public interface IElementAttributes extends Serializable
      */
     long maxLife();
 
-    /**
-     * Gets the size attribute of the IAttributes object
-     *
-     * @return The size value
-     */
-    int size();
-
     /**
      * Get the time factor to convert durations to milliseconds
      * @return The time factor to convert durations to milliseconds
diff --git 
a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/serialization/SerializationConversionUtil.java
 
b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/serialization/SerializationConversionUtil.java
index b057ab82..d6193849 100644
--- 
a/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/serialization/SerializationConversionUtil.java
+++ 
b/commons-jcs4-core/src/main/java/org/apache/commons/jcs4/utils/serialization/SerializationConversionUtil.java
@@ -23,10 +23,8 @@ import java.io.IOException;
 
 import org.apache.commons.jcs4.engine.CacheElement;
 import org.apache.commons.jcs4.engine.CacheElementSerialized;
-import org.apache.commons.jcs4.engine.ElementAttributes;
 import org.apache.commons.jcs4.engine.behavior.ICacheElement;
 import org.apache.commons.jcs4.engine.behavior.ICacheElementSerialized;
-import org.apache.commons.jcs4.engine.behavior.IElementAttributes;
 import org.apache.commons.jcs4.engine.behavior.IElementSerializer;
 import org.apache.commons.jcs4.log.Log;
 
@@ -115,11 +113,6 @@ public class SerializationConversionUtil
             try
             {
                 serializedValue = 
elementSerializer.serialize(element.getVal());
-
-                // update size in bytes
-                IElementAttributes copy = new 
ElementAttributes(element.getElementAttributes())
-                        .withSize(serializedValue.length);
-                element.setElementAttributes(copy);
             }
             catch ( final IOException e )
             {
diff --git 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/CacheAccessUnitTest.java
 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/CacheAccessUnitTest.java
index 5bd4028d..02e4dfb6 100644
--- 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/CacheAccessUnitTest.java
+++ 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/access/CacheAccessUnitTest.java
@@ -36,6 +36,8 @@ import 
org.apache.commons.jcs4.access.exception.CacheException;
 import org.apache.commons.jcs4.access.exception.ObjectExistsException;
 import org.apache.commons.jcs4.engine.CompositeCacheAttributes;
 import org.apache.commons.jcs4.engine.ElementAttributes;
+import org.apache.commons.jcs4.engine.TestCompositeCacheAttributes;
+import org.apache.commons.jcs4.engine.TestElementAttributes;
 import org.apache.commons.jcs4.engine.behavior.ICacheElement;
 import org.apache.commons.jcs4.engine.behavior.ICompositeCacheAttributes;
 import org.junit.jupiter.api.Test;
@@ -109,13 +111,11 @@ class CacheAccessUnitTest
         final String keyprefix1 = "MyPrefix1";
         final String keyprefix2 = "MyPrefix2";
         final String memoryCacheClassName = 
"org.apache.commons.jcs4.engine.memory.lru.LRUMemoryCache";
-        final CompositeCacheAttributes cattr = 
CompositeCacheAttributes.defaults()
-                .withMemoryCacheName( memoryCacheClassName )
-                .withMaxObjects(maxMemorySize);
+        final CompositeCacheAttributes cattr = TestCompositeCacheAttributes
+                .withMemoryCacheNameAndMaxObjects(memoryCacheClassName, 
maxMemorySize);
 
         final long maxLife = 9876;
-        final ElementAttributes attr = ElementAttributes.defaults()
-                .withMaxLife(maxLife);
+        final ElementAttributes attr = 
TestElementAttributes.withEternalFalseAndMaxLife(maxLife);
 
         final CacheAccess<String, Integer> access = JCS.getInstance( 
"testGetMatching_Normal", cattr, attr );
 
@@ -164,13 +164,11 @@ class CacheAccessUnitTest
         final String keyprefix1 = "MyPrefix1";
         final String keyprefix2 = "MyPrefix2";
         final String memoryCacheClassName = 
"org.apache.commons.jcs4.engine.memory.lru.LRUMemoryCache";
-        final CompositeCacheAttributes cattr = 
CompositeCacheAttributes.defaults()
-                .withMemoryCacheName( memoryCacheClassName )
-                .withMaxObjects(maxMemorySize);
+        final CompositeCacheAttributes cattr = TestCompositeCacheAttributes
+                .withMemoryCacheNameAndMaxObjects(memoryCacheClassName, 
maxMemorySize);
 
         final long maxLife = 9876;
-        final ElementAttributes attr = ElementAttributes.defaults()
-                .withMaxLife(maxLife);
+        final ElementAttributes attr = 
TestElementAttributes.withEternalFalseAndMaxLife(maxLife);
 
         final CacheAccess<String, Integer> access = JCS.getInstance( 
"testGetMatching_Normal", cattr, attr );
 
@@ -310,7 +308,7 @@ class CacheAccessUnitTest
         throws Exception
     {
         final long maxIdleTime = 8765;
-        final CompositeCacheAttributes ca = CompositeCacheAttributes.defaults()
+        final CompositeCacheAttributes ca = TestCompositeCacheAttributes
                 .withMaxMemoryIdleTimeSeconds(maxIdleTime);
 
         final CacheAccess<String, String> access = JCS.getInstance( 
"testRegionDefinitonWithAttributes", ca );
@@ -330,12 +328,11 @@ class CacheAccessUnitTest
         throws Exception
     {
         final long maxIdleTime = 8765;
-        final CompositeCacheAttributes ca = CompositeCacheAttributes.defaults()
+        final CompositeCacheAttributes ca = TestCompositeCacheAttributes
                 .withMaxMemoryIdleTimeSeconds(maxIdleTime);
 
         final long maxLife = 9876;
-        final ElementAttributes attr = ElementAttributes.defaults()
-                .withMaxLife(maxLife);
+        final ElementAttributes attr = 
TestElementAttributes.withEternalFalseAndMaxLife(maxLife);
 
         final CacheAccess<String, String> access = JCS.getInstance( 
"testRegionDefinitonWithAttributes", ca, attr );
         assertNotNull( access, "We should have an access class" );
@@ -356,8 +353,7 @@ class CacheAccessUnitTest
         assertNotNull( access, "We should have an access class" );
 
         final long maxLife = 9876;
-        final ElementAttributes attr = ElementAttributes.defaults()
-                .withMaxLife(maxLife);
+        final ElementAttributes attr = 
TestElementAttributes.withEternalFalseAndMaxLife(maxLife);
 
         access.setDefaultElementAttributes( attr );
 
diff --git 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/block/AbstractBlockDiskCacheUnitTest.java
 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/block/AbstractBlockDiskCacheUnitTest.java
index e5b2e636..efde683c 100644
--- 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/block/AbstractBlockDiskCacheUnitTest.java
+++ 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/block/AbstractBlockDiskCacheUnitTest.java
@@ -336,8 +336,7 @@ public abstract class AbstractBlockDiskCacheUnitTest{
             final CacheElement<GroupAttrName<String>, String> element = new 
CacheElement<>(cacheName,
                 groupAttrName, "data:" + i);
 
-            final ElementAttributes eAttr = ElementAttributes.defaults()
-                    .withIsSpool(true);
+            final ElementAttributes eAttr = ElementAttributes.defaults();
             element.setElementAttributes(eAttr);
 
             disk.processUpdate(element);
@@ -386,8 +385,7 @@ public abstract class AbstractBlockDiskCacheUnitTest{
         final int cnt = 25;
         for (int i = 0; i < cnt; i++)
         {
-            final ElementAttributes eAttr = ElementAttributes.defaults()
-                    .withIsSpool(true);
+            final ElementAttributes eAttr = ElementAttributes.defaults();
             final ICacheElement<String, String> element = new 
CacheElement<>("testRemove_PartialKey", i + ":key", "data:"
                 + i);
             element.setElementAttributes(eAttr);
@@ -429,8 +427,7 @@ public abstract class AbstractBlockDiskCacheUnitTest{
         final int cnt = 25;
         for (int i = 0; i < cnt; i++)
         {
-            final ElementAttributes eAttr = ElementAttributes.defaults()
-                    .withIsSpool(true);
+            final ElementAttributes eAttr = ElementAttributes.defaults();
             final ICacheElement<String, String> element = new 
CacheElement<>("testRemoveItems", "key:" + i, "data:" + i);
             element.setElementAttributes(eAttr);
             disk.processUpdate(element);
diff --git 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/indexed/AbstractIndexDiskCacheUnitTest.java
 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/indexed/AbstractIndexDiskCacheUnitTest.java
index af3cc81a..82555d27 100644
--- 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/indexed/AbstractIndexDiskCacheUnitTest.java
+++ 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/indexed/AbstractIndexDiskCacheUnitTest.java
@@ -704,8 +704,7 @@ public abstract class AbstractIndexDiskCacheUnitTest{
             final CacheElement<GroupAttrName<String>, String> element = new 
CacheElement<>(cacheName,
                 groupAttrName, "data:" + i);
 
-            final ElementAttributes eAttr = ElementAttributes.defaults()
-                    .withIsSpool(true);
+            final ElementAttributes eAttr = ElementAttributes.defaults();
             element.setElementAttributes(eAttr);
 
             disk.processUpdate(element);
@@ -754,8 +753,7 @@ public abstract class AbstractIndexDiskCacheUnitTest{
         final int cnt = 25;
         for (int i = 0; i < cnt; i++)
         {
-            final ElementAttributes eAttr = ElementAttributes.defaults()
-                    .withIsSpool(true);
+            final ElementAttributes eAttr = ElementAttributes.defaults();
             final ICacheElement<String, String> element = new 
CacheElement<>("testRemove_PartialKey", i + ":key", "data:"
                 + i);
             element.setElementAttributes(eAttr);
@@ -828,8 +826,7 @@ public abstract class AbstractIndexDiskCacheUnitTest{
         final int cnt = 25;
         for (int i = 0; i < cnt; i++)
         {
-            final ElementAttributes eAttr = ElementAttributes.defaults()
-                    .withIsSpool(true);
+            final ElementAttributes eAttr = ElementAttributes.defaults();
             final ICacheElement<String, String> element = new 
CacheElement<>("testRemoveItems", "key:" + i, "data:" + i);
             element.setElementAttributes(eAttr);
             disk.processUpdate(element);
@@ -863,8 +860,7 @@ public abstract class AbstractIndexDiskCacheUnitTest{
         final int cnt = 999;
         for (int i = 0; i < cnt; i++)
         {
-            final ElementAttributes eAttr = ElementAttributes.defaults()
-                    .withIsSpool(true);
+            final ElementAttributes eAttr = ElementAttributes.defaults();
             final ICacheElement<String, String> element = new 
CacheElement<>("testSimplePutAndGet", "key:" + i, "data:" + i);
             element.setElementAttributes(eAttr);
             disk.processUpdate(element);
diff --git 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/indexed/IndexedDiskCacheKeyStoreUnitTest.java
 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/indexed/IndexedDiskCacheKeyStoreUnitTest.java
index 6380c594..a5bc2c38 100644
--- 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/indexed/IndexedDiskCacheKeyStoreUnitTest.java
+++ 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/disk/indexed/IndexedDiskCacheKeyStoreUnitTest.java
@@ -56,8 +56,7 @@ class IndexedDiskCacheKeyStoreUnitTest
         final int cnt = 25;
         for ( int i = 0; i < cnt; i++ )
         {
-            final ElementAttributes eAttr = ElementAttributes.defaults()
-                    .withIsSpool(true);
+            final ElementAttributes eAttr = ElementAttributes.defaults();
             final ICacheElement<String, String> element = new CacheElement<>( 
cattr.getCacheName(), "key:" + i, "data:" + i );
             element.setElementAttributes( eAttr );
             disk.processUpdate( element );
@@ -65,8 +64,7 @@ class IndexedDiskCacheKeyStoreUnitTest
 
         final long preAddRemoveSize = disk.getDataFileSize();
 
-        final ElementAttributes eAttr = ElementAttributes.defaults()
-                .withIsSpool(true);
+        final ElementAttributes eAttr = ElementAttributes.defaults();
         final ICacheElement<String, String> elementSetup = new CacheElement<>( 
cattr.getCacheName(), "key:A", "data:A" );
         elementSetup.setElementAttributes( eAttr );
         disk.processUpdate( elementSetup );
@@ -115,8 +113,7 @@ class IndexedDiskCacheKeyStoreUnitTest
         final int cnt = 25;
         for ( int i = 0; i < cnt; i++ )
         {
-            final ElementAttributes eAttr = ElementAttributes.defaults()
-                    .withIsSpool(true);
+            final ElementAttributes eAttr = ElementAttributes.defaults();
             final ICacheElement<String, String> element = new CacheElement<>( 
cattr.getCacheName(), "key:" + i, "data:" + i );
             element.setElementAttributes( eAttr );
             disk.processUpdate( element );
diff --git 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheListenerUnitTest.java
 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheListenerUnitTest.java
index 50ba4c51..ccd3c7ba 100644
--- 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheListenerUnitTest.java
+++ 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/auxiliary/remote/RemoteCacheListenerUnitTest.java
@@ -25,6 +25,7 @@ import static org.junit.jupiter.api.Assertions.assertNull;
 
 import org.apache.commons.jcs4.engine.CacheElementSerialized;
 import org.apache.commons.jcs4.engine.ElementAttributes;
+import org.apache.commons.jcs4.engine.TestElementAttributes;
 import org.apache.commons.jcs4.engine.behavior.ICache;
 import org.apache.commons.jcs4.engine.behavior.ICacheElement;
 import org.apache.commons.jcs4.engine.behavior.ICacheElementSerialized;
@@ -59,8 +60,7 @@ class RemoteCacheListenerUnitTest
         final String cacheName = "testName";
         final String key = "key";
         final String value = "value fdsadf dsafdsa fdsaf dsafdsaf dsafdsaf 
dsaf dsaf dsaf dsafa dsaf dsaf dsafdsaf";
-        final ElementAttributes attr = ElementAttributes.defaults()
-                .withMaxLife(34);
+        final ElementAttributes attr = 
TestElementAttributes.withEternalFalseAndMaxLife(34);
 
         final IElementSerializer elementSerializer = new StandardSerializer();
 
@@ -103,8 +103,7 @@ class RemoteCacheListenerUnitTest
         final String cacheName = "testName";
         final String key = "key";
         final String value = "value fdsadf dsafdsa fdsaf dsafdsaf dsafdsaf 
dsaf dsaf dsaf dsafa dsaf dsaf dsafdsaf";
-        final ElementAttributes attr = ElementAttributes.defaults()
-                .withMaxLife(34);
+        final ElementAttributes attr = 
TestElementAttributes.withEternalFalseAndMaxLife(34);
 
         final IElementSerializer elementSerializer = new StandardSerializer();
 
diff --git 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/ElementAttributesUtils.java
 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/ElementAttributesUtils.java
deleted file mode 100644
index e6671729..00000000
--- 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/ElementAttributesUtils.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.apache.commons.jcs4.engine;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   https://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Allow test access to set last access time without exposing public method
- */
-public class ElementAttributesUtils {
-    public static void setLastAccessTime(final ElementAttributes ea, final 
long time)
-    {
-        ea.atomicLastAccessTime().set(time);
-    }
-}
diff --git 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestCompositeCacheAttributes.java
 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestCompositeCacheAttributes.java
new file mode 100644
index 00000000..e40d9c0a
--- /dev/null
+++ 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestCompositeCacheAttributes.java
@@ -0,0 +1,118 @@
+package org.apache.commons.jcs4.engine;
+
+import org.apache.commons.jcs4.engine.behavior.ICompositeCacheAttributes;
+
+/**
+ * The CompositeCacheAttributes defines the general cache region settings. If 
a region is not
+ * explicitly defined in the cache.ccf then it inherits the cache default 
settings.
+ * <p>
+ * If all the default attributes are not defined in the default region 
definition in the cache.ccf,
+ * the hard coded defaults will be used.
+ */
+public class TestCompositeCacheAttributes
+{
+    /**
+     * Get a CompositeCacheAttributes object suitable for tests
+     *
+     * @param memoryCacheName the new memoryCacheName value
+     * @param maxObjects the new maxObjects value
+     */
+    public static CompositeCacheAttributes 
withMemoryCacheNameAndMaxObjects(String memoryCacheName, int maxObjects)
+    {
+        return new 
CompositeCacheAttributes(CompositeCacheAttributes.defaults().cacheName(),
+                maxObjects,
+                CompositeCacheAttributes.defaults().useLateral(),
+                CompositeCacheAttributes.defaults().useDisk(),
+                CompositeCacheAttributes.defaults().useMemoryShrinker(),
+                CompositeCacheAttributes.defaults().shrinkerIntervalSeconds(),
+                CompositeCacheAttributes.defaults().maxSpoolPerRun(),
+                CompositeCacheAttributes.defaults().maxMemoryIdleTimeSeconds(),
+                memoryCacheName,
+                CompositeCacheAttributes.defaults().diskUsagePattern(),
+                CompositeCacheAttributes.defaults().spoolChunkSize());
+    }
+
+    /**
+     * Get a CompositeCacheAttributes object suitable for tests
+     *
+     * @param memoryCacheName the new memoryCacheName value
+     * @param maxMemoryIdleTimeSeconds the new maxMemoryIdleTimeSeconds value
+     * @param maxSpoolPerRun the new maxSpoolPerRun value
+     */
+    public static CompositeCacheAttributes 
withMemoryCacheNameMaxMemoryIdleTimeSecondsAndMaxSpoolPerRun(
+            String memoryCacheName, long maxMemoryIdleTimeSeconds, int 
maxSpoolPerRun)
+    {
+        return new 
CompositeCacheAttributes(CompositeCacheAttributes.defaults().cacheName(),
+                CompositeCacheAttributes.defaults().maxObjects(),
+                CompositeCacheAttributes.defaults().useLateral(),
+                CompositeCacheAttributes.defaults().useDisk(),
+                CompositeCacheAttributes.defaults().useMemoryShrinker(),
+                CompositeCacheAttributes.defaults().shrinkerIntervalSeconds(),
+                maxSpoolPerRun,
+                maxMemoryIdleTimeSeconds,
+                memoryCacheName,
+                CompositeCacheAttributes.defaults().diskUsagePattern(),
+                CompositeCacheAttributes.defaults().spoolChunkSize());
+    }
+
+    /**
+     * Get a CompositeCacheAttributes object suitable for tests
+     *
+     * @param maxObjects the new maxObjects value
+     * @param spoolChunkSize the new spoolChunkSize value
+     */
+    public static CompositeCacheAttributes withMaxObjectsAndSpoolChunkSize(int 
maxObjects, int spoolChunkSize)
+    {
+        return new 
CompositeCacheAttributes(CompositeCacheAttributes.defaults().cacheName(),
+                maxObjects,
+                CompositeCacheAttributes.defaults().useLateral(),
+                CompositeCacheAttributes.defaults().useDisk(),
+                CompositeCacheAttributes.defaults().useMemoryShrinker(),
+                CompositeCacheAttributes.defaults().shrinkerIntervalSeconds(),
+                CompositeCacheAttributes.defaults().maxSpoolPerRun(),
+                CompositeCacheAttributes.defaults().maxMemoryIdleTimeSeconds(),
+                CompositeCacheAttributes.defaults().memoryCacheName(),
+                CompositeCacheAttributes.defaults().diskUsagePattern(),
+                spoolChunkSize);
+    }
+
+    /**
+     * Sets the maximum memory idle-time in seconds of the cache.
+     *
+     * @param maxMemoryIdleTimeSeconds the new maxMemoryIdleTimeSeconds value
+     */
+    public static CompositeCacheAttributes withMaxMemoryIdleTimeSeconds(long 
maxMemoryIdleTimeSeconds)
+    {
+        return new 
CompositeCacheAttributes(CompositeCacheAttributes.defaults().cacheName(),
+                CompositeCacheAttributes.defaults().maxObjects(),
+                CompositeCacheAttributes.defaults().useLateral(),
+                CompositeCacheAttributes.defaults().useDisk(),
+                CompositeCacheAttributes.defaults().useMemoryShrinker(),
+                CompositeCacheAttributes.defaults().shrinkerIntervalSeconds(),
+                CompositeCacheAttributes.defaults().maxSpoolPerRun(),
+                maxMemoryIdleTimeSeconds,
+                CompositeCacheAttributes.defaults().memoryCacheName(),
+                CompositeCacheAttributes.defaults().diskUsagePattern(),
+                CompositeCacheAttributes.defaults().spoolChunkSize());
+    }
+
+    /**
+     * Sets the disk usage pattern of the cache.
+     *
+     * @param diskUsagePattern the new diskUsagePattern value
+     */
+    public static CompositeCacheAttributes 
withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePattern 
diskUsagePattern)
+    {
+        return new 
CompositeCacheAttributes(CompositeCacheAttributes.defaults().cacheName(),
+                CompositeCacheAttributes.defaults().maxObjects(),
+                CompositeCacheAttributes.defaults().useLateral(),
+                CompositeCacheAttributes.defaults().useDisk(),
+                CompositeCacheAttributes.defaults().useMemoryShrinker(),
+                CompositeCacheAttributes.defaults().shrinkerIntervalSeconds(),
+                CompositeCacheAttributes.defaults().maxSpoolPerRun(),
+                CompositeCacheAttributes.defaults().maxMemoryIdleTimeSeconds(),
+                CompositeCacheAttributes.defaults().memoryCacheName(),
+                diskUsagePattern,
+                CompositeCacheAttributes.defaults().spoolChunkSize());
+    }
+}
diff --git 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestElementAttributes.java
 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestElementAttributes.java
new file mode 100644
index 00000000..fc5ac840
--- /dev/null
+++ 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/TestElementAttributes.java
@@ -0,0 +1,76 @@
+package org.apache.commons.jcs4.engine;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * Allow test access to parametrized ElementAttributes objects
+ */
+public class TestElementAttributes
+{
+    /**
+     * Get an ElementAttributes object suitable for tests.
+     *
+     * @param maxLife The new MaxLife value
+     */
+    public static ElementAttributes withEternalFalseAndMaxLife(long maxLife)
+    {
+        ElementAttributes element = new ElementAttributes(
+                ElementAttributes.defaults().isSpool(),
+                ElementAttributes.defaults().isLateral(),
+                ElementAttributes.defaults().isRemote(),
+                false,
+                maxLife,
+                ElementAttributes.defaults().maxIdleTime(),
+                System.currentTimeMillis(),
+                new AtomicLong(),
+                ElementAttributes.defaults().timeFactorForMilliseconds(),
+                new ArrayList<>());
+
+        element.atomicLastAccessTime().set(element.createTime());
+        return element;
+    }
+
+    /**
+     * Get an ElementAttributes object suitable for tests.
+     *
+     * @param maxLife The new MaxLife value
+     * @param maxIdleTime The new MaxIdleTime value
+     */
+    public static ElementAttributes 
withEternalFalseAndMaxLifeAndMaxIdleTime(long maxLife, long maxIdleTime)
+    {
+        ElementAttributes element = new ElementAttributes(
+                ElementAttributes.defaults().isSpool(),
+                ElementAttributes.defaults().isLateral(),
+                ElementAttributes.defaults().isRemote(),
+                false,
+                maxLife,
+                maxIdleTime,
+                System.currentTimeMillis(),
+                new AtomicLong(),
+                ElementAttributes.defaults().timeFactorForMilliseconds(),
+                new ArrayList<>());
+
+        element.atomicLastAccessTime().set(element.createTime());
+        return element;
+    }
+}
diff --git 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/CompositeCacheDiskUsageUnitTest.java
 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/CompositeCacheDiskUsageUnitTest.java
index 40e157eb..65c94ccb 100644
--- 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/CompositeCacheDiskUsageUnitTest.java
+++ 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/CompositeCacheDiskUsageUnitTest.java
@@ -37,6 +37,7 @@ import org.apache.commons.jcs4.engine.CacheElement;
 import org.apache.commons.jcs4.engine.CacheStatus;
 import org.apache.commons.jcs4.engine.CompositeCacheAttributes;
 import org.apache.commons.jcs4.engine.ElementAttributes;
+import org.apache.commons.jcs4.engine.TestCompositeCacheAttributes;
 import org.apache.commons.jcs4.engine.behavior.ICacheElement;
 import org.apache.commons.jcs4.engine.behavior.ICacheType.CacheType;
 import org.apache.commons.jcs4.engine.behavior.ICompositeCacheAttributes;
@@ -262,9 +263,9 @@ class CompositeCacheDiskUsageUnitTest
     void testSpoolAllowed()
     {
         // SETUP
-        final CompositeCacheAttributes cattr = 
CompositeCacheAttributes.defaults()
-                .withCacheName(CACHE_NAME)
-                
.withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePattern.SWAP);
+        final CompositeCacheAttributes cattr = TestCompositeCacheAttributes
+                
.withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePattern.SWAP)
+                .withCacheName(CACHE_NAME);
 
         final IElementAttributes attr = new ElementAttributes();
 
@@ -292,9 +293,9 @@ class CompositeCacheDiskUsageUnitTest
     void testSpoolNotAllowed()
     {
         // SETUP
-        final CompositeCacheAttributes cattr = 
CompositeCacheAttributes.defaults()
-                .withCacheName(CACHE_NAME)
-                
.withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePattern.UPDATE);
+        final CompositeCacheAttributes cattr = TestCompositeCacheAttributes
+                
.withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePattern.UPDATE)
+                .withCacheName(CACHE_NAME);
 
         final IElementAttributes attr = new ElementAttributes();
 
@@ -340,9 +341,9 @@ class CompositeCacheDiskUsageUnitTest
         throws IOException
     {
         // SETUP
-        final CompositeCacheAttributes cattr = 
CompositeCacheAttributes.defaults()
-                .withCacheName(CACHE_NAME)
-                
.withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePattern.UPDATE);
+        final CompositeCacheAttributes cattr = TestCompositeCacheAttributes
+                
.withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePattern.UPDATE)
+                .withCacheName(CACHE_NAME);
 
         final IElementAttributes attr = new ElementAttributes();
 
@@ -376,9 +377,9 @@ class CompositeCacheDiskUsageUnitTest
         throws IOException
     {
         // SETUP
-        final CompositeCacheAttributes cattr = 
CompositeCacheAttributes.defaults()
-                .withCacheName(CACHE_NAME)
-                
.withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePattern.UPDATE);
+        final CompositeCacheAttributes cattr = TestCompositeCacheAttributes
+                
.withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePattern.UPDATE)
+                .withCacheName(CACHE_NAME);
 
         final IElementAttributes attr = new ElementAttributes();
 
@@ -411,9 +412,9 @@ class CompositeCacheDiskUsageUnitTest
         throws IOException
     {
         // SETUP
-        final CompositeCacheAttributes cattr = 
CompositeCacheAttributes.defaults()
-                .withCacheName(CACHE_NAME)
-                
.withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePattern.UPDATE);
+        final CompositeCacheAttributes cattr = TestCompositeCacheAttributes
+                
.withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePattern.UPDATE)
+                .withCacheName(CACHE_NAME);
 
         final IElementAttributes attr = new ElementAttributes();
 
@@ -467,9 +468,9 @@ class CompositeCacheDiskUsageUnitTest
         throws IOException
     {
         // SETUP
-        final CompositeCacheAttributes cattr = 
CompositeCacheAttributes.defaults()
-                .withCacheName(CACHE_NAME)
-                
.withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePattern.SWAP);
+        final CompositeCacheAttributes cattr = TestCompositeCacheAttributes
+                
.withDiskUsagePattern(ICompositeCacheAttributes.DiskUsagePattern.SWAP)
+                .withCacheName(CACHE_NAME);
 
         final IElementAttributes attr = new ElementAttributes();
 
diff --git 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/CompositeCacheUnitTest.java
 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/CompositeCacheUnitTest.java
index fd715aa7..05850825 100644
--- 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/CompositeCacheUnitTest.java
+++ 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/control/CompositeCacheUnitTest.java
@@ -29,6 +29,7 @@ import org.apache.commons.jcs4.auxiliary.MockAuxiliaryCache;
 import org.apache.commons.jcs4.engine.CacheElement;
 import org.apache.commons.jcs4.engine.CompositeCacheAttributes;
 import org.apache.commons.jcs4.engine.ElementAttributes;
+import org.apache.commons.jcs4.engine.TestCompositeCacheAttributes;
 import org.apache.commons.jcs4.engine.behavior.ICacheElement;
 import org.apache.commons.jcs4.engine.behavior.ICacheType.CacheType;
 import org.apache.commons.jcs4.engine.behavior.IElementAttributes;
@@ -55,12 +56,10 @@ class CompositeCacheUnitTest
         final String keyprefix2 = "MyPrefix2";
         final String cacheName = "testGetMatching_Normal";
         final String memoryCacheClassName = 
"org.apache.commons.jcs4.engine.memory.lru.LRUMemoryCache";
-        final CompositeCacheAttributes cattr = 
CompositeCacheAttributes.defaults()
-                .withMemoryCacheName(memoryCacheClassName)
-                .withMaxObjects(maxMemorySize);
+        final CompositeCacheAttributes cattr = TestCompositeCacheAttributes
+                .withMemoryCacheNameAndMaxObjects(memoryCacheClassName, 
maxMemorySize);
 
         final IElementAttributes attr = new ElementAttributes();
-
         final CompositeCache<String, Integer> cache = new CompositeCache<>( 
cattr, attr );
 
         final MockAuxiliaryCache<String, Integer> diskMock = new 
MockAuxiliaryCache<>();
@@ -105,10 +104,9 @@ class CompositeCacheUnitTest
         final int maxMemorySize = 0;
         final String cacheName = "testGetMatching_NotOnDisk";
         final String memoryCacheClassName = 
"org.apache.commons.jcs4.engine.memory.lru.LRUMemoryCache";
-        final CompositeCacheAttributes cattr = 
CompositeCacheAttributes.defaults()
-                .withCacheName(cacheName)
-                .withMemoryCacheName(memoryCacheClassName)
-                .withMaxObjects(maxMemorySize);
+        final CompositeCacheAttributes cattr = TestCompositeCacheAttributes
+                .withMemoryCacheNameAndMaxObjects(memoryCacheClassName, 
maxMemorySize)
+                .withCacheName(cacheName);
 
         final IElementAttributes attr = new ElementAttributes();
 
@@ -138,10 +136,9 @@ class CompositeCacheUnitTest
         final int maxMemorySize = 0;
         final String cacheName = "testGetMatching_NotOnDisk";
         final String memoryCacheClassName = 
"org.apache.commons.jcs4.engine.memory.lru.LRUMemoryCache";
-        final CompositeCacheAttributes cattr = 
CompositeCacheAttributes.defaults()
-                .withCacheName(cacheName)
-                .withMemoryCacheName(memoryCacheClassName)
-                .withMaxObjects(maxMemorySize);
+        final CompositeCacheAttributes cattr = TestCompositeCacheAttributes
+                .withMemoryCacheNameAndMaxObjects(memoryCacheClassName, 
maxMemorySize)
+                .withCacheName(cacheName);
 
         final IElementAttributes attr = new ElementAttributes();
 
@@ -171,11 +168,10 @@ class CompositeCacheUnitTest
         // SETUP
         final String cacheName = "testCacheName";
         final String mockMemoryCacheClassName = 
"org.apache.commons.jcs4.engine.memory.MockMemoryCache";
-        final CompositeCacheAttributes cattr = 
CompositeCacheAttributes.defaults()
-                .withMemoryCacheName(mockMemoryCacheClassName);
+        final CompositeCacheAttributes cattr = TestCompositeCacheAttributes
+                .withMemoryCacheNameAndMaxObjects(mockMemoryCacheClassName, 
100);
 
         final IElementAttributes attr = new ElementAttributes();
-
         final CompositeCache<String, Integer> cache = new CompositeCache<>( 
cattr, attr );
 
         final MockAuxiliaryCache<String, Integer> diskMock = new 
MockAuxiliaryCache<>();
@@ -210,11 +206,10 @@ class CompositeCacheUnitTest
         // SETUP
         final String cacheName = "testCacheName";
         final String mockMemoryCacheClassName = 
"org.apache.commons.jcs4.engine.memory.MockMemoryCache";
-        final CompositeCacheAttributes cattr = 
CompositeCacheAttributes.defaults()
-                .withMemoryCacheName(mockMemoryCacheClassName);
+        final CompositeCacheAttributes cattr = TestCompositeCacheAttributes
+                .withMemoryCacheNameAndMaxObjects(mockMemoryCacheClassName, 
100);
 
         final IElementAttributes attr = new ElementAttributes();
-
         final CompositeCache<String, Integer> cache = new CompositeCache<>( 
cattr, attr );
 
         final MockAuxiliaryCache<String, Integer> diskMock = new 
MockAuxiliaryCache<>();
diff --git 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/fifo/FIFOMemoryCacheUnitTest.java
 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/fifo/FIFOMemoryCacheUnitTest.java
index 28adde18..617c4d1d 100644
--- 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/fifo/FIFOMemoryCacheUnitTest.java
+++ 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/fifo/FIFOMemoryCacheUnitTest.java
@@ -27,6 +27,7 @@ import java.io.IOException;
 import org.apache.commons.jcs4.engine.CacheElement;
 import org.apache.commons.jcs4.engine.CompositeCacheAttributes;
 import org.apache.commons.jcs4.engine.ElementAttributes;
+import org.apache.commons.jcs4.engine.TestCompositeCacheAttributes;
 import org.apache.commons.jcs4.engine.control.CompositeCache;
 import org.junit.jupiter.api.Test;
 
@@ -46,10 +47,9 @@ class FIFOMemoryCacheUnitTest
         final int maxObjects = 10;
         final String cacheName = "testExpirationPolicy_oneExtra";
 
-        final CompositeCacheAttributes attributes = 
CompositeCacheAttributes.defaults()
-                .withCacheName(cacheName)
-                .withMaxObjects(maxObjects)
-                .withSpoolChunkSize(1);
+        final CompositeCacheAttributes attributes = 
TestCompositeCacheAttributes
+                .withMaxObjectsAndSpoolChunkSize(maxObjects, 1)
+                .withCacheName(cacheName);
 
         final FIFOMemoryCache<String, String> cache = new FIFOMemoryCache<>();
         cache.initialize( new CompositeCache<>( attributes, new 
ElementAttributes() ) );
@@ -82,10 +82,9 @@ class FIFOMemoryCacheUnitTest
         final int maxObjects = 10;
         final String cacheName = "testExpirationPolicy_oneExtra";
 
-        final CompositeCacheAttributes attributes = 
CompositeCacheAttributes.defaults()
-                .withCacheName(cacheName)
-                .withMaxObjects(maxObjects)
-                .withSpoolChunkSize(1);
+        final CompositeCacheAttributes attributes = 
TestCompositeCacheAttributes
+                .withMaxObjectsAndSpoolChunkSize(maxObjects, 1)
+                .withCacheName(cacheName);
 
         final FIFOMemoryCache<String, String> cache = new FIFOMemoryCache<>();
         cache.initialize( new CompositeCache<>( attributes, new 
ElementAttributes() ) );
diff --git 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThreadUnitTest.java
 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThreadUnitTest.java
index 6f50e06b..f0a5e187 100644
--- 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThreadUnitTest.java
+++ 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/engine/memory/shrinking/ShrinkerThreadUnitTest.java
@@ -30,7 +30,8 @@ import java.io.IOException;
 import org.apache.commons.jcs4.engine.CacheElement;
 import org.apache.commons.jcs4.engine.CompositeCacheAttributes;
 import org.apache.commons.jcs4.engine.ElementAttributes;
-import org.apache.commons.jcs4.engine.ElementAttributesUtils;
+import org.apache.commons.jcs4.engine.TestCompositeCacheAttributes;
+import org.apache.commons.jcs4.engine.TestElementAttributes;
 import org.apache.commons.jcs4.engine.behavior.ICacheElement;
 import org.apache.commons.jcs4.engine.control.CompositeCache;
 import 
org.apache.commons.jcs4.engine.control.event.ElementEventHandlerMockImpl;
@@ -51,10 +52,10 @@ class ShrinkerThreadUnitTest
         throws IOException
     {
         // SETUP
-        final CompositeCacheAttributes cacheAttr = 
CompositeCacheAttributes.defaults()
-                .withCacheName("testRegion")
-                .withMaxMemoryIdleTimeSeconds(10)
-                .withMaxSpoolPerRun(10);
+        final CompositeCacheAttributes cacheAttr = TestCompositeCacheAttributes
+                .withMemoryCacheNameMaxMemoryIdleTimeSecondsAndMaxSpoolPerRun(
+                        CompositeCacheAttributes.defaults().memoryCacheName(), 
10, 10)
+                .withCacheName("testRegion");
 
         final CompositeCache<String, String> cache = new 
CompositeCache<>(cacheAttr, new ElementAttributes());
 
@@ -62,9 +63,7 @@ class ShrinkerThreadUnitTest
         final String value = "value";
 
         final ICacheElement<String, String> element = new CacheElement<>( 
"testRegion", key, value,
-                new ElementAttributes()
-                .withIsEternal(false)
-                .withMaxLife(1));
+                TestElementAttributes.withEternalFalseAndMaxLife(1));
 
         long now = System.currentTimeMillis();
         // add two seconds
@@ -87,10 +86,10 @@ class ShrinkerThreadUnitTest
         throws IOException
     {
         // SETUP
-        final CompositeCacheAttributes cacheAttr = 
CompositeCacheAttributes.defaults()
-                .withCacheName("testRegion")
-                .withMaxMemoryIdleTimeSeconds(10)
-                .withMaxSpoolPerRun(10);
+        final CompositeCacheAttributes cacheAttr = TestCompositeCacheAttributes
+                .withMemoryCacheNameMaxMemoryIdleTimeSecondsAndMaxSpoolPerRun(
+                        CompositeCacheAttributes.defaults().memoryCacheName(), 
10, 10)
+                .withCacheName("testRegion");
 
         final CompositeCache<String, String> cache = new 
CompositeCache<>(cacheAttr, new ElementAttributes());
 
@@ -98,10 +97,7 @@ class ShrinkerThreadUnitTest
         final String value = "value";
 
         final ICacheElement<String, String> element = new CacheElement<>( 
"testRegion", key, value,
-                new ElementAttributes()
-                .withIsEternal(false)
-                .withMaxLife(100)
-                .withMaxIdleTime(1));
+                
TestElementAttributes.withEternalFalseAndMaxLifeAndMaxIdleTime(100, 1));
 
         long now = System.currentTimeMillis();
         // add two seconds
@@ -124,10 +120,10 @@ class ShrinkerThreadUnitTest
         throws IOException
     {
         // SETUP
-        final CompositeCacheAttributes cacheAttr = 
CompositeCacheAttributes.defaults()
-                .withCacheName("testRegion")
-                .withMaxMemoryIdleTimeSeconds(10)
-                .withMaxSpoolPerRun(10);
+        final CompositeCacheAttributes cacheAttr = TestCompositeCacheAttributes
+                .withMemoryCacheNameMaxMemoryIdleTimeSecondsAndMaxSpoolPerRun(
+                        CompositeCacheAttributes.defaults().memoryCacheName(), 
10, 10)
+                .withCacheName("testRegion");
 
         final CompositeCache<String, String> cache = new 
CompositeCache<>(cacheAttr, new ElementAttributes());
 
@@ -135,9 +131,7 @@ class ShrinkerThreadUnitTest
         final String value = "value";
 
         final ICacheElement<String, String> element = new CacheElement<>( 
"testRegion", key, value,
-                new ElementAttributes()
-                .withIsEternal(false)
-                .withMaxLife(1));
+                TestElementAttributes.withEternalFalseAndMaxLife(1));
 
         long now = System.currentTimeMillis();
         // subtract two seconds
@@ -160,10 +154,10 @@ class ShrinkerThreadUnitTest
         throws IOException
     {
         // SETUP
-        final CompositeCacheAttributes cacheAttr = 
CompositeCacheAttributes.defaults()
-                .withCacheName("testRegion")
-                .withMaxMemoryIdleTimeSeconds(10)
-                .withMaxSpoolPerRun(10);
+        final CompositeCacheAttributes cacheAttr = TestCompositeCacheAttributes
+                .withMemoryCacheNameMaxMemoryIdleTimeSecondsAndMaxSpoolPerRun(
+                        CompositeCacheAttributes.defaults().memoryCacheName(), 
10, 10)
+                .withCacheName("testRegion");
 
         final CompositeCache<String, String> cache = new 
CompositeCache<>(cacheAttr, new ElementAttributes());
 
@@ -171,10 +165,7 @@ class ShrinkerThreadUnitTest
         final String value = "value";
 
         final ICacheElement<String, String> element = new CacheElement<>( 
"testRegion", key, value,
-                new ElementAttributes()
-                .withIsEternal(false)
-                .withMaxLife(100)
-                .withMaxIdleTime(1));
+                
TestElementAttributes.withEternalFalseAndMaxLifeAndMaxIdleTime(100, 1));
 
         long now = System.currentTimeMillis();
         // subtract two seconds
@@ -200,11 +191,10 @@ class ShrinkerThreadUnitTest
         throws Exception
     {
         // SETUP
-        final CompositeCacheAttributes cacheAttr = 
CompositeCacheAttributes.defaults()
-                .withCacheName("testRegion")
-                
.withMemoryCacheName("org.apache.commons.jcs4.engine.memory.MockMemoryCache")
-                .withMaxMemoryIdleTimeSeconds(1)
-                .withMaxSpoolPerRun(10);
+        final CompositeCacheAttributes cacheAttr = TestCompositeCacheAttributes
+                .withMemoryCacheNameMaxMemoryIdleTimeSecondsAndMaxSpoolPerRun(
+                        
"org.apache.commons.jcs4.engine.memory.MockMemoryCache", 1, 10)
+                .withCacheName("testRegion");
 
         final CompositeCache<String, String> cache = new 
CompositeCache<>(cacheAttr, new ElementAttributes());
         final MockMemoryCache<String, String> memory = 
(MockMemoryCache<String, String>)cache.getMemoryCache();
@@ -213,10 +203,7 @@ class ShrinkerThreadUnitTest
         final String value = "value";
 
         final ICacheElement<String, String> element = new CacheElement<>( 
"testRegion", key, value );
-
-        final ElementAttributes elementAttr = new ElementAttributes()
-                .withIsEternal(false)
-                .withMaxLife(1);
+        final ElementAttributes elementAttr = 
TestElementAttributes.withEternalFalseAndMaxLife(1);
         element.setElementAttributes( elementAttr );
         memory.update( element );
 
@@ -224,7 +211,7 @@ class ShrinkerThreadUnitTest
         assertNotNull( returnedElement1, "We should have received an element" 
);
 
         // set this to 2 seconds ago.
-        ElementAttributesUtils.setLastAccessTime( elementAttr,  
System.currentTimeMillis() - 2000 );
+        elementAttr.atomicLastAccessTime().set(System.currentTimeMillis() - 
2000);
 
         // DO WORK
         final ShrinkerThread<String, String> shrinker = new ShrinkerThread<>( 
cache );
@@ -248,11 +235,10 @@ class ShrinkerThreadUnitTest
         throws Exception
     {
         // SETUP
-        final CompositeCacheAttributes cacheAttr = 
CompositeCacheAttributes.defaults()
-                .withCacheName("testRegion")
-                
.withMemoryCacheName("org.apache.commons.jcs4.engine.memory.MockMemoryCache")
-                .withMaxMemoryIdleTimeSeconds(1)
-                .withMaxSpoolPerRun(3);
+        final CompositeCacheAttributes cacheAttr = TestCompositeCacheAttributes
+                .withMemoryCacheNameMaxMemoryIdleTimeSecondsAndMaxSpoolPerRun(
+                        
"org.apache.commons.jcs4.engine.memory.MockMemoryCache", 1, 3)
+                .withCacheName("testRegion");
 
         final CompositeCache<String, String> cache = new 
CompositeCache<>(cacheAttr, new ElementAttributes());
         final MockMemoryCache<String, String> memory = 
(MockMemoryCache<String, String>)cache.getMemoryCache();
@@ -263,10 +249,7 @@ class ShrinkerThreadUnitTest
             final String value = "value";
 
             final ICacheElement<String, String> element = new CacheElement<>( 
"testRegion", key, value );
-
-            final ElementAttributes elementAttr = new ElementAttributes()
-                    .withIsEternal(false)
-                    .withMaxLife(1);
+            final ElementAttributes elementAttr = 
TestElementAttributes.withEternalFalseAndMaxLife(1);
             element.setElementAttributes( elementAttr );
             memory.update( element );
 
@@ -274,7 +257,7 @@ class ShrinkerThreadUnitTest
             assertNotNull( returnedElement1, "We should have received an 
element" );
 
             // set this to 2 seconds ago.
-            ElementAttributesUtils.setLastAccessTime( elementAttr,  
System.currentTimeMillis() - 2000 );
+            elementAttr.atomicLastAccessTime().set(System.currentTimeMillis() 
- 2000);
         }
 
         // DO WORK
@@ -299,11 +282,10 @@ class ShrinkerThreadUnitTest
         throws Exception
     {
         // SETUP
-        final CompositeCacheAttributes cacheAttr = 
CompositeCacheAttributes.defaults()
-                .withCacheName("testRegion")
-                
.withMemoryCacheName("org.apache.commons.jcs4.engine.memory.MockMemoryCache")
-                .withMaxMemoryIdleTimeSeconds(1)
-                .withMaxSpoolPerRun(3);
+        final CompositeCacheAttributes cacheAttr = TestCompositeCacheAttributes
+                .withMemoryCacheNameMaxMemoryIdleTimeSecondsAndMaxSpoolPerRun(
+                        
"org.apache.commons.jcs4.engine.memory.MockMemoryCache", 1, 3)
+                .withCacheName("testRegion");
 
         final CompositeCache<String, String> cache = new 
CompositeCache<>(cacheAttr, new ElementAttributes());
         final MockMemoryCache<String, String> memory = 
(MockMemoryCache<String, String>)cache.getMemoryCache();
@@ -316,10 +298,7 @@ class ShrinkerThreadUnitTest
             final String value = "value";
 
             final ICacheElement<String, String> element = new CacheElement<>( 
"testRegion", key, value );
-
-            final ElementAttributes elementAttr = new ElementAttributes()
-                    .withIsEternal(false)
-                    .withMaxLife(1);
+            final ElementAttributes elementAttr = 
TestElementAttributes.withEternalFalseAndMaxLife(1);
             elementAttr.addElementEventHandler( handler );
             element.setElementAttributes( elementAttr );
             memory.update( element );
@@ -328,7 +307,7 @@ class ShrinkerThreadUnitTest
             assertNotNull( returnedElement1, "We should have received an 
element" );
 
             // set this to 2 seconds ago.
-            ElementAttributesUtils.setLastAccessTime( elementAttr,  
System.currentTimeMillis() - 2000 );
+            elementAttr.atomicLastAccessTime().set(System.currentTimeMillis() 
- 2000);
         }
 
         // DO WORK
diff --git 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/utils/serialization/SerializationConversionUtilUnitTest.java
 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/utils/serialization/SerializationConversionUtilUnitTest.java
index 002f1518..05093c09 100644
--- 
a/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/utils/serialization/SerializationConversionUtilUnitTest.java
+++ 
b/commons-jcs4-core/src/test/java/org/apache/commons/jcs4/utils/serialization/SerializationConversionUtilUnitTest.java
@@ -28,6 +28,7 @@ import java.io.IOException;
 
 import org.apache.commons.jcs4.engine.CacheElement;
 import org.apache.commons.jcs4.engine.ElementAttributes;
+import org.apache.commons.jcs4.engine.TestElementAttributes;
 import org.apache.commons.jcs4.engine.behavior.ICacheElement;
 import org.apache.commons.jcs4.engine.behavior.ICacheElementSerialized;
 import org.apache.commons.jcs4.engine.behavior.IElementSerializer;
@@ -53,9 +54,7 @@ class SerializationConversionUtilUnitTest
         final String value = "value fdsadf dsafdsa fdsaf dsafdsaf dsafdsaf 
dsaf dsaf dsaf dsafa dsaf dsaf dsafdsaf";
 
         final IElementSerializer elementSerializer = new StandardSerializer();
-
-        final ElementAttributes attr = ElementAttributes.defaults()
-                .withMaxLife(34);
+        final ElementAttributes attr = 
TestElementAttributes.withEternalFalseAndMaxLife(34);
 
         final ICacheElement<String, String> before = new CacheElement<>( 
cacheName, key, value );
         before.setElementAttributes( attr );
@@ -136,9 +135,7 @@ class SerializationConversionUtilUnitTest
         final String value = "value fdsadf dsafdsa fdsaf dsafdsaf dsafdsaf 
dsaf dsaf dsaf dsafa dsaf dsaf dsafdsaf";
 
         final IElementSerializer elementSerializer = null; // new 
StandardSerializer();
-
-        final ElementAttributes attr = ElementAttributes.defaults()
-                .withMaxLife(34);
+        final ElementAttributes attr = 
TestElementAttributes.withEternalFalseAndMaxLife(34);
 
         final ICacheElement<String, String> before = new CacheElement<>( 
cacheName, key, value );
         before.setElementAttributes( attr );
@@ -172,9 +169,7 @@ class SerializationConversionUtilUnitTest
         final String value = "value fdsadf dsafdsa fdsaf dsafdsaf dsafdsaf 
dsaf dsaf dsaf dsafa dsaf dsaf dsafdsaf";
 
         final IElementSerializer elementSerializer = new StandardSerializer();
-
-        final ElementAttributes attr = ElementAttributes.defaults()
-                .withMaxLife(34);
+        final ElementAttributes attr = 
TestElementAttributes.withEternalFalseAndMaxLife(34);
 
         final ICacheElement<String, String> before = new CacheElement<>( 
cacheName, key, value );
         before.setElementAttributes( attr );

Reply via email to