Search in sources :

Example 96 with TransactionContext

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());
}
Also used : TransactionContext(com.hazelcast.transaction.TransactionContext) Test(org.junit.Test)

Example 97 with TransactionContext

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());
}
Also used : TransactionContext(com.hazelcast.transaction.TransactionContext) Test(org.junit.Test)

Example 98 with TransactionContext

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());
}
Also used : TransactionContext(com.hazelcast.transaction.TransactionContext) Test(org.junit.Test)

Example 99 with TransactionContext

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());
}
Also used : TransactionContext(com.hazelcast.transaction.TransactionContext) Test(org.junit.Test)

Example 100 with TransactionContext

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

the class TransactionalSetAbstractTest method testSetSizeAfterRemove_withinTxn.

@Test
public void testSetSizeAfterRemove_withinTxn() throws Exception {
    set.add(ELEMENT);
    TransactionContext context = local.newTransactionContext();
    context.beginTransaction();
    TransactionalSet<Object> txnSet = context.getSet(setName);
    txnSet.remove(ELEMENT);
    context.commitTransaction();
    assertEquals(0, set.size());
}
Also used : TransactionContext(com.hazelcast.transaction.TransactionContext) Test(org.junit.Test)

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