}
public void testHashStore() throws Exception {
for (int x=0; x<HS_INSERTS; x++) {
VeryLongIntegerKey key = new VeryLongIntegerKey(x,x);
VeryLongInteger hash = new VeryLongInteger(x*x, x*x);
_hs.put(key, hash);
}
_hs.close();
assertEquals("File length doesn't correspond to HashStore size", _index.length(), HS_SIZE*40);
_hs = new HashStore(_index, HS_SIZE);
VeryLongInteger v = _hs.getHash(new VeryLongIntegerKey(2,2));
assertEquals("Retrieved VLI was not as expected", v, new VeryLongInteger(4,4));
// This shouldn't be in there any more as it should have been displayed
v = _hs.getHash(new VeryLongIntegerKey(0,0));
assertNull("Object should have been deleted, but wasn't", v);
_hs.put(new VeryLongIntegerKey(20, 20), new VeryLongInteger(400, 400));
v = _hs.getHash(new VeryLongIntegerKey(3,3));
assertNull("Object should have been deleted, but wasn't", v);
v = _hs.getHash(new VeryLongIntegerKey(2,2));
assertNotNull("Object should have been retained, but wasn't", v);
assertEquals("Retrieved VLI was not as expected", v, new VeryLongInteger(4,4));
_hs.close();
_hs = new HashStore(_index, HS_SIZE);
v = _hs.getHash(new VeryLongIntegerKey(4,4));
assertNotNull("Failed to retrieve hash", v);
assertEquals("Retrieved VLI is not as expected", v, new VeryLongInteger(16, 16));
v = _hs.getHash(new VeryLongIntegerKey(3,3));
assertNull(v);
_hs.delete(new VeryLongIntegerKey(4,4));
assertNull(_hs.getHash(new VeryLongIntegerKey(4,4)));
_hs.close();
_hs = new HashStore(_index, HS_SIZE);
assertNull(_hs.getHash(new VeryLongIntegerKey(4,4)));
v = _hs.getHash(new VeryLongIntegerKey(2,2));
assertNotNull("Object should have been retained, but wasn't", v);
assertEquals("Retrieved VLI was not as expected", v, new VeryLongInteger(4,4));
}