You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by rm...@apache.org on 2014/05/12 20:51:56 UTC

svn commit: r1594051 - in /commons/proper/jcs/trunk: auxiliary-builds/jdk14/src/java/org/apache/commons/jcs/engine/memory/lru/ commons-jcs-core/src/main/java/org/apache/commons/jcs/admin/ commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/...

Author: rmannibucau
Date: Mon May 12 18:51:56 2014
New Revision: 1594051

URL: http://svn.apache.org/r1594051
Log:
getting rid of JCSElement

Added:
    commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/ImmediateExpiryTest.java
Removed:
    commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSElement.java
    commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSKey.java
Modified:
    commons/proper/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/commons/jcs/engine/memory/lru/LHMLRUMemoryCache.java
    commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/admin/JCSAdminBean.java
    commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java
    commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/ElementAttributes.java
    commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/behavior/IElementAttributes.java
    commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCache.java
    commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/access/CacheAccessUnitTest.java
    commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheListenerUnitTest.java
    commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/shrinking/ShrinkerThreadUnitTest.java
    commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/serialization/SerializationConversionUtilUnitTest.java
    commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java
    commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCachingManager.java
    commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/CacheTest.java

Modified: commons/proper/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/commons/jcs/engine/memory/lru/LHMLRUMemoryCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/commons/jcs/engine/memory/lru/LHMLRUMemoryCache.java?rev=1594051&r1=1594050&r2=1594051&view=diff
==============================================================================
--- commons/proper/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/commons/jcs/engine/memory/lru/LHMLRUMemoryCache.java (original)
+++ commons/proper/jcs/trunk/auxiliary-builds/jdk14/src/java/org/apache/commons/jcs/engine/memory/lru/LHMLRUMemoryCache.java Mon May 12 18:51:56 2014
@@ -38,7 +38,7 @@ import java.util.Map;
  *  This is a test memory manager using the jdk1.4 LinkedHashMap.
  *  There may be some thread safety issues.
  *  So far i cannot notice any performance difference between this and the
- *  standard LRU implementation.  It needs more testing.
+ *  standard LRU implementation.  It neeLogds more testing.
  *
  *@version    $Id$
  */

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/admin/JCSAdminBean.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/admin/JCSAdminBean.java?rev=1594051&r1=1594050&r2=1594051&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/admin/JCSAdminBean.java (original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/admin/JCSAdminBean.java Mon May 12 18:51:56 2014
@@ -122,8 +122,8 @@ public class JCSAdminBean implements JCS
             		String.valueOf( key ),
             		attributes.getIsEternal(),
             		format.format(new Date(attributes.getCreateTime())),
-            		attributes.getMaxLifeSeconds(),
-            		(now - attributes.getCreateTime() - attributes.getMaxLifeSeconds() * 1000 ) / -1000);
+            		attributes.getMaxLife(),
+            		(now - attributes.getCreateTime() - attributes.getMaxLife() * 1000 ) / -1000);
 
             records.add( elementInfo );
         }

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java?rev=1594051&r1=1594050&r2=1594051&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java (original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java Mon May 12 18:51:56 2014
@@ -333,7 +333,7 @@ public class JDBCDiskCache<K, V>
             psInsert.setString( 1, (String) ce.getKey() );
             psInsert.setString( 2, this.getCacheName() );
             psInsert.setBytes( 3, element );
-            psInsert.setLong( 4, ce.getElementAttributes().getMaxLifeSeconds() );
+            psInsert.setLong( 4, ce.getElementAttributes().getMaxLife() );
             if ( ce.getElementAttributes().getIsEternal() )
             {
                 psInsert.setString( 5, "T" );
@@ -348,7 +348,7 @@ public class JDBCDiskCache<K, V>
             long now = System.currentTimeMillis() / 1000;
             psInsert.setLong( 7, now );
 
-            long expireTime = now + ce.getElementAttributes().getMaxLifeSeconds();
+            long expireTime = now + ce.getElementAttributes().getMaxLife();
             psInsert.setLong( 8, expireTime );
 
             psInsert.execute();
@@ -401,7 +401,7 @@ public class JDBCDiskCache<K, V>
             long now = System.currentTimeMillis() / 1000;
             psUpdate.setLong( 3, now );
 
-            long expireTime = now + ce.getElementAttributes().getMaxLifeSeconds();
+            long expireTime = now + ce.getElementAttributes().getMaxLife();
             psUpdate.setLong( 4, expireTime );
 
             psUpdate.setString( 5, (String) ce.getKey() );

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/ElementAttributes.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/ElementAttributes.java?rev=1594051&r1=1594050&r2=1594051&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/ElementAttributes.java (original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/ElementAttributes.java Mon May 12 18:51:56 2014
@@ -60,13 +60,13 @@ public class ElementAttributes
     private boolean IS_ETERNAL = true;
 
     /** Max life seconds */
-    private long maxLifeSeconds = -1;
+    private long maxLife = -1;
 
     /**
      * The maximum time an entry can be idle. Setting this to -1 causes the idle time check to be
      * ignored.
      */
-    private long maxIdleTimeSeconds = -1;
+    private long maxIdleTime = -1;
 
     /** The byte size of the field. Must be manually set. */
     private int size = 0;
@@ -86,6 +86,8 @@ public class ElementAttributes
      */
     private transient ArrayList<IElementEventHandler> eventHandlers;
 
+    private long timeFactor = 1000;
+
     /**
      * Constructor for the IElementAttributes object
      */
@@ -113,9 +115,9 @@ public class ElementAttributes
         // central rmi store
         IS_REMOTE = attr.IS_REMOTE;
 
-        maxLifeSeconds = attr.maxLifeSeconds;
+        maxLife = attr.maxLife;
         // time-to-live
-        maxIdleTimeSeconds = attr.maxIdleTimeSeconds;
+        maxIdleTime = attr.maxIdleTime;
         size = attr.size;
     }
 
@@ -137,7 +139,7 @@ public class ElementAttributes
             attr.setIsLateral( this.getIsLateral() );
             attr.setIsRemote( this.getIsRemote() );
             attr.setIsSpool( this.getIsSpool() );
-            attr.setMaxLifeSeconds( this.getMaxLifeSeconds() );
+            attr.setMaxLife(this.getMaxLife());
             attr.addElementEventHandlers( this.eventHandlers );
             return attr;
         }
@@ -153,9 +155,9 @@ public class ElementAttributes
      * @param mls The new MaxLifeSeconds value
      */
     @Override
-    public void setMaxLifeSeconds( long mls )
+    public void setMaxLife(long mls)
     {
-        this.maxLifeSeconds = mls;
+        this.maxLife = mls;
     }
 
     /**
@@ -167,9 +169,9 @@ public class ElementAttributes
      * @return The MaxLifeSeconds value
      */
     @Override
-    public long getMaxLifeSeconds()
+    public long getMaxLife()
     {
-        return this.maxLifeSeconds;
+        return this.maxLife;
     }
 
     /**
@@ -183,7 +185,7 @@ public class ElementAttributes
     @Override
     public void setIdleTime( long idle )
     {
-        this.maxIdleTimeSeconds = idle;
+        this.maxIdleTime = idle;
     }
 
     /**
@@ -239,7 +241,7 @@ public class ElementAttributes
     @Override
     public long getIdleTime()
     {
-        return this.maxIdleTimeSeconds;
+        return this.maxIdleTime;
     }
 
     /**
@@ -251,8 +253,9 @@ public class ElementAttributes
     @Override
     public long getTimeToLiveSeconds()
     {
-        long now = System.currentTimeMillis();
-        return ( this.getCreateTime() + this.getMaxLifeSeconds() * 1000 - now ) / 1000;
+        final long now = System.currentTimeMillis();
+        final long timeFactorForMilliseconds = getTimeFactorForMilliseconds();
+        return ( this.getCreateTime() + this.getMaxLife() * timeFactorForMilliseconds - now ) / 1000;
     }
 
     /**
@@ -417,6 +420,18 @@ public class ElementAttributes
         }
     }
 
+    @Override
+    public long getTimeFactorForMilliseconds()
+    {
+        return timeFactor;
+    }
+
+    @Override
+    public void setTimeFactorForMilliseconds(long factor)
+    {
+        this.timeFactor = factor;
+    }
+
     /**
      * Gets the elementEventHandlers. Returns null if none exist. Makes checking easy.
      * <p>
@@ -442,7 +457,7 @@ public class ElementAttributes
         dump.append( ", IS_SPOOL = " ).append( IS_SPOOL );
         dump.append( ", IS_REMOTE = " ).append( IS_REMOTE );
         dump.append( ", IS_ETERNAL = " ).append( IS_ETERNAL );
-        dump.append( ", MaxLifeSeconds = " ).append( this.getMaxLifeSeconds() );
+        dump.append( ", MaxLifeSeconds = " ).append( this.getMaxLife() );
         dump.append( ", IdleTime = " ).append( this.getIdleTime() );
         dump.append( ", CreateTime = " ).append( this.getCreateTime() );
         dump.append( ", LastAccessTime = " ).append( this.getLastAccessTime() );

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/behavior/IElementAttributes.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/behavior/IElementAttributes.java?rev=1594051&r1=1594050&r2=1594051&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/behavior/IElementAttributes.java (original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/behavior/IElementAttributes.java Mon May 12 18:51:56 2014
@@ -36,7 +36,7 @@ public interface IElementAttributes
      * <p>
      * @param mls The new MaxLifeSeconds value
      */
-    void setMaxLifeSeconds( long mls );
+    void setMaxLife(long mls);
 
     /**
      * Sets the maxLife attribute of the IAttributes object. How many seconds it can live after
@@ -46,7 +46,7 @@ public interface IElementAttributes
      * removed on retrieval, or removed actively if the memory shrinker is turned on.
      * @return The MaxLifeSeconds value
      */
-    long getMaxLifeSeconds();
+    long getMaxLife();
 
     /**
      * Sets the idleTime attribute of the IAttributes object. This is the maximum time the item can
@@ -197,4 +197,7 @@ public interface IElementAttributes
      */
     void addElementEventHandlers( List<IElementEventHandler> eventHandlers );
 
+    long getTimeFactorForMilliseconds();
+
+    void setTimeFactorForMilliseconds(long factor);
 }

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCache.java?rev=1594051&r1=1594050&r2=1594051&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCache.java (original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCache.java Mon May 12 18:51:56 2014
@@ -1614,10 +1614,10 @@ public class CompositeCache<K, V>
             {
                 // Remove if maxLifeSeconds exceeded
 
-                long maxLifeSeconds = attributes.getMaxLifeSeconds();
+                long maxLifeSeconds = attributes.getMaxLife();
                 long createTime = attributes.getCreateTime();
 
-                if ( maxLifeSeconds != -1 && ( timestamp - createTime ) > ( maxLifeSeconds * 1000 ) )
+                if ( maxLifeSeconds != -1 && ( timestamp - createTime ) > ( maxLifeSeconds * attributes.getTimeFactorForMilliseconds() ) )
                 {
                     if ( log.isDebugEnabled() )
                     {

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/access/CacheAccessUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/access/CacheAccessUnitTest.java?rev=1594051&r1=1594050&r2=1594051&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/access/CacheAccessUnitTest.java (original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/access/CacheAccessUnitTest.java Mon May 12 18:51:56 2014
@@ -134,12 +134,12 @@ public class CacheAccessUnitTest
 
         long maxLife = 9876;
         IElementAttributes attr = new ElementAttributes();
-        attr.setMaxLifeSeconds( maxLife );
+        attr.setMaxLife(maxLife);
 
         access.setDefaultElementAttributes( attr );
 
-        assertEquals( "Wrong element attributes.", attr.getMaxLifeSeconds(), access.getDefaultElementAttributes()
-            .getMaxLifeSeconds() );
+        assertEquals( "Wrong element attributes.", attr.getMaxLife(), access.getDefaultElementAttributes()
+            .getMaxLife() );
 
         String key = "mykey";
         String value = "myvalue";
@@ -149,7 +149,7 @@ public class CacheAccessUnitTest
         ICacheElement<String, String> element = access.getCacheElement( key );
 
         assertEquals( "Wrong max life.  Should have the new value.", maxLife, element.getElementAttributes()
-            .getMaxLifeSeconds() );
+            .getMaxLife() );
     }
 
     /**
@@ -236,7 +236,7 @@ public class CacheAccessUnitTest
 
         long maxLife = 9876;
         IElementAttributes attr = new ElementAttributes();
-        attr.setMaxLifeSeconds( maxLife );
+        attr.setMaxLife(maxLife);
 
         CacheAccess<String, String> access = JCS.defineRegion( "testRegionDefinitonWithAttributes", ca, attr );
         assertNotNull( "We should have an access class", access );
@@ -264,7 +264,7 @@ public class CacheAccessUnitTest
 
         long maxLife = 9876;
         IElementAttributes attr = new ElementAttributes();
-        attr.setMaxLifeSeconds( maxLife );
+        attr.setMaxLife(maxLife);
 
         CacheAccess<String, Integer> access = JCS.defineRegion( "testGetMatching_Normal", cattr, attr );
 
@@ -318,7 +318,7 @@ public class CacheAccessUnitTest
 
         long maxLife = 9876;
         IElementAttributes attr = new ElementAttributes();
-        attr.setMaxLifeSeconds( maxLife );
+        attr.setMaxLife(maxLife);
 
         CacheAccess<String, Integer> access = JCS.defineRegion( "testGetMatching_Normal", cattr, attr );
 

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheListenerUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheListenerUnitTest.java?rev=1594051&r1=1594050&r2=1594051&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheListenerUnitTest.java (original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheListenerUnitTest.java Mon May 12 18:51:56 2014
@@ -60,7 +60,7 @@ public class RemoteCacheListenerUnitTest
         String key = "key";
         String value = "value fdsadf dsafdsa fdsaf dsafdsaf dsafdsaf dsaf dsaf dsaf dsafa dsaf dsaf dsafdsaf";
         IElementAttributes attr = new ElementAttributes();
-        attr.setMaxLifeSeconds( 34 );
+        attr.setMaxLife(34);
 
         IElementSerializer elementSerializer = new StandardSerializer();
 
@@ -77,8 +77,8 @@ public class RemoteCacheListenerUnitTest
 
         assertNotNull( "Should have a deserialized object.", after );
         assertEquals( "Values should be the same.", value, after.getVal() );
-        assertEquals( "Attributes should be the same.", attr.getMaxLifeSeconds(), after
-            .getElementAttributes().getMaxLifeSeconds() );
+        assertEquals( "Attributes should be the same.", attr.getMaxLife(), after
+            .getElementAttributes().getMaxLife() );
         assertEquals( "Keys should be the same.", key, after.getKey() );
         assertEquals( "Cache name should be the same.", cacheName, after.getCacheName() );
     }
@@ -103,7 +103,7 @@ public class RemoteCacheListenerUnitTest
         String key = "key";
         String value = "value fdsadf dsafdsa fdsaf dsafdsaf dsafdsaf dsaf dsaf dsaf dsafa dsaf dsaf dsafdsaf";
         IElementAttributes attr = new ElementAttributes();
-        attr.setMaxLifeSeconds( 34 );
+        attr.setMaxLife(34);
 
         IElementSerializer elementSerializer = new StandardSerializer();
 

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/shrinking/ShrinkerThreadUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/shrinking/ShrinkerThreadUnitTest.java?rev=1594051&r1=1594050&r2=1594051&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/shrinking/ShrinkerThreadUnitTest.java (original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/shrinking/ShrinkerThreadUnitTest.java Mon May 12 18:51:56 2014
@@ -60,7 +60,7 @@ public class ShrinkerThreadUnitTest
         ElementAttributes elementAttr = new ElementAttributes();
         elementAttr.setIsEternal( false );
         element.setElementAttributes( elementAttr );
-        element.getElementAttributes().setMaxLifeSeconds( 1 );
+        element.getElementAttributes().setMaxLife(1);
 
         long now = System.currentTimeMillis();
         // add two seconds
@@ -95,7 +95,7 @@ public class ShrinkerThreadUnitTest
         ElementAttributes elementAttr = new ElementAttributes();
         elementAttr.setIsEternal( false );
         element.setElementAttributes( elementAttr );
-        element.getElementAttributes().setMaxLifeSeconds( 1 );
+        element.getElementAttributes().setMaxLife(1);
 
         long now = System.currentTimeMillis();
         // subtract two seconds
@@ -130,7 +130,7 @@ public class ShrinkerThreadUnitTest
         ElementAttributes elementAttr = new ElementAttributes();
         elementAttr.setIsEternal( false );
         element.setElementAttributes( elementAttr );
-        element.getElementAttributes().setMaxLifeSeconds( 100 );
+        element.getElementAttributes().setMaxLife(100);
         element.getElementAttributes().setIdleTime( 1 );
 
         long now = System.currentTimeMillis();
@@ -166,7 +166,7 @@ public class ShrinkerThreadUnitTest
         ElementAttributes elementAttr = new ElementAttributes();
         elementAttr.setIsEternal( false );
         element.setElementAttributes( elementAttr );
-        element.getElementAttributes().setMaxLifeSeconds( 100 );
+        element.getElementAttributes().setMaxLife(100);
         element.getElementAttributes().setIdleTime( 1 );
 
         long now = System.currentTimeMillis();
@@ -209,7 +209,7 @@ public class ShrinkerThreadUnitTest
         ElementAttributes elementAttr = new ElementAttributes();
         elementAttr.setIsEternal( false );
         element.setElementAttributes( elementAttr );
-        element.getElementAttributes().setMaxLifeSeconds( 1 );
+        element.getElementAttributes().setMaxLife(1);
         memory.update( element );
 
         ICacheElement<String, String> returnedElement1 = memory.get( key );
@@ -258,7 +258,7 @@ public class ShrinkerThreadUnitTest
             ElementAttributes elementAttr = new ElementAttributes();
             elementAttr.setIsEternal( false );
             element.setElementAttributes( elementAttr );
-            element.getElementAttributes().setMaxLifeSeconds( 1 );
+            element.getElementAttributes().setMaxLife(1);
             memory.update( element );
 
             ICacheElement<String, String> returnedElement1 = memory.get( key );
@@ -311,7 +311,7 @@ public class ShrinkerThreadUnitTest
             elementAttr.addElementEventHandler( handler );
             elementAttr.setIsEternal( false );
             element.setElementAttributes( elementAttr );
-            element.getElementAttributes().setMaxLifeSeconds( 1 );
+            element.getElementAttributes().setMaxLife(1);
             memory.update( element );
 
             ICacheElement<String, String> returnedElement1 = memory.get( key );

Modified: commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/serialization/SerializationConversionUtilUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/serialization/SerializationConversionUtilUnitTest.java?rev=1594051&r1=1594050&r2=1594051&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/serialization/SerializationConversionUtilUnitTest.java (original)
+++ commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/serialization/SerializationConversionUtilUnitTest.java Mon May 12 18:51:56 2014
@@ -93,7 +93,7 @@ public class SerializationConversionUtil
         IElementSerializer elementSerializer = new StandardSerializer();
 
         IElementAttributes attr = new ElementAttributes();
-        attr.setMaxLifeSeconds( 34 );
+        attr.setMaxLife(34);
 
         ICacheElement<String, String> before = new CacheElement<String, String>( cacheName, key, value );
         before.setElementAttributes( attr );
@@ -112,8 +112,8 @@ public class SerializationConversionUtil
         // VERIFY
         assertNotNull( "Should have a deserialized object.", after );
         assertEquals( "Values should be the same.", before.getVal(), after.getVal() );
-        assertEquals( "Attributes should be the same.", before.getElementAttributes().getMaxLifeSeconds(), after
-            .getElementAttributes().getMaxLifeSeconds() );
+        assertEquals( "Attributes should be the same.", before.getElementAttributes().getMaxLife(), after
+            .getElementAttributes().getMaxLife() );
         assertEquals( "Keys should be the same.", before.getKey(), after.getKey() );
         assertEquals( "Cache name should be the same.", before.getCacheName(), after.getCacheName() );
     }
@@ -134,7 +134,7 @@ public class SerializationConversionUtil
         IElementSerializer elementSerializer = new StandardSerializer();
 
         IElementAttributes attr = new ElementAttributes();
-        attr.setMaxLifeSeconds( 34 );
+        attr.setMaxLife(34);
 
         ICacheElement<String, String> before = new CacheElement<String, String>( cacheName, key, value );
         before.setElementAttributes( attr );
@@ -155,8 +155,8 @@ public class SerializationConversionUtil
         // VERIFY
         assertNotNull( "Should have a deserialized object.", after );
         assertEquals( "Values should be the same.", before.getVal(), after.getVal() );
-        assertEquals( "Attributes should be the same.", before.getElementAttributes().getMaxLifeSeconds(), after
-            .getElementAttributes().getMaxLifeSeconds() );
+        assertEquals( "Attributes should be the same.", before.getElementAttributes().getMaxLife(), after
+            .getElementAttributes().getMaxLife() );
         assertEquals( "Keys should be the same.", before.getKey(), after.getKey() );
         assertEquals( "Cache name should be the same.", before.getCacheName(), after.getCacheName() );
     }
@@ -174,7 +174,7 @@ public class SerializationConversionUtil
         IElementSerializer elementSerializer = null;// new StandardSerializer();
 
         IElementAttributes attr = new ElementAttributes();
-        attr.setMaxLifeSeconds( 34 );
+        attr.setMaxLife(34);
 
         ICacheElement<String, String> before = new CacheElement<String, String>( cacheName, key, value );
         before.setElementAttributes( attr );

Modified: commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java?rev=1594051&r1=1594050&r2=1594051&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java (original)
+++ commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java Mon May 12 18:51:56 2014
@@ -18,7 +18,9 @@
  */
 package org.apache.commons.jcs.jcache;
 
-import org.apache.commons.jcs.access.CacheAccess;
+import org.apache.commons.jcs.engine.CacheElement;
+import org.apache.commons.jcs.engine.behavior.ICacheElement;
+import org.apache.commons.jcs.engine.behavior.IElementAttributes;
 import org.apache.commons.jcs.engine.behavior.IElementSerializer;
 import org.apache.commons.jcs.engine.control.CompositeCache;
 import org.apache.commons.jcs.jcache.jmx.JCSCacheMXBean;
@@ -30,6 +32,7 @@ import org.apache.commons.jcs.jcache.thr
 import org.apache.commons.jcs.utils.serialization.StandardSerializer;
 
 import javax.cache.Cache;
+import javax.cache.CacheException;
 import javax.cache.CacheManager;
 import javax.cache.configuration.CacheEntryListenerConfiguration;
 import javax.cache.configuration.Configuration;
@@ -49,6 +52,7 @@ import javax.cache.processor.EntryProces
 import javax.cache.processor.EntryProcessorResult;
 import javax.management.ObjectName;
 import java.io.Closeable;
+import java.io.IOException;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -69,7 +73,7 @@ public class JCSCache<K, V> implements C
 {
     private static final Subsitutor SUBSTITUTOR = Subsitutor.Helper.INSTANCE;
 
-    private final CacheAccess<JCSKey<K>, JCSElement<V>> delegate;
+    private final CompositeCache<K, V> delegate;
     private final JCSCachingManager manager;
     private final JCSConfiguration<K, V> config;
     private final CacheLoader<K, V> loader;
@@ -87,13 +91,13 @@ public class JCSCache<K, V> implements C
 
     public JCSCache(final ClassLoader classLoader, final JCSCachingManager mgr,
                     final String cacheName, final JCSConfiguration<K, V> configuration,
-                    final Properties properties, final CompositeCache<JCSKey<K>, JCSElement<V>> cache)
+                    final Properties properties, final CompositeCache<K, V> cache)
     {
         manager = mgr;
 
         name = cacheName;
 
-        delegate = new CacheAccess<JCSKey<K>, JCSElement<V>>(cache);
+        delegate = cache;
 
         config = configuration;
 
@@ -194,7 +198,7 @@ public class JCSCache<K, V> implements C
     {
         assertNotClosed();
         assertNotNull(key, "key");
-        return doGetControllingExpiry(new JCSKey<K>(key), true, false, false, true);
+        return doGetControllingExpiry(key, true, false, false, true);
     }
 
     private V doLoad(final K key, final boolean update, final boolean propagateLoadException)
@@ -214,21 +218,57 @@ public class JCSCache<K, V> implements C
         if (v != null)
         {
             final Duration duration = update ? expiryPolicy.getExpiryForUpdate() : expiryPolicy.getExpiryForCreation();
-            if (duration == null || !duration.isZero())
+            if (isNotZero(duration))
             {
-                final JCSKey<K> jcsKey = new JCSKey<K>(key);
-                delegate.put(jcsKey, new JCSElement<V>(v, duration));
+                final ICacheElement<K, V> element = createElement(key, v, duration);
+                try
+                {
+                    delegate.update(element);
+                }
+                catch (final IOException e)
+                {
+                    throw new CacheException(e);
+                }
             }
         }
         return v;
     }
 
-    private void touch(final JCSKey<K> key, final JCSElement<V> elt)
+    private ICacheElement<K, V> createElement(final K key, final V v, final Duration duration)
+    {
+        final ICacheElement<K, V> element = new CacheElement<K, V>(name, key, v);
+        final IElementAttributes copy = delegate.getElementAttributes().copy();
+        if (duration != null)
+        {
+            copy.setTimeFactorForMilliseconds(1);
+            final boolean eternal = duration.isEternal();
+            if (eternal)
+            {
+                copy.setIsEternal(true);
+            }
+            else
+            {
+                copy.setIsEternal(false);
+                copy.setMaxLife(duration.getTimeUnit().toMillis(duration.getDurationAmount()));
+            }
+        }
+        element.setElementAttributes(copy);
+        return element;
+    }
+
+    private void touch(final K key, final ICacheElement<K, V> element)
     {
         if (config.isStoreByValue())
         {
-            final K copy = copy(serializer, manager.getClassLoader(), key.getKey());
-            delegate.put(new JCSKey<K>(copy), elt);
+            final K copy = copy(serializer, manager.getClassLoader(), key);
+            try
+            {
+                delegate.update(new CacheElement<K, V>(name, copy, element.getVal(), element.getElementAttributes()));
+            }
+            catch (final IOException e)
+            {
+                throw new CacheException(e);
+            }
         }
     }
 
@@ -245,9 +285,8 @@ public class JCSCache<K, V> implements C
         for (final K key : keys) {
             assertNotNull(key, "key");
 
-            final JCSKey<K> cacheKey = new JCSKey<K>(key);
-            final JCSElement<V> elt = delegate.get(cacheKey);
-            V val = elt != null ? elt.getElement() : null;
+            final ICacheElement<K, V> elt = delegate.get(key);
+            V val = elt != null ? elt.getVal() : null;
             if (val == null && config.isReadThrough())
             {
                 val = doLoad(key, false, false);
@@ -258,15 +297,15 @@ public class JCSCache<K, V> implements C
             }
             else if (elt != null)
             {
-                elt.update(expiryPolicy.getExpiryForAccess());
-                if (elt.isExpired())
+                final Duration expiryForAccess = expiryPolicy.getExpiryForAccess();
+                if (isNotZero(expiryForAccess))
                 {
-                    expires(cacheKey);
+                    touch(key, elt);
+                    result.put(key, val);
                 }
                 else
                 {
-                    touch(cacheKey, elt);
-                    result.put(key, val);
+                    expires(key);
                 }
             }
         }
@@ -278,7 +317,7 @@ public class JCSCache<K, V> implements C
     {
         assertNotClosed();
         assertNotNull(key, "key");
-        return delegate.get(new JCSKey<K>(key)) != null;
+        return delegate.get(key) != null;
     }
 
     @Override
@@ -291,28 +330,27 @@ public class JCSCache<K, V> implements C
         final boolean statisticsEnabled = config.isStatisticsEnabled();
         final long start = Times.now(false); // needed for access (eviction)
 
-        final JCSKey<K> cacheKey = new JCSKey<K>(key);
-        final JCSElement<V> oldElt = delegate.get(cacheKey);
-        final V old = oldElt != null ? oldElt.getElement() : null;
+        final ICacheElement<K, V> oldElt = delegate.get(key);
+        final V old = oldElt != null ? oldElt.getVal() : null;
 
         final boolean storeByValue = config.isStoreByValue();
         final V value = storeByValue ? copy(serializer, manager.getClassLoader(), rawValue) : rawValue;
 
         final boolean created = old == null;
-        final JCSElement<V> element = new JCSElement<V>(value, created ? expiryPolicy.getExpiryForCreation()
-                : expiryPolicy.getExpiryForUpdate());
-        if (element.isExpired())
+        final Duration duration = created ? expiryPolicy.getExpiryForCreation() : expiryPolicy.getExpiryForUpdate();
+        if (isNotZero(duration))
         {
-            if (!created)
+            final K jcsKey = storeByValue ? copy(serializer, manager.getClassLoader(), key) : key;
+            final ICacheElement<K, V> element = createElement(jcsKey, value, duration);
+            writer.write(new JCSEntry<K, V>(jcsKey, value));
+            try
             {
-                expires(cacheKey);
+                delegate.update(element);
+            }
+            catch (final IOException e)
+            {
+                throw new CacheException(e);
             }
-        }
-        else
-        {
-            writer.write(new JCSEntry<K, V>(key, value));
-            final JCSKey<K> jcsKey = storeByValue ? new JCSKey<K>(copy(serializer, manager.getClassLoader(), key)) : cacheKey;
-            delegate.put(jcsKey, element);
             for (final JCSListener<K, V> listener : listeners.values())
             {
                 if (created)
@@ -333,16 +371,28 @@ public class JCSCache<K, V> implements C
                 statistics.addPutTime(System.currentTimeMillis() - start);
             }
         }
+        else
+        {
+            if (!created)
+            {
+                expires(key);
+            }
+        }
     }
 
-    private void expires(final JCSKey<K> cacheKey)
+    private static boolean isNotZero(final Duration duration)
     {
-        final JCSElement<V> elt = delegate.get(cacheKey);
+        return duration == null || !duration.isZero();
+    }
+
+    private void expires(final K cacheKey)
+    {
+        final ICacheElement<K, V> elt = delegate.get(cacheKey);
         delegate.remove(cacheKey);
         for (final JCSListener<K, V> listener : listeners.values())
         {
             listener.onExpired(Arrays.<CacheEntryEvent<? extends K, ? extends V>> asList(new JCSCacheEntryEvent<K, V>(this,
-                    EventType.REMOVED, null, cacheKey.getKey(), elt.getElement())));
+                    EventType.REMOVED, null, cacheKey, elt.getVal())));
         }
     }
 
@@ -352,7 +402,7 @@ public class JCSCache<K, V> implements C
         assertNotClosed();
         assertNotNull(key, "key");
         assertNotNull(value, "value");
-        final V v = doGetControllingExpiry(new JCSKey<K>(key), false, false, true, false);
+        final V v = doGetControllingExpiry(key, false, false, true, false);
         put(key, value);
         return v;
     }
@@ -390,17 +440,13 @@ public class JCSCache<K, V> implements C
         final long start = Times.now(!statisticsEnabled);
 
         writer.delete(key);
-        final JCSKey<K> cacheKey = new JCSKey<K>(key);
+        final K cacheKey = key;
 
-        final JCSElement<V> v = delegate.get(cacheKey);
+        final ICacheElement<K, V> v = delegate.get(cacheKey);
         delegate.remove(cacheKey);
 
-        final V value = v != null && v.getElement() != null ? v.getElement() : null;
+        final V value = v != null && v.getVal() != null ? v.getVal() : null;
         boolean remove = v != null;
-        if (v != null && v.isExpired())
-        {
-            remove = false;
-        }
         for (final JCSListener<K, V> listener : listeners.values())
         {
             listener.onRemoved(Arrays.<CacheEntryEvent<? extends K, ? extends V>> asList(new JCSCacheEntryEvent<K, V>(this,
@@ -420,8 +466,7 @@ public class JCSCache<K, V> implements C
         assertNotClosed();
         assertNotNull(key, "key");
         assertNotNull(oldValue, "oldValue");
-        final JCSKey<K> cacheKey = new JCSKey<K>(key);
-        final V v = doGetControllingExpiry(cacheKey, false, false, false, false);
+        final V v = doGetControllingExpiry(key, false, false, false, false);
         final boolean found = v != null;
         if (found)
         {
@@ -430,7 +475,18 @@ public class JCSCache<K, V> implements C
                 remove(key);
                 return true;
             }
-            delegate.get(new JCSKey<K>(key)).update(expiryPolicy.getExpiryForAccess());
+            final Duration expiryForAccess = expiryPolicy.getExpiryForAccess();
+            if (expiryForAccess != null)
+            {
+                try
+                {
+                    delegate.update(createElement(key, v, expiryForAccess));
+                }
+                catch (final IOException e)
+                {
+                    throw new CacheException(e);
+                }
+            }
         }
         return false;
     }
@@ -440,23 +496,23 @@ public class JCSCache<K, V> implements C
     {
         assertNotClosed();
         assertNotNull(key, "key");
-        final V v = doGetControllingExpiry(new JCSKey<K>(key), false, false, true, false);
+        final V v = doGetControllingExpiry(key, false, false, true, false);
         remove(key);
         return v;
     }
 
-    private V doGetControllingExpiry(final JCSKey<K> key, final boolean updateAcess, final boolean forceDoLoad, final boolean skipLoad,
+    private V doGetControllingExpiry(final K key, final boolean updateAcess, final boolean forceDoLoad, final boolean skipLoad,
             final boolean propagateLoadException)
     {
         final boolean statisticsEnabled = config.isStatisticsEnabled();
         final long getStart = Times.now(false);
-        final JCSElement<V> elt = delegate.get(key);
-        V v = elt != null ? elt.getElement() : null;
+        final ICacheElement<K, V> elt = delegate.get(key);
+        V v = elt != null ? elt.getVal() : null;
         if (v == null && (config.isReadThrough() || forceDoLoad))
         {
             if (!skipLoad)
             {
-                v = doLoad(key.getKey(), false, propagateLoadException);
+                v = doLoad(key, false, propagateLoadException);
             }
         }
         else if (statisticsEnabled)
@@ -473,19 +529,26 @@ public class JCSCache<K, V> implements C
 
         if (updateAcess && elt != null)
         {
-            elt.update(expiryPolicy.getExpiryForAccess());
-            if (elt.isExpired())
+            final Duration expiryForAccess = expiryPolicy.getExpiryForAccess();
+            if (!isNotZero(expiryForAccess))
             {
                 expires(key);
             }
-            else
+            else if (expiryForAccess != null && (!elt.getElementAttributes().getIsEternal() || !expiryForAccess.isEternal()))
             {
-                touch(key, elt);
+                try
+                {
+                    delegate.update(createElement(key, elt.getVal(), expiryForAccess));
+                }
+                catch (final IOException e)
+                {
+                    throw new CacheException(e);
+                }
             }
         }
         if (statisticsEnabled && v != null)
         {
-            statistics.addGetTime(Times.now(!statisticsEnabled) - getStart);
+            statistics.addGetTime(Times.now(false) - getStart);
         }
         return v;
     }
@@ -498,15 +561,10 @@ public class JCSCache<K, V> implements C
         assertNotNull(oldValue, "oldValue");
         assertNotNull(newValue, "newValue");
         final boolean statisticsEnabled = config.isStatisticsEnabled();
-        final JCSKey<K> cacheKey = new JCSKey<K>(key);
-        final JCSElement<V> elt = delegate.get(cacheKey);
+        final ICacheElement<K, V> elt = delegate.get(key);
         if (elt != null)
         {
-            V value = elt.getElement();
-            if (elt.isExpired())
-            {
-                value = null;
-            }
+            V value = elt.getVal();
             if (value != null && statisticsEnabled)
             {
                 statistics.increaseHits(1);
@@ -522,8 +580,18 @@ public class JCSCache<K, V> implements C
             }
             else if (value != null)
             {
-                elt.update(expiryPolicy.getExpiryForAccess());
-                touch(cacheKey, elt);
+                final Duration expiryForAccess = expiryPolicy.getExpiryForAccess();
+                if (expiryForAccess != null && (!elt.getElementAttributes().getIsEternal() || !expiryForAccess.isEternal()))
+                {
+                    try
+                    {
+                        delegate.update(createElement(key, elt.getVal(), expiryForAccess));
+                    }
+                    catch (final IOException e)
+                    {
+                        throw new CacheException(e);
+                    }
+                }
             }
         }
         else if (statisticsEnabled)
@@ -565,11 +633,10 @@ public class JCSCache<K, V> implements C
 
         final boolean statisticsEnabled = config.isStatisticsEnabled();
 
-        final JCSKey<K> cacheKey = new JCSKey<K>(key);
-        final JCSElement<V> elt = delegate.get(cacheKey);
+        final ICacheElement<K, V> elt = delegate.get(key);
         if (elt != null)
         {
-            V oldValue = elt.getElement();
+            V oldValue = elt.getVal();
             if (oldValue == null && config.isReadThrough())
             {
                 oldValue = doLoad(key, false, false);
@@ -603,9 +670,9 @@ public class JCSCache<K, V> implements C
     public void removeAll()
     {
         assertNotClosed();
-        for (final JCSKey<K> k : delegate.getCacheControl().getKeySet())
+        for (final K k : delegate.getKeySet())
         {
-            remove(k.getKey());
+            remove(k);
         }
     }
 
@@ -613,7 +680,14 @@ public class JCSCache<K, V> implements C
     public void clear()
     {
         assertNotClosed();
-        delegate.clear();
+        try
+        {
+            delegate.removeAll();
+        }
+        catch (final IOException e)
+        {
+            throw new CacheException(e);
+        }
     }
 
     @Override
@@ -657,7 +731,7 @@ public class JCSCache<K, V> implements C
                 {
                     continue;
                 }
-                doGetControllingExpiry(new JCSKey<K>(k), true, true, false, completionListener != null);
+                doGetControllingExpiry(k, true, true, false, completionListener != null);
             }
         }
         catch (final RuntimeException e)
@@ -782,7 +856,7 @@ public class JCSCache<K, V> implements C
     public Iterator<Entry<K, V>> iterator()
     {
         assertNotClosed();
-        final Iterator<JCSKey<K>> keys = new HashSet<JCSKey<K>>(delegate.getCacheControl().getKeySet()).iterator();
+        final Iterator<K> keys = new HashSet<K>(delegate.getKeySet()).iterator();
         return new Iterator<Entry<K, V>>()
         {
             private K lastKey = null;
@@ -796,8 +870,7 @@ public class JCSCache<K, V> implements C
             @Override
             public Entry<K, V> next()
             {
-                final JCSKey<K> next = keys.next();
-                lastKey = next.getKey();
+                lastKey = keys.next();
                 return new JCSEntry<K, V>(lastKey, get(lastKey));
             }
 
@@ -848,7 +921,14 @@ public class JCSCache<K, V> implements C
         listeners.clear();
         JMXs.unregister(cacheConfigObjectName);
         JMXs.unregister(cacheStatsObjectName);
-        delegate.clear();
+        try
+        {
+            delegate.removeAll();
+        }
+        catch (final IOException e)
+        {
+            throw new CacheException(e);
+        }
     }
 
     private static void close(final Object potentiallyCloseable)

Modified: commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCachingManager.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCachingManager.java?rev=1594051&r1=1594050&r2=1594051&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCachingManager.java (original)
+++ commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCachingManager.java Mon May 12 18:51:56 2014
@@ -136,8 +136,10 @@ public class JCSCachingManager implement
         if (!caches.containsKey(cacheName))
         {
             final Cache<K, V> cache = ClassLoaderAwareCache.wrap(loader,
-                    new JCSCache(loader, this, cacheName,
-                            new JCSConfiguration(configuration, keyType, valueType), properties,
+                    new JCSCache/*<K, V>*/(
+                            loader, this, cacheName,
+                            new JCSConfiguration/*<K, V>*/(configuration, keyType, valueType),
+                            properties,
                             delegate.getCache(cacheName)));
             caches.putIfAbsent(cacheName, cache);
         }

Modified: commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/CacheTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/CacheTest.java?rev=1594051&r1=1594050&r2=1594051&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/CacheTest.java (original)
+++ commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/CacheTest.java Mon May 12 18:51:56 2014
@@ -55,8 +55,7 @@ public class CacheTest
     {
         final CachingProvider cachingProvider = Caching.getCachingProvider();
         final CacheManager cacheManager = cachingProvider.getCacheManager();
-        cacheManager.createCache("default", new MutableConfiguration<Object, Object>());
-        final Cache<String, String> cache = cacheManager.getCache("default");
+        final Cache<String, String> cache = cacheManager.createCache("default", new MutableConfiguration<String, String>());
         assertFalse(cache.containsKey("foo"));
         cache.put("foo", "bar");
         assertTrue(cache.containsKey("foo"));

Added: commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/ImmediateExpiryTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/ImmediateExpiryTest.java?rev=1594051&view=auto
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/ImmediateExpiryTest.java (added)
+++ commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/ImmediateExpiryTest.java Mon May 12 18:51:56 2014
@@ -0,0 +1,34 @@
+package org.apache.commons.jcs.jcache;
+
+import org.junit.Test;
+
+import javax.cache.Cache;
+import javax.cache.CacheManager;
+import javax.cache.Caching;
+import javax.cache.configuration.FactoryBuilder;
+import javax.cache.configuration.MutableConfiguration;
+import javax.cache.expiry.CreatedExpiryPolicy;
+import javax.cache.expiry.Duration;
+import javax.cache.expiry.ExpiryPolicy;
+import javax.cache.spi.CachingProvider;
+
+import static org.junit.Assert.assertFalse;
+
+public class ImmediateExpiryTest
+{
+    @Test
+    public void immediate()
+    {
+        final CachingProvider cachingProvider = Caching.getCachingProvider();
+        final CacheManager cacheManager = cachingProvider.getCacheManager();
+        cacheManager.createCache("default",
+                new MutableConfiguration<Object, Object>()
+                        .setExpiryPolicyFactory(
+                                new FactoryBuilder.SingletonFactory<ExpiryPolicy>(new CreatedExpiryPolicy(Duration.ZERO))));
+        final Cache<String, String> cache = cacheManager.getCache("default");
+        assertFalse(cache.containsKey("foo"));
+        cache.put("foo", "bar");
+        assertFalse(cache.containsKey("foo"));
+        cachingProvider.close();
+    }
+}