/** 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 ); }
/** * Translates the name to the disk usage pattern short value. * <p> * The allowed values are SWAP and UPDATE. * <p> * @param diskUsagePatternName The diskUsagePattern to set. */ @Override public void setDiskUsagePatternName( String diskUsagePatternName ) { if ( diskUsagePatternName != null ) { String name = diskUsagePatternName.toUpperCase().trim(); if ( name.startsWith( "SWAP" ) ) { this.setDiskUsagePattern( DiskUsagePattern.SWAP ); } else if ( name.startsWith( "UPDATE" ) ) { this.setDiskUsagePattern( DiskUsagePattern.UPDATE ); } } }
/** * Description of the Method * <p> * @return ICompositeCacheAttributes a copy */ @Override public ICompositeCacheAttributes copy() { try { ICompositeCacheAttributes cattr = (CompositeCacheAttributes) this.clone(); return cattr; } catch ( Exception e ) { System.err.println( e.toString() ); return new CompositeCacheAttributes(); } }
new CompositeCacheAttributes(), DEFAULT_REGION );
/** 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 ); }
/** * @param cacheName * @return Returns a CompositeCache */ @Override @SuppressWarnings("unchecked") public <K, V> CompositeCache<K, V> getCache( String cacheName ) { if ( cache == null ) { // System.out.println( "Creating mock cache" ); CompositeCache<K, V> newCache = new CompositeCache<K, V>( new CompositeCacheAttributes(), new ElementAttributes() ); this.setCache( newCache ); } return (CompositeCache<K, V>)cache; }
/** * Translates the name to the disk usage pattern short value. * <p> * The allowed values are SWAP and UPDATE. * <p> * @param diskUsagePatternName The diskUsagePattern to set. */ @Override public void setDiskUsagePatternName( String diskUsagePatternName ) { if ( diskUsagePatternName != null ) { String name = diskUsagePatternName.toUpperCase().trim(); if ( name.startsWith( "SWAP" ) ) { this.setDiskUsagePattern( DiskUsagePattern.SWAP ); } else if ( name.startsWith( "UPDATE" ) ) { this.setDiskUsagePattern( DiskUsagePattern.UPDATE ); } } }
/** 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 ); }
/** * @param cacheName * @return Returns a CompositeCache */ @Override @SuppressWarnings("unchecked") public <K, V> CompositeCache<K, V> getCache( String cacheName ) { if ( cache == null ) { // System.out.println( "Creating mock cache" ); CompositeCache<K, V> newCache = new CompositeCache<K, V>( new CompositeCacheAttributes(), new ElementAttributes() ); this.setCache( newCache ); } return (CompositeCache<K, V>)cache; }
/** 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 ); }
String keyprefix2 = "MyPrefix2"; String memoryCacheClassName = "org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache"; ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setMemoryCacheName( memoryCacheClassName ); cattr.setMaxObjects( maxMemorySize );
/** 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 ); }
String keyprefix2 = "MyPrefix2"; String memoryCacheClassName = "org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache"; ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setMemoryCacheName( memoryCacheClassName ); cattr.setMaxObjects( maxMemorySize );
/** 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 ); }
String keyprefix2 = "MyPrefix2"; String memoryCacheClassName = "org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache"; ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setMemoryCacheName( memoryCacheClassName ); cattr.setMaxObjects( maxMemorySize );
/** 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 ); }
String keyprefix2 = "MyPrefix2"; String memoryCacheClassName = "org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache"; ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setMemoryCacheName( memoryCacheClassName ); cattr.setMaxObjects( maxMemorySize );
/** 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 ); }
String cacheName = "testGetMatching_Normal"; String memoryCacheClassName = "org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache"; ICompositeCacheAttributes cattr = new CompositeCacheAttributes(); cattr.setMemoryCacheName( memoryCacheClassName ); cattr.setMaxObjects( maxMemorySize );
CompositeCacheAttributes cacheAttr = new CompositeCacheAttributes(); cacheAttr.setCacheName("testRegion"); cacheAttr.setMemoryCacheName("org.apache.commons.jcs.engine.memory.MockMemoryCache"); cacheAttr.setMaxMemoryIdleTimeSeconds( 1 ); cacheAttr.setMaxSpoolPerRun( 10 );