@Test
public void testTwoDeadlocks() throws Exception
{

    TestKey k0 = key(0);
    TestKey k1 = key(1);
    TestKey k2 = key(2);
    TestKey k3 = key(3);
    a.lock(k0);
    b.lock(k1);
    a.lock(k1);
    b.lock(k0);
    c.lock(k2);
    d.lock(k3);
    c.lock(k3);
    d.lock(k2);
    DeadlockDetector deadlockDetector = new DeadlockDetector(lockManager);
    Set<Transaction> victims = deadlockDetector.victims();
    int count = 0;
    for (Transaction victim : victims) {
        if (victim == latestStart(a, b).transaction() || victim == latestStart(c, d).transaction()) {
            count++;
        } else {
            fail();
        }
    }
    assertEquals(2, count);
}