use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.
the class TransactionQueueTest method testRollbackQueue.
@Test
public void testRollbackQueue() throws Throwable {
final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(4);
final HazelcastInstance h1 = factory.newHazelcastInstance();
final TransactionContext transactionContext = h1.newTransactionContext();
transactionContext.beginTransaction();
TransactionalQueue<String> queue = transactionContext.getQueue("testq");
queue.offer("offered-val");
transactionContext.rollbackTransaction();
assertNull(h1.getQueue("testq").poll());
}
use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.
the class TransactionalSetAbstractTest method testSetSizeAfterAdd_withinTxn.
@Test
public void testSetSizeAfterAdd_withinTxn() throws Exception {
TransactionContext context = local.newTransactionContext();
context.beginTransaction();
TransactionalSet<Object> txnSet = context.getSet(setName);
txnSet.add(ELEMENT);
context.commitTransaction();
assertEquals(1, set.size());
}
use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.
the class TransactionalSetAbstractTest method testAddDuplicateElement_withinTxn.
@Test
public void testAddDuplicateElement_withinTxn() throws Exception {
TransactionContext context = local.newTransactionContext();
context.beginTransaction();
TransactionalSet<Object> txnSet = context.getSet(setName);
assertTrue(txnSet.add(ELEMENT));
assertFalse(txnSet.add(ELEMENT));
context.commitTransaction();
assertEquals(1, local.getSet(setName).size());
}
use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.
the class TransactionalSetAbstractTest method testRemove_withinTxn.
@Test
public void testRemove_withinTxn() throws Exception {
set.add(ELEMENT);
TransactionContext context = local.newTransactionContext();
context.beginTransaction();
TransactionalSet<Object> txnSet = context.getSet(setName);
assertTrue(txnSet.remove(ELEMENT));
assertFalse(txnSet.remove("NOT_THERE"));
context.commitTransaction();
assertEquals(0, set.size());
}
use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.
the class TransactionalSetAbstractTest method testAdd_withinTxn.
@Test
public void testAdd_withinTxn() throws Exception {
TransactionContext context = local.newTransactionContext();
context.beginTransaction();
TransactionalSet<Object> txnSet = context.getSet(setName);
assertTrue(txnSet.add(ELEMENT));
assertEquals(1, txnSet.size());
context.commitTransaction();
assertEquals(1, set.size());
}
Aggregations