use of com.hazelcast.core.LifecycleListener in project hazelcast by hazelcast.
the class ClientTxnOwnerDisconnectedTest method testNewTransactionContextShouldFail_onDisconnectedState.
@Test(expected = TransactionException.class)
public void testNewTransactionContextShouldFail_onDisconnectedState() {
Hazelcast.newHazelcastInstance();
ClientConfig clientConfig = new ClientConfig();
clientConfig.getConnectionStrategyConfig().getConnectionRetryConfig().setClusterConnectTimeoutMillis(Long.MAX_VALUE);
clientConfig.setProperty(ClientProperty.INVOCATION_TIMEOUT_SECONDS.getName(), "3");
HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);
Hazelcast.newHazelcastInstance();
final CountDownLatch clientDisconnected = new CountDownLatch(1);
client.getLifecycleService().addLifecycleListener(new LifecycleListener() {
@Override
public void stateChanged(LifecycleEvent event) {
clientDisconnected.countDown();
}
});
Hazelcast.shutdownAll();
assertOpenEventually(clientDisconnected);
client.newTransactionContext();
}
Aggregations