use of com.hazelcast.core.ISet in project hazelcast by hazelcast.
the class ClientTxnSetTest method testAddExistingElement_withinTxn.
@Test
public void testAddExistingElement_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);
assertFalse(txnSet.add(element));
context.commitTransaction();
assertEquals(1, set.size());
}
use of com.hazelcast.core.ISet in project hazelcast by hazelcast.
the class TransactionalSetAbstractTest method testSingleSetAtomicity.
@Test
public void testSingleSetAtomicity() throws ExecutionException, InterruptedException {
final int itemCount = 200;
Future<Integer> f = spawn(new Callable<Integer>() {
@Override
public Integer call() throws Exception {
ISet<Object> set = local.getSet(setName);
while (!set.remove("item-1")) {
}
return set.size();
}
});
TransactionContext context = local.newTransactionContext();
context.beginTransaction();
TransactionalSet<Object> set = context.getSet(setName);
for (int i = 0; i < itemCount; i++) {
set.add("item-" + i);
}
context.commitTransaction();
int size = f.get();
assertEquals(itemCount - 1, size);
}
use of com.hazelcast.core.ISet in project hazelcast by hazelcast.
the class MBeanDestroyTest method testSet.
@Test
public void testSet() throws Exception {
ISet set = holder.getHz().getSet("set");
set.size();
holder.assertMBeanExistEventually("ISet", set.getName());
destroyObjectAndAssert(set, "ISet");
}
Aggregations