use of com.hazelcast.transaction.TransactionOptions in project hazelcast by hazelcast.
the class TransactionImpl_TwoPhaseIntegrationTest method commit_whenPrepareSkippedButCommitRunsIntoConflict.
@Test
public void commit_whenPrepareSkippedButCommitRunsIntoConflict() {
TransactionOptions options = new TransactionOptions().setTransactionType(TWO_PHASE).setDurability(1);
TransactionImpl tx = new TransactionImpl(localTxService, localNodeEngine, options, txOwner);
tx.begin();
MockTransactionLogRecord record = new MockTransactionLogRecord().failCommit();
tx.add(record);
try {
tx.commit();
fail();
} catch (TransactionException expected) {
}
assertCommitFailed(tx);
assertNoBackupLogOnRemote(tx);
record.assertPrepareNotCalled().assertCommitCalled().assertRollbackNotCalled();
}
use of com.hazelcast.transaction.TransactionOptions in project hazelcast by hazelcast.
the class TransactionImpl_TwoPhaseIntegrationTest method commit_whenSingleItemAndDurabilityOne_thenNoBackupLog.
// =================== commit ===========================================
@Test
public void commit_whenSingleItemAndDurabilityOne_thenNoBackupLog() {
TransactionOptions options = new TransactionOptions().setTransactionType(TWO_PHASE).setDurability(1);
TransactionImpl tx = new TransactionImpl(localTxService, localNodeEngine, options, txOwner);
tx.begin();
MockTransactionLogRecord record = new MockTransactionLogRecord();
tx.add(record);
tx.prepare();
tx.commit();
assertCommitted(tx);
assertNoBackupLogOnRemote(tx);
record.assertPrepareCalled().assertCommitCalled().assertRollbackNotCalled();
}
use of com.hazelcast.transaction.TransactionOptions in project hazelcast by hazelcast.
the class TransactionImpl_TwoPhaseTest method commit_whenThrowsExceptionDuringCommit.
@Test
public void commit_whenThrowsExceptionDuringCommit() throws Exception {
TransactionOptions options = new TransactionOptions().setTransactionType(TWO_PHASE).setDurability(0);
TransactionImpl tx = new TransactionImpl(txManagerService, nodeEngine, options, "dummy-uuid");
tx.begin();
tx.add(new MockTransactionLogRecord().failCommit());
tx.prepare();
try {
tx.commit();
fail();
} catch (TransactionException expected) {
}
assertEquals(COMMIT_FAILED, tx.getState());
}
use of com.hazelcast.transaction.TransactionOptions in project hazelcast by hazelcast.
the class TransactionImpl_TwoPhaseTest method rollback_whenFailureDuringRollback.
@Test
public void rollback_whenFailureDuringRollback() {
TransactionOptions options = new TransactionOptions().setTransactionType(TWO_PHASE).setDurability(0);
TransactionImpl tx = new TransactionImpl(txManagerService, nodeEngine, options, "dummy-uuid");
tx.begin();
tx.add(new MockTransactionLogRecord().failRollback());
tx.rollback();
}
use of com.hazelcast.transaction.TransactionOptions in project hazelcast by hazelcast.
the class TransactionImpl_TwoPhaseTest method commit_whenNotActive.
// =================== commit ==================================================
@Test(expected = IllegalStateException.class)
public void commit_whenNotActive() {
TransactionOptions options = new TransactionOptions().setTransactionType(TWO_PHASE).setDurability(0);
TransactionImpl tx = new TransactionImpl(txManagerService, nodeEngine, options, "dummy-uuid");
tx.begin();
tx.rollback();
tx.commit();
}
Aggregations