/** verify the check for removal * <p> * @throws IOException */ public void testCheckForRemoval_NotExpired() throws IOException { // SETUP CompositeCacheAttributes cacheAttr = new CompositeCacheAttributes(); cacheAttr.setCacheName("testRegion"); cacheAttr.setMaxMemoryIdleTimeSeconds( 10 ); cacheAttr.setMaxSpoolPerRun( 10 ); CompositeCache<String, String> cache = new CompositeCache<String, String>(cacheAttr, new ElementAttributes()); String key = "key"; String value = "value"; ICacheElement<String, String> element = new CacheElement<String, String>( "testRegion", key, value ); ElementAttributes elementAttr = new ElementAttributes(); elementAttr.setIsEternal( false ); element.setElementAttributes( elementAttr ); element.getElementAttributes().setMaxLife(1); long now = System.currentTimeMillis(); // subtract two seconds now -= 2000; // DO WORK boolean result = cache.isExpired( element, now, ElementEventType.EXCEEDED_MAXLIFE_BACKGROUND, ElementEventType.EXCEEDED_IDLETIME_BACKGROUND ); // VERIFY assertFalse( "Item should not have expired.", result ); }
/** verify the check for removal * <p> * @throws IOException */ public void testCheckForRemoval_NotExpired() throws IOException { // SETUP CompositeCacheAttributes cacheAttr = new CompositeCacheAttributes(); cacheAttr.setCacheName("testRegion"); cacheAttr.setMaxMemoryIdleTimeSeconds( 10 ); cacheAttr.setMaxSpoolPerRun( 10 ); CompositeCache<String, String> cache = new CompositeCache<String, String>(cacheAttr, new ElementAttributes()); String key = "key"; String value = "value"; ICacheElement<String, String> element = new CacheElement<String, String>( "testRegion", key, value ); ElementAttributes elementAttr = new ElementAttributes(); elementAttr.setIsEternal( false ); element.setElementAttributes( elementAttr ); element.getElementAttributes().setMaxLife(1); long now = System.currentTimeMillis(); // subtract two seconds now -= 2000; // DO WORK boolean result = cache.isExpired( element, now, ElementEventType.EXCEEDED_MAXLIFE_BACKGROUND, ElementEventType.EXCEEDED_IDLETIME_BACKGROUND ); // VERIFY assertFalse( "Item should not have expired.", result ); }
/** verify the check for removal * <p> * @throws IOException */ public void testCheckForRemoval_Expired() throws IOException { // SETUP CompositeCacheAttributes cacheAttr = new CompositeCacheAttributes(); cacheAttr.setCacheName("testRegion"); cacheAttr.setMaxMemoryIdleTimeSeconds( 10 ); cacheAttr.setMaxSpoolPerRun( 10 ); CompositeCache<String, String> cache = new CompositeCache<String, String>(cacheAttr, new ElementAttributes()); String key = "key"; String value = "value"; ICacheElement<String, String> element = new CacheElement<String, String>( "testRegion", key, value ); ElementAttributes elementAttr = new ElementAttributes(); elementAttr.setIsEternal( false ); element.setElementAttributes( elementAttr ); element.getElementAttributes().setMaxLife(1); long now = System.currentTimeMillis(); // add two seconds now += 2000; // DO WORK boolean result = cache.isExpired( element, now, ElementEventType.EXCEEDED_MAXLIFE_BACKGROUND, ElementEventType.EXCEEDED_IDLETIME_BACKGROUND ); // VERIFY assertTrue( "Item should have expired.", result ); }
/** verify the check for removal * <p> * @throws IOException */ public void testCheckForRemoval_IdleTooLong() throws IOException { // SETUP CompositeCacheAttributes cacheAttr = new CompositeCacheAttributes(); cacheAttr.setCacheName("testRegion"); cacheAttr.setMaxMemoryIdleTimeSeconds( 10 ); cacheAttr.setMaxSpoolPerRun( 10 ); CompositeCache<String, String> cache = new CompositeCache<String, String>(cacheAttr, new ElementAttributes()); String key = "key"; String value = "value"; ICacheElement<String, String> element = new CacheElement<String, String>( "testRegion", key, value ); ElementAttributes elementAttr = new ElementAttributes(); elementAttr.setIsEternal( false ); element.setElementAttributes( elementAttr ); element.getElementAttributes().setMaxLife(100); element.getElementAttributes().setIdleTime( 1 ); long now = System.currentTimeMillis(); // add two seconds now += 2000; // DO WORK boolean result = cache.isExpired( element, now, ElementEventType.EXCEEDED_MAXLIFE_BACKGROUND, ElementEventType.EXCEEDED_IDLETIME_BACKGROUND ); // VERIFY assertTrue( "Item should have expired.", result ); }
/** verify the check for removal * <p> * @throws IOException */ public void testCheckForRemoval_Expired() throws IOException { // SETUP CompositeCacheAttributes cacheAttr = new CompositeCacheAttributes(); cacheAttr.setCacheName("testRegion"); cacheAttr.setMaxMemoryIdleTimeSeconds( 10 ); cacheAttr.setMaxSpoolPerRun( 10 ); CompositeCache<String, String> cache = new CompositeCache<String, String>(cacheAttr, new ElementAttributes()); String key = "key"; String value = "value"; ICacheElement<String, String> element = new CacheElement<String, String>( "testRegion", key, value ); ElementAttributes elementAttr = new ElementAttributes(); elementAttr.setIsEternal( false ); element.setElementAttributes( elementAttr ); element.getElementAttributes().setMaxLife(1); long now = System.currentTimeMillis(); // add two seconds now += 2000; // DO WORK boolean result = cache.isExpired( element, now, ElementEventType.EXCEEDED_MAXLIFE_BACKGROUND, ElementEventType.EXCEEDED_IDLETIME_BACKGROUND ); // VERIFY assertTrue( "Item should have expired.", result ); }
/** verify the check for removal * <p> * @throws IOException */ public void testCheckForRemoval_IdleTooLong() throws IOException { // SETUP CompositeCacheAttributes cacheAttr = new CompositeCacheAttributes(); cacheAttr.setCacheName("testRegion"); cacheAttr.setMaxMemoryIdleTimeSeconds( 10 ); cacheAttr.setMaxSpoolPerRun( 10 ); CompositeCache<String, String> cache = new CompositeCache<String, String>(cacheAttr, new ElementAttributes()); String key = "key"; String value = "value"; ICacheElement<String, String> element = new CacheElement<String, String>( "testRegion", key, value ); ElementAttributes elementAttr = new ElementAttributes(); elementAttr.setIsEternal( false ); element.setElementAttributes( elementAttr ); element.getElementAttributes().setMaxLife(100); element.getElementAttributes().setIdleTime( 1 ); long now = System.currentTimeMillis(); // add two seconds now += 2000; // DO WORK boolean result = cache.isExpired( element, now, ElementEventType.EXCEEDED_MAXLIFE_BACKGROUND, ElementEventType.EXCEEDED_IDLETIME_BACKGROUND ); // VERIFY assertTrue( "Item should have expired.", result ); }
/** verify the check for removal * <p> * @throws IOException */ public void testCheckForRemoval_NotIdleTooLong() throws IOException { // SETUP CompositeCacheAttributes cacheAttr = new CompositeCacheAttributes(); cacheAttr.setCacheName("testRegion"); cacheAttr.setMaxMemoryIdleTimeSeconds( 10 ); cacheAttr.setMaxSpoolPerRun( 10 ); CompositeCache<String, String> cache = new CompositeCache<String, String>(cacheAttr, new ElementAttributes()); String key = "key"; String value = "value"; ICacheElement<String, String> element = new CacheElement<String, String>( "testRegion", key, value ); ElementAttributes elementAttr = new ElementAttributes(); elementAttr.setIsEternal( false ); element.setElementAttributes( elementAttr ); element.getElementAttributes().setMaxLife(100); element.getElementAttributes().setIdleTime( 1 ); long now = System.currentTimeMillis(); // subtract two seconds now -= 2000; // DO WORK boolean result = cache.isExpired( element, now, ElementEventType.EXCEEDED_MAXLIFE_BACKGROUND, ElementEventType.EXCEEDED_IDLETIME_BACKGROUND ); // VERIFY assertFalse( "Item should not have expired.", result ); }
/** verify the check for removal * <p> * @throws IOException */ public void testCheckForRemoval_NotIdleTooLong() throws IOException { // SETUP CompositeCacheAttributes cacheAttr = new CompositeCacheAttributes(); cacheAttr.setCacheName("testRegion"); cacheAttr.setMaxMemoryIdleTimeSeconds( 10 ); cacheAttr.setMaxSpoolPerRun( 10 ); CompositeCache<String, String> cache = new CompositeCache<String, String>(cacheAttr, new ElementAttributes()); String key = "key"; String value = "value"; ICacheElement<String, String> element = new CacheElement<String, String>( "testRegion", key, value ); ElementAttributes elementAttr = new ElementAttributes(); elementAttr.setIsEternal( false ); element.setElementAttributes( elementAttr ); element.getElementAttributes().setMaxLife(100); element.getElementAttributes().setIdleTime( 1 ); long now = System.currentTimeMillis(); // subtract two seconds now -= 2000; // DO WORK boolean result = cache.isExpired( element, now, ElementEventType.EXCEEDED_MAXLIFE_BACKGROUND, ElementEventType.EXCEEDED_IDLETIME_BACKGROUND ); // VERIFY assertFalse( "Item should not have expired.", result ); }
cacheAttr.setMemoryCacheName("org.apache.commons.jcs.engine.memory.MockMemoryCache"); cacheAttr.setMaxMemoryIdleTimeSeconds( 1 ); cacheAttr.setMaxSpoolPerRun( 10 );
cacheAttr.setMemoryCacheName("org.apache.commons.jcs.engine.memory.MockMemoryCache"); cacheAttr.setMaxMemoryIdleTimeSeconds( 1 ); cacheAttr.setMaxSpoolPerRun( 10 );
cacheAttr.setMemoryCacheName("org.apache.commons.jcs.engine.memory.MockMemoryCache"); cacheAttr.setMaxMemoryIdleTimeSeconds( 1 ); cacheAttr.setMaxSpoolPerRun( 3 );
cacheAttr.setMemoryCacheName("org.apache.commons.jcs.engine.memory.MockMemoryCache"); cacheAttr.setMaxMemoryIdleTimeSeconds( 1 ); cacheAttr.setMaxSpoolPerRun( 3 );
cacheAttr.setMemoryCacheName("org.apache.commons.jcs.engine.memory.MockMemoryCache"); cacheAttr.setMaxMemoryIdleTimeSeconds( 1 ); cacheAttr.setMaxSpoolPerRun( 3 );
cacheAttr.setMemoryCacheName("org.apache.commons.jcs.engine.memory.MockMemoryCache"); cacheAttr.setMaxMemoryIdleTimeSeconds( 1 ); cacheAttr.setMaxSpoolPerRun( 3 );