use of com.hazelcast.transaction.TransactionOptions in project hazelcast by hazelcast.
the class HazelcastOSGiInstanceTest method executeTransactionWithOptionsCalledSuccessfullyOverOSGiInstance.
@Test
public void executeTransactionWithOptionsCalledSuccessfullyOverOSGiInstance() {
Object result = new Object();
TransactionOptions transactionOptions = new TransactionOptions();
TransactionalTask mockTransactionalTask = mock(TransactionalTask.class);
HazelcastInstance mockHazelcastInstance = mock(HazelcastInstance.class);
HazelcastOSGiInstance hazelcastOSGiInstance = HazelcastOSGiTestUtil.createHazelcastOSGiInstance(mockHazelcastInstance);
when(mockHazelcastInstance.executeTransaction(transactionOptions, mockTransactionalTask)).thenReturn(result);
assertEquals(result, hazelcastOSGiInstance.executeTransaction(transactionOptions, mockTransactionalTask));
verify(mockHazelcastInstance).executeTransaction(transactionOptions, mockTransactionalTask);
}
use of com.hazelcast.transaction.TransactionOptions in project hazelcast by hazelcast.
the class HazelcastOSGiInstanceTest method newTransactionContextWithOptionsCalledSuccessfullyOverOSGiInstance.
@Test
public void newTransactionContextWithOptionsCalledSuccessfullyOverOSGiInstance() {
TransactionOptions transactionOptions = new TransactionOptions();
TransactionContext mockTransactionContext = mock(TransactionContext.class);
HazelcastInstance mockHazelcastInstance = mock(HazelcastInstance.class);
HazelcastOSGiInstance hazelcastOSGiInstance = HazelcastOSGiTestUtil.createHazelcastOSGiInstance(mockHazelcastInstance);
when(mockHazelcastInstance.newTransactionContext(transactionOptions)).thenReturn(mockTransactionContext);
assertEquals(mockTransactionContext, hazelcastOSGiInstance.newTransactionContext(transactionOptions));
verify(mockHazelcastInstance).newTransactionContext(transactionOptions);
}
use of com.hazelcast.transaction.TransactionOptions in project hazelcast by hazelcast.
the class TransactionalMapReadWriteQuorumTest method parameters.
@Parameterized.Parameters(name = "Executing: {0}")
public static Collection<Object[]> parameters() {
TransactionOptions onePhaseOption = TransactionOptions.getDefault();
onePhaseOption.setTransactionType(ONE_PHASE);
TransactionOptions twoPhaseOption = TransactionOptions.getDefault();
twoPhaseOption.setTransactionType(TWO_PHASE);
return Arrays.asList(new Object[] { twoPhaseOption }, new Object[] { onePhaseOption });
}
use of com.hazelcast.transaction.TransactionOptions in project hazelcast by hazelcast.
the class AdvancedClusterStateTest method changeClusterState_shouldNotFail_whenNonInitiatorMemberDies_duringCommit.
@Test
public void changeClusterState_shouldNotFail_whenNonInitiatorMemberDies_duringCommit() throws Exception {
final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);
final HazelcastInstance[] instances = factory.newInstances();
final HazelcastInstance hz = instances[2];
TransactionManagerServiceImpl transactionManagerService = spyTransactionManagerService(hz);
final Address address = getAddress(instances[0]);
TransactionOptions options = TransactionOptions.getDefault().setDurability(0);
when(transactionManagerService.newAllowedDuringPassiveStateTransaction(options)).thenAnswer(new TransactionAnswer() {
@Override
protected void afterPrepare() {
terminateInstance(instances[0]);
}
});
hz.getCluster().changeClusterState(ClusterState.FROZEN, options);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertClusterState(ClusterState.FROZEN, instances[2], instances[1]);
}
});
instances[0] = factory.newHazelcastInstance(address);
assertClusterSizeEventually(3, instances[0]);
assertClusterSizeEventually(3, instances[1]);
assertClusterSizeEventually(3, instances[2]);
assertClusterState(ClusterState.FROZEN, instances);
}
use of com.hazelcast.transaction.TransactionOptions in project hazelcast by hazelcast.
the class BasicClusterStateTest method changeClusterState_transaction_mustBe_TWO_PHASE.
@Test(expected = IllegalArgumentException.class)
public void changeClusterState_transaction_mustBe_TWO_PHASE() {
HazelcastInstance hz = createHazelcastInstance();
hz.getCluster().changeClusterState(ClusterState.FROZEN, new TransactionOptions().setTransactionType(TransactionType.LOCAL));
}
Aggregations