@Override public IndexedDiskCacheAttributes getCacheAttributes() { IndexedDiskCacheAttributes ret = new IndexedDiskCacheAttributes(); ret.setDiskLimitType(DiskLimitType.COUNT); return ret; } public void testRecycleBin()
@Override public IndexedDiskCacheAttributes getCacheAttributes() { IndexedDiskCacheAttributes ret = new IndexedDiskCacheAttributes(); ret.setDiskLimitType(DiskLimitType.SIZE); return ret; } public void testRecycleBin()
@Override public IndexedDiskCacheAttributes getCacheAttributes() { IndexedDiskCacheAttributes ret = new IndexedDiskCacheAttributes(); ret.setDiskLimitType(DiskLimitType.COUNT); return ret; } public void testRecycleBin()
@Override public IndexedDiskCacheAttributes getCacheAttributes() { IndexedDiskCacheAttributes ret = new IndexedDiskCacheAttributes(); ret.setDiskLimitType(DiskLimitType.SIZE); return ret; } public void testRecycleBin()
/** * The main program for the DiskDumper class * <p> * Creates a disk cache and then calls dump, which write out the contents to * a debug log. * <p> * @param args * The command line arguments */ public static void main( String[] args ) { if ( args.length != 1 ) { System.out.println( "Usage: java org.apache.commons.jcs.auxiliary.disk.DiskDump <cache_name>" ); System.exit( 0 ); } IndexedDiskCacheAttributes attr = new IndexedDiskCacheAttributes(); attr.setCacheName( args[0] ); attr.setDiskPath( args[0] ); IndexedDiskCache<Serializable, Serializable> dc = new IndexedDiskCache<Serializable, Serializable>( attr ); dc.dump( true ); System.exit( 0 ); } }
/** * The main program for the DiskDumper class * <p> * Creates a disk cache and then calls dump, which write out the contents to * a debug log. * <p> * @param args * The command line arguments */ public static void main( String[] args ) { if ( args.length != 1 ) { System.out.println( "Usage: java org.apache.commons.jcs.auxiliary.disk.DiskDump <cache_name>" ); System.exit( 0 ); } IndexedDiskCacheAttributes attr = new IndexedDiskCacheAttributes(); attr.setCacheName( args[0] ); attr.setDiskPath( args[0] ); IndexedDiskCache<Serializable, Serializable> dc = new IndexedDiskCache<Serializable, Serializable>( attr ); dc.dump( true ); System.exit( 0 ); } }
/** * Verify that removeAll is prohibited. * <p> * @throws IOException */ public void testRemoveAll_notAllowed() throws IOException { // SETUP StringWriter stringWriter = new StringWriter(); TestLogConfigurationUtil.configureLogger( stringWriter, AbstractDiskCache.class.getName() ); IDiskCacheAttributes diskCacheAttributes = new IndexedDiskCacheAttributes(); diskCacheAttributes.setAllowRemoveAll( false ); AbstractDiskCacheTestInstance<String, String> diskCache = new AbstractDiskCacheTestInstance<String, String>( diskCacheAttributes ); String cacheName = "testRemoveAll_notAllowed"; String key = "myKey"; String value = "myValue"; IElementAttributes elementAttributes = new ElementAttributes(); ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value, elementAttributes ); diskCache.update( cacheElement ); // DO WORK diskCache.removeAll(); String result = stringWriter.toString(); // VERIFY assertTrue( "Should say not allowed.", result.indexOf( "set to false" ) != -1 ); assertNotNull( "Item should be in the map.", diskCache.get( key ) ); }
/** * Verify that removeAll is prohibited. * <p> * @throws IOException */ public void testRemoveAll_notAllowed() throws IOException { // SETUP StringWriter stringWriter = new StringWriter(); TestLogConfigurationUtil.configureLogger( stringWriter, AbstractDiskCache.class.getName() ); IDiskCacheAttributes diskCacheAttributes = new IndexedDiskCacheAttributes(); diskCacheAttributes.setAllowRemoveAll( false ); AbstractDiskCacheTestInstance<String, String> diskCache = new AbstractDiskCacheTestInstance<String, String>( diskCacheAttributes ); String cacheName = "testRemoveAll_notAllowed"; String key = "myKey"; String value = "myValue"; IElementAttributes elementAttributes = new ElementAttributes(); ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value, elementAttributes ); diskCache.update( cacheElement ); // DO WORK diskCache.removeAll(); String result = stringWriter.toString(); // VERIFY assertTrue( "Should say not allowed.", result.indexOf( "set to false" ) != -1 ); assertNotNull( "Item should be in the map.", diskCache.get( key ) ); }
/** * Verify that update and get work. * <p> * @throws IOException */ public void testUpdateGet_allowed() throws IOException { // SETUP String cacheName = "testUpdateGet_allowed"; IDiskCacheAttributes diskCacheAttributes = new IndexedDiskCacheAttributes(); diskCacheAttributes.setCacheName( cacheName ); AbstractDiskCacheTestInstance<String, String> diskCache = new AbstractDiskCacheTestInstance<String, String>( diskCacheAttributes ); String key = "myKey"; String value = "myValue"; IElementAttributes elementAttributes = new ElementAttributes(); ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value, elementAttributes ); diskCache.update( cacheElement ); // DO WORK ICacheElement<String, String> result = diskCache.get( key ); // VERIFY //System.out.println( diskCache.getStats() ); assertNotNull( "Item should be in the map.", result ); }
/** * Verify that update and get work. * <p> * @throws IOException */ public void testUpdateGet_allowed() throws IOException { // SETUP String cacheName = "testUpdateGet_allowed"; IDiskCacheAttributes diskCacheAttributes = new IndexedDiskCacheAttributes(); diskCacheAttributes.setCacheName( cacheName ); AbstractDiskCacheTestInstance<String, String> diskCache = new AbstractDiskCacheTestInstance<String, String>( diskCacheAttributes ); String key = "myKey"; String value = "myValue"; IElementAttributes elementAttributes = new ElementAttributes(); ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value, elementAttributes ); diskCache.update( cacheElement ); // DO WORK ICacheElement<String, String> result = diskCache.get( key ); // VERIFY //System.out.println( diskCache.getStats() ); assertNotNull( "Item should be in the map.", result ); }
/** * Verify that removeAll is allowed. * <p> * @throws IOException */ public void testRemoveAll_allowed() throws IOException { // SETUP IDiskCacheAttributes diskCacheAttributes = new IndexedDiskCacheAttributes(); diskCacheAttributes.setAllowRemoveAll( true ); AbstractDiskCacheTestInstance<String, String> diskCache = new AbstractDiskCacheTestInstance<String, String>( diskCacheAttributes ); String cacheName = "testRemoveAll_allowed"; String key = "myKey"; String value = "myValue"; IElementAttributes elementAttributes = new ElementAttributes(); ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value, elementAttributes ); diskCache.update( cacheElement ); // DO WORK diskCache.removeAll(); // VERIFY assertNull( "Item should not be in the map.", diskCache.get( key ) ); }
/** * Verify that removeAll is allowed. * <p> * @throws IOException */ public void testRemoveAll_allowed() throws IOException { // SETUP IDiskCacheAttributes diskCacheAttributes = new IndexedDiskCacheAttributes(); diskCacheAttributes.setAllowRemoveAll( true ); AbstractDiskCacheTestInstance<String, String> diskCache = new AbstractDiskCacheTestInstance<String, String>( diskCacheAttributes ); String cacheName = "testRemoveAll_allowed"; String key = "myKey"; String value = "myValue"; IElementAttributes elementAttributes = new ElementAttributes(); ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value, elementAttributes ); diskCache.update( cacheElement ); // DO WORK diskCache.removeAll(); // VERIFY assertNull( "Item should not be in the map.", diskCache.get( key ) ); }
/** * Verify that alive is set to false.. * <p> * @throws IOException */ public void testDispose() throws IOException { // SETUP String cacheName = "testDispose"; IDiskCacheAttributes diskCacheAttributes = new IndexedDiskCacheAttributes(); diskCacheAttributes.setCacheName( cacheName ); AbstractDiskCacheTestInstance<String, String> diskCache = new AbstractDiskCacheTestInstance<String, String>( diskCacheAttributes ); String key = "myKey"; String value = "myValue"; IElementAttributes elementAttributes = new ElementAttributes(); ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value, elementAttributes ); diskCache.update( cacheElement ); // DO WORK diskCache.dispose(); // VERIFY assertFalse( "disk cache should not be alive.", diskCache.alive ); assertEquals( "Status should be disposed", CacheStatus.DISPOSED, diskCache.getStatus() ); }
IndexedDiskCacheAttributes cattr = new IndexedDiskCacheAttributes(); cattr.setCacheName( "testOptimization" ); cattr.setMaxKeySize( removeCount * 2 );
/** * Verify that alive is set to false.. * <p> * @throws IOException */ public void testDispose() throws IOException { // SETUP String cacheName = "testDispose"; IDiskCacheAttributes diskCacheAttributes = new IndexedDiskCacheAttributes(); diskCacheAttributes.setCacheName( cacheName ); AbstractDiskCacheTestInstance<String, String> diskCache = new AbstractDiskCacheTestInstance<String, String>( diskCacheAttributes ); String key = "myKey"; String value = "myValue"; IElementAttributes elementAttributes = new ElementAttributes(); ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value, elementAttributes ); diskCache.update( cacheElement ); // DO WORK diskCache.dispose(); // VERIFY assertFalse( "disk cache should not be alive.", diskCache.isAlive() ); assertEquals( "Status should be disposed", CacheStatus.DISPOSED, diskCache.getStatus() ); }
IndexedDiskCacheAttributes cattr = new IndexedDiskCacheAttributes(); cattr.setCacheName( "testOptimization" ); cattr.setMaxKeySize( removeCount * 2 );
throws Exception IndexedDiskCacheAttributes cattr = new IndexedDiskCacheAttributes(); cattr.setCacheName( "testStoreKeys" ); cattr.setMaxKeySize( 100 );
throws Exception IndexedDiskCacheAttributes cattr = new IndexedDiskCacheAttributes(); cattr.setCacheName( "testStoreKeys" ); cattr.setMaxKeySize( 100 );
throws Exception IndexedDiskCacheAttributes cattr = new IndexedDiskCacheAttributes(); cattr.setCacheName( "testOptimize" ); cattr.setMaxKeySize( 100 );
throws Exception IndexedDiskCacheAttributes cattr = new IndexedDiskCacheAttributes(); cattr.setCacheName( "testOptimize" ); cattr.setMaxKeySize( 100 );