*/
public void testLRURemoval()
throws Exception
{
int total = 10;
LRUMap map = new LRUMap( total );
map.setChunkSize( 1 );
// put the max in
for ( int i = 0; i < total; i++ )
{
map.put( i + ":key", "data" + i );
}
Iterator it = map.entrySet().iterator();
while ( it.hasNext() )
{
System.out.println( it.next() );
}
System.out.println( map.getStatistics() );
// get the max out backwards
for ( int i = total - 1; i >= 0; i-- )
{
String res = (String) map.get( i + ":key" );
if ( res == null )
{
assertNotNull( "[" + i + ":key] should not be null", res );
}
}
System.out.println( map.getStatistics() );
//since we got them backwards the total should be at the end.
// add one confirm that total is gone.
map.put( ( total ) + ":key", "data" + ( total ) );
assertNull( map.get( ( total - 1 ) + ":key" ) );
}