use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.
the class ClientMapUnboundReturnValuesTestSupport method internalRunTxn.
/**
* Calls {@link TransactionalMap} methods once which are expected to throw {@link QueryResultSizeExceededException}.
* <p/>
* This method requires the map to be filled to an amount where the exception is safely triggered.
* <p/>
* This methods fails if any of the called methods does not trigger the exception.
*/
private void internalRunTxn(String mapName) {
TransactionContext transactionContext = instance.newTransactionContext();
try {
transactionContext.beginTransaction();
TransactionalMap<Object, Integer> txnMap = transactionContext.getMap(mapName);
try {
txnMap.values(TruePredicate.INSTANCE);
failExpectedException("TransactionalMap.values(predicate)");
} catch (QueryResultSizeExceededException e) {
checkException(e);
}
try {
txnMap.keySet(TruePredicate.INSTANCE);
failExpectedException("TransactionalMap.keySet(predicate)");
} catch (QueryResultSizeExceededException e) {
checkException(e);
}
try {
txnMap.values();
failExpectedException("TransactionalMap.values()");
} catch (QueryResultSizeExceededException e) {
checkException(e);
}
try {
txnMap.keySet();
failExpectedException("TransactionalMap.keySet()");
} catch (QueryResultSizeExceededException e) {
checkException(e);
}
} finally {
transactionContext.rollbackTransaction();
}
}
use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.
the class ClientTransactionalMapQuorumTest method testTxContainsKeySucceedsWhenQuorumSizeMet.
@Test
public void testTxContainsKeySucceedsWhenQuorumSizeMet() {
TransactionContext transaction = getTransactionFromMajority();
TransactionalMap<Object, Object> map = getMap(transaction);
map.containsKey("foo");
transaction.commitTransaction();
}
use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.
the class ClientTransactionalMapQuorumTest method testTxRemoveThrowsExceptionWhenQuorumSizeNotMet.
@Test
public void testTxRemoveThrowsExceptionWhenQuorumSizeNotMet() {
TransactionContext transaction = getTransactionFromMinority();
TransactionalMap<Object, Object> map = getMap(transaction);
expectedException.expect(QuorumException.class);
map.remove("foo");
}
use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.
the class ClientTransactionalMapQuorumTest method testTxContainsKeyThrowsExceptionWhenQuorumSizeNotMet.
@Test
public void testTxContainsKeyThrowsExceptionWhenQuorumSizeNotMet() {
TransactionContext transaction = getTransactionFromMinority();
TransactionalMap<Object, Object> map = getMap(transaction);
expectedException.expect(QuorumException.class);
map.containsKey("foo");
}
use of com.hazelcast.transaction.TransactionContext in project hazelcast by hazelcast.
the class ClientTransactionalMapQuorumTest method testTxReplaceExpectedValueSucceedsWhenQuorumSizeMet.
@Test
public void testTxReplaceExpectedValueSucceedsWhenQuorumSizeMet() {
TransactionContext transaction = getTransactionFromMajority();
TransactionalMap<Object, Object> map = getMap(transaction);
map.replace("foo", "bar", "baz");
transaction.commitTransaction();
}
Aggregations