use of com.hazelcast.transaction.TransactionOptions in project hazelcast by hazelcast.
the class TransactionImpl_TwoPhaseTest method commit_whenNotPreparedAndMoreThanOneTransactionLogRecord.
@Test(expected = IllegalStateException.class)
public void commit_whenNotPreparedAndMoreThanOneTransactionLogRecord() {
TransactionOptions options = new TransactionOptions().setTransactionType(TWO_PHASE).setDurability(0);
TransactionImpl tx = new TransactionImpl(txManagerService, nodeEngine, options, "dummy-uuid");
tx.begin();
tx.add(new MockTransactionLogRecord());
tx.add(new MockTransactionLogRecord());
tx.commit();
}
use of com.hazelcast.transaction.TransactionOptions in project hazelcast by hazelcast.
the class TransactionImpl_TwoPhaseTest method assertRequiresPrepare.
public void assertRequiresPrepare(int recordCount, boolean expected) throws Exception {
TransactionOptions options = new TransactionOptions().setTransactionType(TWO_PHASE).setDurability(0);
TransactionImpl tx = new TransactionImpl(txManagerService, nodeEngine, options, "dummy-uuid");
tx.begin();
for (int k = 0; k < recordCount; k++) {
tx.add(new MockTransactionLogRecord());
}
boolean result = tx.requiresPrepare();
assertEquals(expected, result);
}
use of com.hazelcast.transaction.TransactionOptions in project hazelcast by hazelcast.
the class TransactionImpl_TwoPhaseTest method rollback.
// =================== commit ==================================================
@Test
public void rollback() {
TransactionOptions options = new TransactionOptions().setTransactionType(TWO_PHASE).setDurability(0);
TransactionImpl tx = new TransactionImpl(txManagerService, nodeEngine, options, "dummy-uuid");
tx.begin();
tx.rollback();
assertEquals(ROLLED_BACK, tx.getState());
}
use of com.hazelcast.transaction.TransactionOptions in project hazelcast by hazelcast.
the class TransactionContextImpl_backupLogsTest method assertBackupLogCreationNotForced.
public void assertBackupLogCreationNotForced(String serviceName) {
TransactionOptions options = new TransactionOptions();
TransactionContextImpl txContext = new TransactionContextImpl(localTxManager, localNodeEngine, options, ownerUuid, false);
txContext.beginTransaction();
TransactionalObject result = txContext.getTransactionalObject(serviceName, "foo");
assertNotNull(result);
assertNull(remoteTxManager.txBackupLogs.get(txContext.getTxnId()));
}
use of com.hazelcast.transaction.TransactionOptions in project hazelcast by hazelcast.
the class TransactionImpl_OnePhaseTest method setup.
@Before
public void setup() {
HazelcastInstance hz = createHazelcastInstance();
operationService = getOperationService(hz);
logger = mock(ILogger.class);
txManagerService = mock(TransactionManagerServiceImpl.class);
txManagerService.commitCount = MwCounter.newMwCounter();
txManagerService.startCount = MwCounter.newMwCounter();
txManagerService.rollbackCount = MwCounter.newMwCounter();
nodeEngine = mock(NodeEngine.class);
when(nodeEngine.getOperationService()).thenReturn(operationService);
when(nodeEngine.getLocalMember()).thenReturn(new MemberImpl());
when(nodeEngine.getLogger(TransactionImpl.class)).thenReturn(logger);
options = new TransactionOptions().setTransactionType(ONE_PHASE);
}
Aggregations