size );
}
@Test
public void testChechExistsTrue() {
final ObjectHashMap map = new ObjectHashMap();
final Cheese stilton = new Cheese( "stilton",
5 );
map.put( new Integer( 1 ),
stilton,
true );
Cheese c = (Cheese) map.get( new Integer( 1 ) );
assertSame( stilton,
c );
// we haven't told the map to check if the key exists, so we should end up with two entries.
// the second one is nolonger reacheable
final Cheese cheddar = new Cheese( "cheddar",
5 );
map.put( new Integer( 1 ),
cheddar );
c = (Cheese) map.get( new Integer( 1 ) );
assertSame( cheddar,
c );
Entry entry = map.getBucket( new Integer( 1 ) );
int size = 0;
while ( entry != null ) {
size++;
entry = entry.getNext();
}
assertEquals( 1,
size );
// Check remove works
map.remove( new Integer( 1 ) );
entry = map.getBucket( new Integer( 1 ) );
size = 0;
while ( entry != null ) {
size++;
entry = entry.getNext();
}