use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.
the class ClientTransactionalMapQuorumTest method testTxValuesWithPredicateSucceedsWhenQuorumSizeMet.
@Test
public void testTxValuesWithPredicateSucceedsWhenQuorumSizeMet() {
TransactionContext transaction = getTransactionFromMajority();
TransactionalMap<Object, Object> map = getMap(transaction);
map.values(TruePredicate.INSTANCE);
transaction.commitTransaction();
}
use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.
the class ClientTxnSetTest method testSetSizeAfterAddingDuplicateElement_withinTxn.
@Test
public void testSetSizeAfterAddingDuplicateElement_withinTxn() throws Exception {
final String element = "item1";
final String setName = randomString();
final ISet set = client.getSet(setName);
set.add(element);
final TransactionContext context = client.newTransactionContext();
context.beginTransaction();
final 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 ClientTxnTest method testTxnRollbackOnServerCrash.
@Test
public void testTxnRollbackOnServerCrash() throws Exception {
final String queueName = randomString();
final TransactionContext context = client.newTransactionContext();
CountDownLatch txnRollbackLatch = new CountDownLatch(1);
final CountDownLatch memberRemovedLatch = new CountDownLatch(1);
context.beginTransaction();
final TransactionalQueue queue = context.getQueue(queueName);
queue.offer(randomString());
client.getCluster().addMembershipListener(new MembershipAdapter() {
@Override
public void memberRemoved(MembershipEvent membershipEvent) {
memberRemovedLatch.countDown();
}
});
server.getLifecycleService().terminate();
try {
context.commitTransaction();
fail("commit should throw exception !");
} catch (Exception e) {
context.rollbackTransaction();
txnRollbackLatch.countDown();
}
assertOpenEventually(txnRollbackLatch);
assertOpenEventually(memberRemovedLatch);
final IQueue<Object> q = client.getQueue(queueName);
assertNull(q.poll());
assertEquals(0, q.size());
}
use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.
the class ClientXACompatibilityTest method testGetXAResource_TransactionProxy.
@Test(expected = UnsupportedOperationException.class)
public void testGetXAResource_TransactionProxy() throws Exception {
xaResource.start(xid, TMNOFLAGS);
TransactionContext transactionContext = xaResource.getTransactionContext();
transactionContext.getXaResource();
}
use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.
the class ClientXACompatibilityTest method testPrepare_AlreadyPreparedTransaction.
@Test(expected = TransactionNotActiveException.class)
public void testPrepare_AlreadyPreparedTransaction() throws Exception {
xaResource.start(xid, TMNOFLAGS);
TransactionContext context = xaResource.getTransactionContext();
TransactionalMap<Object, Object> map = context.getMap("map");
map.put("key", "val");
xaResource.end(xid, TMSUCCESS);
xaResource.prepare(xid);
xaResource.prepare(xid);
}
Aggregations