@Test
public void testLRU() {
final LRUCache<String,String> cut = new LRUCache<String, String>( 3 );
final String f = "foo";
final String br = "bar";
cut.put(f, br);
cut.put(br, "baz");
Assert.assertTrue( Arrays.equals( new String[]{ f, br }, cut.getKeys().toArray() ),
"invalid order of items, initially it should be insertion ordered" );
cut.get( f );
Assert.assertTrue( Arrays.equals( new String[]{ br, f }, cut.getKeys().toArray() ),
"invalid order of items, accessing foo should move it to the end" );
cut.get( br );
Assert.assertTrue( Arrays.equals( new String[]{ f, br }, cut.getKeys().toArray() ),
"invalid order of items" );
cut.get( f );
Assert.assertTrue( Arrays.equals( new String[]{ br, f }, cut.getKeys().toArray() ),
"invalid order of items, accessing foo should move it to the end" );
cut.put( "baz", "foo" );
Assert.assertTrue( Arrays.equals( new String[]{ br, f, "baz" }, cut.getKeys().toArray() ),
"invalid order of items, last inserted item should be at last position" );
}