public void testSecondTxCannotPrepare() throws Exception {
tm(0).begin();
cache(0).put("k0", "v");
DummyTransaction dtm = (DummyTransaction) tm(0).getTransaction();
dtm.runPrepare();
tm(0).suspend();
assert checkTxCount(0, 1, 0);
assert checkTxCount(1, 0, 1);
assert checkTxCount(2, 0, 1);
tm(0).begin();
cache(0).put("k0", "other");
try {
tm(0).commit();
assert false;
} catch (Throwable e) {
//ignore
}
eventually(new Condition() {
@Override
public boolean isSatisfied() throws Exception {
return checkTxCount(0, 1, 0) && checkTxCount(1, 0, 1) && checkTxCount(2, 0, 1);
}
});
tm(1).begin();
cache(1).put("k0", "other");
try {
tm(1).commit();
assert false;
} catch (Throwable e) {
//expected
}
eventually(new Condition() {
@Override
public boolean isSatisfied() throws Exception {
return checkTxCount(0, 1, 0) && checkTxCount(1, 0, 1) && checkTxCount(2, 0, 1);
}
});
tm(0).resume(dtm);
dtm.runCommitTx();
tm(0).suspend();
assertValue("k0", false);
eventually(new Condition() {