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_TwoPhaseIntegrationTest method rollback_whenMultipleItemsAndDurabilityZero_thenNoBackupLog.
@Test
public void rollback_whenMultipleItemsAndDurabilityZero_thenNoBackupLog() {
TransactionOptions options = new TransactionOptions().setTransactionType(TWO_PHASE).setDurability(0);
TransactionImpl tx = new TransactionImpl(localTxService, localNodeEngine, options, txOwner);
tx.begin();
MockTransactionLogRecord record1 = new MockTransactionLogRecord();
tx.add(record1);
MockTransactionLogRecord record2 = new MockTransactionLogRecord();
tx.add(record2);
tx.prepare();
tx.rollback();
assertRolledBack(tx);
assertNoBackupLogOnRemote(tx);
record1.assertPrepareCalled().assertCommitNotCalled().assertRollbackCalled();
record2.assertPrepareCalled().assertCommitNotCalled().assertRollbackCalled();
}
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, UUID.randomUUID());
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, UUID.randomUUID());
tx.begin();
tx.rollback();
tx.commit();
}
Aggregations