### Question:
LruCache implements Cache<K,E> { public synchronized void resize( int newMaxSize ) { if ( newMaxSize < 1 ) { throw new IllegalArgumentException( "newMaxSize=" + newMaxSize ); } resizeInternal( newMaxSize ); } LruCache( String name, int maxSize, AdaptiveCacheManager cacheManager ); String getName(); synchronized void put( K key, E element ); synchronized E remove( K key ); synchronized E get( K key ); synchronized void clear(); synchronized int size(); int maxSize(); synchronized void resize( int newMaxSize ); void elementCleaned( E element ); boolean isAdaptive(); void setAdaptiveStatus( boolean status ); void putAll( Map<K, E> map );  }### Answer:
@Test public void testResize() { LruCacheTest<Object,Object> cache = new LruCacheTest<Object,Object>( "TestCache", 3 ); String s1 = new String( "1" ); Integer key1 = new Integer( 1 ); String s2 = new String( "2" ); Integer key2 = new Integer( 2 ); String s3 = new String( "3" ); Integer key3 = new Integer( 3 ); String s4 = new String( "4" ); Integer key4 = new Integer( 4 ); String s5 = new String( "5" ); Integer key5 = new Integer( 5 ); cache.put( key1, s1 ); cache.put( key2, s2 ); cache.put( key3, s3 ); cache.get( key2 ); assertEquals( null, cache.getLastCleanedElement() ); assertEquals( cache.maxSize(), cache.size() ); cache.resize( 5 ); assertEquals( 5, cache.maxSize() ); assertEquals( 3, cache.size() ); cache.put( key4, s4 ); assertEquals( null, cache.getLastCleanedElement() ); cache.put( key5, s5 ); assertEquals( null, cache.getLastCleanedElement() ); assertEquals( cache.maxSize(), cache.size() ); cache.resize( 4 ); assertEquals( s1, cache.getLastCleanedElement() ); assertEquals( cache.maxSize(), cache.size() ); cache.resize( 3 ); assertEquals( s3, cache.getLastCleanedElement() ); assertEquals( 3, cache.maxSize() ); assertEquals( 3, cache.size() ); }