LRUMap<String, String> map = new LRUMap<String, String>( total ); map.setChunkSize( 1 ); map.put( i + ":key", "data" + i ); assertNull( map.get( i + ":key" ) ); String res = map.get( i + ":key" ); assertNotNull( "[" + i + ":key] should not be null", res );
/** * Just test that we can put, get and remove as expected. * <p> * @throws Exception * Description of the Exception */ public void testSimpleLoad() throws Exception { LRUMap<String, String> map = new LRUMap<String, String>( items ); for ( int i = 0; i < items; i++ ) { map.put( i + ":key", "data" + i ); } for ( int i = items - 1; i >= 0; i-- ) { String res = map.get( i + ":key" ); assertNotNull( "[" + i + ":key] should not be null", res ); } // test removal map.remove( "300:key" ); assertNull( map.get( "300:key" ) ); }
@Override public boolean shouldRemove() { return maxObjects > 0 && this.size() > maxObjects; }
/** * Just make sure that we can put and get concurrently * * @param map * @param items * @throws Exception */ public void runConcurrentPutGetTests( LRUMap<String, String> map, int items ) throws Exception { for ( int i = 0; i < items; i++ ) { map.put( i + ":key", "data" + i ); } for ( int i = items - 1; i >= 0; i-- ) { String res = map.get( i + ":key" ); assertNotNull( "[" + i + ":key] should not be null", res ); } }
purgatory = new LRUMap<K, PurgatoryElement<K, V>>( diskCacheAttributes.getMaxPurgatorySize() );
/** * Put, get, and remove from a range. This should occur at a range that is not touched by other * tests. * @param map * @param start * @param end * @throws Exception */ public void runConcurrentRangeTests( LRUMap<String, String> map, int start, int end ) throws Exception { for ( int i = start; i < end; i++ ) { map.put( i + ":key", "data" + i ); } for ( int i = end - 1; i >= start; i-- ) { String res = map.get( i + ":key" ); assertNotNull( "[" + i + ":key] should not be null", res ); } // test removal map.remove( start + ":key" ); assertNull( map.get( start + ":key" ) ); } }
/** * Call remove on an empty map * */ public void testRemoveEmpty() { int size = 10; Map<String, String> cache = new LRUMap<String, String>( size ); Object returned = cache.remove( "key:" + 1 ); assertNull( "Shouldn't hvae anything.", returned ); }
/** * Put, get, and remove from a range. This should occur at a range that is * not touched by other tests. * <p> * @param map * @param start * @param end * @throws Exception */ public void runConcurrentRangeTests( LRUMap<String, String> map, int start, int end ) throws Exception { for ( int i = start; i < end; i++ ) { map.put( i + ":key", "data" + i ); } for ( int i = end - 1; i >= start; i-- ) { String res = map.get( i + ":key" ); assertNotNull( "[" + i + ":key] should not be null", res ); } // test removal map.remove( start + ":key" ); assertNull( map.get( start + ":key" ) ); } }
/** * Just make sure that we can put and get concurrently * @param map * @param items * @throws Exception */ public void runConcurrentPutGetTests( LRUMap<String, String> map, int items ) throws Exception { for ( int i = 0; i < items; i++ ) { map.put( i + ":key", "data" + i ); } for ( int i = items - 1; i >= 0; i-- ) { String res = map.get( i + ":key" ); assertNotNull( "[" + i + ":key] should not be null", res ); } }
LRUMap<String, String> map = new LRUMap<String, String>( total ); map.setChunkSize( 1 ); map.put( i + ":key", "data" + i ); assertNull( map.get( i + ":key" ) ); String res = map.get( i + ":key" ); assertNotNull( "[" + i + ":key] should not be null", res );
/** * Just test that we can put, get and remove as expected. * <p> * @throws Exception * Description of the Exception */ public void testSimpleLoad() throws Exception { LRUMap<String, String> map = new LRUMap<String, String>( items ); for ( int i = 0; i < items; i++ ) { map.put( i + ":key", "data" + i ); } for ( int i = items - 1; i >= 0; i-- ) { String res = map.get( i + ":key" ); assertNotNull( "[" + i + ":key] should not be null", res ); } // test removal map.remove( "300:key" ); assertNull( map.get( "300:key" ) ); }
/** * Call remove on an empty map * */ public void testRemoveEmpty() { int size = 10; Map<String, String> cache = new LRUMap<String, String>( size ); Object returned = cache.remove( "key:" + 1 ); assertNull( "Shouldn't hvae anything.", returned ); }
/** * Put, get, and remove from a range. This should occur at a range that is * not touched by other tests. * <p> * @param map * @param start * @param end * @throws Exception */ public void runConcurrentRangeTests( LRUMap<String, String> map, int start, int end ) throws Exception { for ( int i = start; i < end; i++ ) { map.put( i + ":key", "data" + i ); } for ( int i = end - 1; i >= start; i-- ) { String res = map.get( i + ":key" ); assertNotNull( "[" + i + ":key] should not be null", res ); } // test removal map.remove( start + ":key" ); assertNull( map.get( start + ":key" ) ); } }
/** * Just make sure that we can put and get concurrently * * @param map * @param items * @throws Exception */ public void runConcurrentPutGetTests( LRUMap<String, String> map, int items ) throws Exception { for ( int i = 0; i < items; i++ ) { map.put( i + ":key", "data" + i ); } for ( int i = items - 1; i >= 0; i-- ) { String res = map.get( i + ":key" ); assertNotNull( "[" + i + ":key] should not be null", res ); } }
@Override public boolean shouldRemove() { return maxObjects > 0 && this.size() > maxObjects; }
LRUMap<String, String> map = new LRUMap<String, String>( total ); map.setChunkSize( 1 ); map.put( i + ":key", "data" + i ); assertNull( map.get( i + ":key" ) ); String res = map.get( i + ":key" ); assertNotNull( "[" + i + ":key] should not be null", res );
/** * Just test that we can put, get and remove as expected. * @throws Exception Description of the Exception */ public void testSimpleLoad() throws Exception { LRUMap<String, String> map = new LRUMap<String, String>( items ); for ( int i = 0; i < items; i++ ) { map.put( i + ":key", "data" + i ); } for ( int i = items - 1; i >= 0; i-- ) { String res = map.get( i + ":key" ); assertNotNull( "[" + i + ":key] should not be null", res ); } // test removal map.remove( "300:key" ); assertNull( map.get( "300:key" ) ); }
/** * Put and then remove. Make sure the element is returned. * */ public void testPutAndRemove() { int size = 10; Map<String, String> cache = new LRUMap<String, String>( size ); cache.put( "key:" + 1, "data:" + 1 ); String data = cache.remove( "key:" + 1 ); assertEquals( "Data is wrong.", "data:" + 1, data ); }
LRUMap<String, String> map = new LRUMap<String, String>( total ); map.setChunkSize( 1 ); map.put( i + ":key", "data" + i ); Iterator<?> it = map.entrySet().iterator(); while ( it.hasNext() ) String res = map.get( i + ":key" ); assertNotNull( "[" + i + ":key] should not be null", res ); map.put( ( total ) + ":key", "data" + ( total ) ); assertNull( map.get( ( total - 1 ) + ":key" ) );
/** * Put and then remove. Make sure the element is returned. * */ public void testPutAndRemove() { int size = 10; Map<String, String> cache = new LRUMap<String, String>( size ); cache.put( "key:" + 1, "data:" + 1 ); String data = cache.remove( "key:" + 1 ); assertEquals( "Data is wrong.", "data:" + 1, data ); }