@Test
public void testDelete()
    throws IOException,
           InterruptedException,
           DeadlockException,
           TransactionRolledBackException
{

    Database db = new DisklessTestDatabase(FACTORY);
    OrderedMap map = db.createMap(MAP_NAME, RecordFactory.simpleRecordFactory(TestKey.class, TestRecord.class));
    for (int i = 0; i < N; i++) {
        AbstractRecord replaced = map.put(TestRecord.createRecord(i, "first"));
        assertNull(replaced);
    }
    for (int i = 0; i < N; i++) {
        // Delete present key
        {
            AbstractRecord replaced = map.delete(new TestKey(i));
            assertNotNull(replaced);
            assertEquals(i, ((TestKey) replaced.key()).key());
            assertEquals("first", ((TestRecord) replaced).stringValue());
        }
        // Delete missing key (a version of bug #4)
        {
            AbstractRecord replaced = map.delete(new TestKey(-i));
            assertNull(replaced);
        }
    }
    assertNull(map.first().next());
    db.close();
}