use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.
the class MultiMapTestsFrom2X method testMultiMapPutRemoveWithTxn.
@Test
public void testMultiMapPutRemoveWithTxn() {
final HazelcastInstance instance = createHazelcastInstance();
MultiMap<String, String> multiMap = instance.getMultiMap("testMultiMapPutRemoveWithTxn");
multiMap.put("1", "C");
multiMap.put("2", "x");
multiMap.put("2", "y");
final TransactionContext context = instance.newTransactionContext();
context.beginTransaction();
TransactionalMultiMap<String, String> txnMap = context.getMultiMap("testMultiMapPutRemoveWithTxn");
txnMap.put("1", "A");
txnMap.put("1", "B");
Collection g1 = txnMap.get("1");
assertContains(g1, "A");
assertContains(g1, "B");
assertContains(g1, "C");
assertTrue(txnMap.remove("1", "C"));
assertEquals(4, txnMap.size());
Collection g2 = txnMap.get("1");
assertContains(g2, "A");
assertContains(g2, "B");
assertFalse(g2.contains("C"));
Collection r1 = txnMap.remove("2");
assertContains(r1, "x");
assertContains(r1, "y");
assertEquals(0, txnMap.get("2").size());
Collection r2 = txnMap.remove("1");
assertEquals(2, r2.size());
assertContains(r2, "A");
assertContains(r2, "B");
assertEquals(0, txnMap.get("1").size());
assertEquals(0, txnMap.size());
assertEquals(3, multiMap.size());
context.commitTransaction();
assertEquals(0, multiMap.size());
}
use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.
the class TransactionalMapWriteQuorumTest method testTxDeleteThrowsExceptionWhenQuorumSizeNotMet.
@Test(expected = TransactionException.class)
public void testTxDeleteThrowsExceptionWhenQuorumSizeNotMet() {
TransactionContext transactionContext = cluster.h4.newTransactionContext(options);
transactionContext.beginTransaction();
TransactionalMap<Object, Object> map = transactionContext.getMap(randomMapName(MAP_NAME_PREFIX));
map.delete("foo");
transactionContext.commitTransaction();
}
use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.
the class TransactionalMapWriteQuorumTest method testTxGetForUpdateThrowsExceptionWhenQuorumSizeNotMet.
@Test(expected = TransactionException.class)
public void testTxGetForUpdateThrowsExceptionWhenQuorumSizeNotMet() {
TransactionContext transactionContext = cluster.h4.newTransactionContext(options);
transactionContext.beginTransaction();
TransactionalMap<Object, Object> map = transactionContext.getMap(randomMapName(MAP_NAME_PREFIX));
map.getForUpdate("foo");
transactionContext.commitTransaction();
}
use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.
the class TransactionalQueueQuorumTest method testTxTakeThrowsExceptionWhenQuorumSizeNotMet.
@Test(expected = TransactionException.class)
public void testTxTakeThrowsExceptionWhenQuorumSizeNotMet() throws Exception {
TransactionContext transactionContext = cluster.h4.newTransactionContext(options);
transactionContext.beginTransaction();
TransactionalQueue<Object> q = transactionContext.getQueue(QUEUE_NAME);
q.take();
transactionContext.commitTransaction();
}
use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.
the class TransactionalMapReadWriteQuorumTest method testTxValuesThrowsExceptionWhenQuorumSizeNotMet.
@Test(expected = TransactionException.class)
public void testTxValuesThrowsExceptionWhenQuorumSizeNotMet() {
TransactionContext transactionContext = cluster.h4.newTransactionContext(options);
transactionContext.beginTransaction();
TransactionalMap<Object, Object> map = transactionContext.getMap(randomMapName(MAP_NAME_PREFIX));
map.values();
transactionContext.commitTransaction();
}
Aggregations