Search in sources :

Example 6 with ISet

use of com.hazelcast.core.ISet in project hazelcast by hazelcast.

the class MBeanTest method testSet.

@Test
public void testSet() throws Exception {
    ISet set = holder.getHz().getSet("set");
    set.size();
    holder.assertMBeanExistEventually("ISet", set.getName());
}
Also used : ISet(com.hazelcast.core.ISet) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 7 with ISet

use of com.hazelcast.core.ISet in project hazelcast by hazelcast.

the class ClientTxnSetTest method testAddRollBack.

@Test
public void testAddRollBack() throws Exception {
    final String setName = randomString();
    final ISet set = client.getSet(setName);
    set.add("item1");
    final TransactionContext context = client.newTransactionContext();
    context.beginTransaction();
    final TransactionalSet<Object> setTxn = context.getSet(setName);
    setTxn.add("item2");
    context.rollbackTransaction();
    assertEquals(1, set.size());
}
Also used : TransactionContext(com.hazelcast.transaction.TransactionContext) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) ISet(com.hazelcast.core.ISet) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 8 with ISet

use of com.hazelcast.core.ISet in project hazelcast by hazelcast.

the class ClientTxnSetTest method testAdd_withinTxn.

@Test
public void testAdd_withinTxn() throws Exception {
    final String element = "item1";
    final String setName = randomString();
    final ISet set = client.getSet(setName);
    final TransactionContext context = client.newTransactionContext();
    context.beginTransaction();
    final TransactionalSet<Object> txnSet = context.getSet(setName);
    assertTrue(txnSet.add(element));
    assertEquals(1, txnSet.size());
    context.commitTransaction();
}
Also used : TransactionContext(com.hazelcast.transaction.TransactionContext) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) ISet(com.hazelcast.core.ISet) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 9 with ISet

use of com.hazelcast.core.ISet in project hazelcast by hazelcast.

the class ClientTxnSetTest method testRemove_withinTxn.

@Test
public void testRemove_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);
    assertTrue(txnSet.remove(element));
    assertFalse(txnSet.remove("NOT_THERE"));
    context.commitTransaction();
}
Also used : TransactionContext(com.hazelcast.transaction.TransactionContext) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) ISet(com.hazelcast.core.ISet) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 10 with ISet

use of com.hazelcast.core.ISet in project hazelcast by hazelcast.

the class ClientTxnSetTest method testSetSizeAfterAdd_withinTxn.

@Test
public void testSetSizeAfterAdd_withinTxn() throws Exception {
    final String element = "item1";
    final String setName = randomString();
    final ISet set = client.getSet(setName);
    final TransactionContext context = client.newTransactionContext();
    context.beginTransaction();
    final TransactionalSet<Object> txnSet = context.getSet(setName);
    txnSet.add(element);
    context.commitTransaction();
    assertEquals(1, set.size());
}
Also used : TransactionContext(com.hazelcast.transaction.TransactionContext) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) ISet(com.hazelcast.core.ISet) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

ISet (com.hazelcast.core.ISet)13 Test (org.junit.Test)13 ParallelTest (com.hazelcast.test.annotation.ParallelTest)11 QuickTest (com.hazelcast.test.annotation.QuickTest)11 TransactionContext (com.hazelcast.transaction.TransactionContext)8 HazelcastTestSupport.randomString (com.hazelcast.test.HazelcastTestSupport.randomString)7 HazelcastInstance (com.hazelcast.core.HazelcastInstance)2 SetService (com.hazelcast.collection.impl.set.SetService)1 TransactionalTask (com.hazelcast.transaction.TransactionalTask)1 TransactionalTaskContext (com.hazelcast.transaction.TransactionalTaskContext)1 ExecutionException (java.util.concurrent.ExecutionException)1