Search in sources :

Example 26 with TransactionContext

use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.

the class ClientXACompatibilityTest method testManualCommitShouldThrowException.

@Test(expected = UnsupportedOperationException.class)
public void testManualCommitShouldThrowException() throws Exception {
    xaResource.start(xid, TMNOFLAGS);
    TransactionContext transactionContext = xaResource.getTransactionContext();
    transactionContext.commitTransaction();
}
Also used : TransactionContext(com.hazelcast.transaction.TransactionContext) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 27 with TransactionContext

use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.

the class ClientXACompatibilityTest method testCommit_TwoPhase_NonPrepared.

@Test(expected = TransactionException.class)
public void testCommit_TwoPhase_NonPrepared() 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.commit(xid, false);
}
Also used : TransactionContext(com.hazelcast.transaction.TransactionContext) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 28 with TransactionContext

use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.

the class ClientXACompatibilityTest method doSomeWorkWithXa.

private void doSomeWorkWithXa(HazelcastXAResource xaResource) throws Exception {
    xaResource.start(xid, TMNOFLAGS);
    TransactionContext context = xaResource.getTransactionContext();
    TransactionalMap<Object, Object> map = context.getMap("map");
    map.put("key", "value");
    TransactionalQueue<Object> queue = context.getQueue("queue");
    queue.offer("item");
    TransactionalList<Object> list = context.getList("list");
    list.add("item");
    TransactionalSet<Object> set = context.getSet("set");
    set.add("item");
    TransactionalMultiMap<Object, Object> mm = context.getMultiMap("mm");
    mm.put("key", "value");
    xaResource.end(xid, TMSUCCESS);
}
Also used : TransactionContext(com.hazelcast.transaction.TransactionContext)

Example 29 with TransactionContext

use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.

the class ClientXACompatibilityTest method testManualRollbackShouldThrowException.

@Test(expected = UnsupportedOperationException.class)
public void testManualRollbackShouldThrowException() throws Exception {
    xaResource.start(xid, TMNOFLAGS);
    TransactionContext transactionContext = xaResource.getTransactionContext();
    transactionContext.rollbackTransaction();
}
Also used : TransactionContext(com.hazelcast.transaction.TransactionContext) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 30 with TransactionContext

use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.

the class ClientXACompatibilityTest method testManualBeginShouldThrowException.

@Test(expected = UnsupportedOperationException.class)
public void testManualBeginShouldThrowException() throws Exception {
    xaResource.start(xid, TMNOFLAGS);
    TransactionContext transactionContext = xaResource.getTransactionContext();
    transactionContext.beginTransaction();
}
Also used : TransactionContext(com.hazelcast.transaction.TransactionContext) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

TransactionContext (com.hazelcast.transaction.TransactionContext)280 Test (org.junit.Test)209 QuickTest (com.hazelcast.test.annotation.QuickTest)189 ParallelTest (com.hazelcast.test.annotation.ParallelTest)184 HazelcastInstance (com.hazelcast.core.HazelcastInstance)58 HazelcastTestSupport.randomString (com.hazelcast.test.HazelcastTestSupport.randomString)48 TransactionalMap (com.hazelcast.core.TransactionalMap)33 TransactionException (com.hazelcast.transaction.TransactionException)22 IMap (com.hazelcast.core.IMap)21 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)19 Config (com.hazelcast.config.Config)17 NightlyTest (com.hazelcast.test.annotation.NightlyTest)16 CountDownLatch (java.util.concurrent.CountDownLatch)14 XAException (javax.transaction.xa.XAException)14 TransactionalQueue (com.hazelcast.core.TransactionalQueue)13 TransactionalMultiMap (com.hazelcast.core.TransactionalMultiMap)9 HazelcastXAResource (com.hazelcast.transaction.HazelcastXAResource)9 ExecutionException (java.util.concurrent.ExecutionException)9 ISet (com.hazelcast.core.ISet)8 MultiMap (com.hazelcast.core.MultiMap)8