use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class ClientTxnMapTest method testTnxMapIsEmpty.
@Test
public void testTnxMapIsEmpty() throws Exception {
final String mapName = randomString();
IMap map = client.getMap(mapName);
final TransactionContext context = client.newTransactionContext();
context.beginTransaction();
final TransactionalMap txMap = context.getMap(mapName);
assertTrue(txMap.isEmpty());
context.commitTransaction();
}
use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class ClientTxnMapTest method testTxnMapGet_BeforeCommit.
@Test
public void testTxnMapGet_BeforeCommit() throws Exception {
final String mapName = randomString();
final String key = "key";
final String value = "Value";
final IMap map = client.getMap(mapName);
final TransactionContext context = client.newTransactionContext();
context.beginTransaction();
final TransactionalMap<Object, Object> txnMap = context.getMap(mapName);
txnMap.put(key, value);
assertEquals(value, txnMap.get(key));
assertNull(map.get(key));
context.commitTransaction();
}
use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class ClientTxnMapTest method testPutAndRoleBack.
@Test
public void testPutAndRoleBack() throws Exception {
final String mapName = randomString();
final String key = "key";
final String value = "value";
final IMap map = client.getMap(mapName);
final TransactionContext context = client.newTransactionContext();
context.beginTransaction();
final TransactionalMap<Object, Object> mapTxn = context.getMap(mapName);
mapTxn.put(key, value);
context.rollbackTransaction();
assertNull(map.get(key));
}
use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class ClientTxnMapTest method testTnxMapReplaceKeyValue.
@Test
public void testTnxMapReplaceKeyValue() throws Exception {
final String mapName = randomString();
final String key1 = "key1";
final String oldValue1 = "old1";
final String newValue1 = "new1";
final String key2 = "key2";
final String oldValue2 = "old2";
IMap map = client.getMap(mapName);
map.put(key1, oldValue1);
map.put(key2, oldValue2);
final TransactionContext context = client.newTransactionContext();
context.beginTransaction();
final TransactionalMap txMap = context.getMap(mapName);
txMap.replace(key1, oldValue1, newValue1);
txMap.replace(key2, "NOT_OLD_VALUE", "NEW_VALUE_CANT_BE_THIS");
context.commitTransaction();
assertEquals(newValue1, map.get(key1));
assertEquals(oldValue2, map.get(key2));
}
use of com.hazelcast.map.IMap in project hazelcast by hazelcast.
the class ClientTxnMapTest method testTxnMapPut.
@Test
public void testTxnMapPut() throws Exception {
final String mapName = randomString();
final String key = "key";
final String value = "Value";
final IMap map = client.getMap(mapName);
final TransactionContext context = client.newTransactionContext();
context.beginTransaction();
final TransactionalMap<Object, Object> txnMap = context.getMap(mapName);
txnMap.put(key, value);
context.commitTransaction();
assertEquals(value, map.get(key));
}
Aggregations