use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientServiceTest method testNumberOfClients_afterUnAuthenticatedClient.
@Test(timeout = 120000)
public void testNumberOfClients_afterUnAuthenticatedClient() {
final HazelcastInstance instance = hazelcastFactory.newHazelcastInstance();
final ClientConfig clientConfig = new ClientConfig();
clientConfig.getGroupConfig().setPassword("wrongPassword");
try {
hazelcastFactory.newHazelcastClient(clientConfig);
} catch (IllegalStateException ignored) {
}
assertEquals(0, instance.getClientService().getConnectedClients().size());
}
use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientServiceTest method testConnectedClientsWithReAuth.
@Test(timeout = 120000)
public void testConnectedClientsWithReAuth() throws InterruptedException {
final ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().setConnectionAttemptPeriod(1000 * 5);
clientConfig.getNetworkConfig().setConnectionAttemptLimit(Integer.MAX_VALUE);
final CountDownLatch countDownLatch = new CountDownLatch(2);
clientConfig.addListenerConfig(new ListenerConfig(new LifecycleListener() {
@Override
public void stateChanged(LifecycleEvent event) {
if (event.getState() == LifecycleEvent.LifecycleState.CLIENT_CONNECTED) {
countDownLatch.countDown();
}
}
}));
HazelcastInstance instance = hazelcastFactory.newHazelcastInstance();
final HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
//restart the node
instance.shutdown();
final HazelcastInstance restartedInstance = hazelcastFactory.newHazelcastInstance();
// do any operation
client.getMap(randomMapName()).size();
//wait for clients to reconnect & reAuth
assertOpenEventually(countDownLatch);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(1, restartedInstance.getClientService().getConnectedClients().size());
}
});
}
use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientTimeoutTest method testTimeoutToOutsideNetwork.
@Test(timeout = 20000, expected = IllegalStateException.class)
public void testTimeoutToOutsideNetwork() throws Exception {
ClientConfig clientConfig = new ClientConfig();
clientConfig.getGroupConfig().setName("dev").setPassword("dev-pass");
clientConfig.getNetworkConfig().addAddress("8.8.8.8:5701");
HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
IList<Object> list = client.getList("test");
}
use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientRegressionWithMockNetworkTest method testNearCache_WhenRegisteredNodeIsDead.
@Test
public void testNearCache_WhenRegisteredNodeIsDead() {
final HazelcastInstance instance = hazelcastFactory.newHazelcastInstance();
final ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().setConnectionAttemptLimit(Integer.MAX_VALUE);
final String mapName = randomMapName();
NearCacheConfig nearCacheConfig = new NearCacheConfig();
nearCacheConfig.setName(mapName);
nearCacheConfig.setInvalidateOnChange(true);
clientConfig.addNearCacheConfig(nearCacheConfig);
final HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
final IMap<Object, Object> map = client.getMap(mapName);
map.put("a", "b");
// populate Near Cache
map.get("a");
instance.shutdown();
hazelcastFactory.newHazelcastInstance();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(null, map.get("a"));
}
});
}
use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientRegressionWithMockNetworkTest method testNearCache_shutdownClient.
@Test
public void testNearCache_shutdownClient() {
final ClientConfig clientConfig = new ClientConfig();
NearCacheConfig invalidateConfig = new NearCacheConfig();
final String mapName = randomMapName();
invalidateConfig.setName(mapName);
invalidateConfig.setInvalidateOnChange(true);
clientConfig.addNearCacheConfig(invalidateConfig);
hazelcastFactory.newHazelcastInstance();
final HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
final IMap<Integer, Integer> map = client.getMap(mapName);
map.get(1);
//test should finish without throwing any exception.
client.shutdown();
}
Aggregations