use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientNearCacheConfigTest method testSpecificNearCacheConfig_whenAsteriskInTheMiddle.
@Test
public void testSpecificNearCacheConfig_whenAsteriskInTheMiddle() {
final ClientConfig clientConfig = new ClientConfig();
final NearCacheConfig genericNearCacheConfig = new NearCacheConfig();
genericNearCacheConfig.setName("map*Bar");
clientConfig.addNearCacheConfig(genericNearCacheConfig);
final NearCacheConfig specificNearCacheConfig = new NearCacheConfig();
specificNearCacheConfig.setName("mapStudent*Bar");
clientConfig.addNearCacheConfig(specificNearCacheConfig);
final NearCacheConfig mapFoo = clientConfig.getNearCacheConfig("mapFooBar");
final NearCacheConfig mapStudentFoo = clientConfig.getNearCacheConfig("mapStudentFooBar");
assertEquals(genericNearCacheConfig, mapFoo);
assertEquals(specificNearCacheConfig, mapStudentFoo);
}
use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientNearCacheConfigTest method testSpecificNearCacheConfig_whenAsteriskAtTheBeginning.
@Test
public void testSpecificNearCacheConfig_whenAsteriskAtTheBeginning() {
final ClientConfig clientConfig = new ClientConfig();
final NearCacheConfig genericNearCacheConfig = new NearCacheConfig();
genericNearCacheConfig.setName("*Map");
clientConfig.addNearCacheConfig(genericNearCacheConfig);
final NearCacheConfig specificNearCacheConfig = new NearCacheConfig();
specificNearCacheConfig.setName("*MapStudent");
clientConfig.addNearCacheConfig(specificNearCacheConfig);
final NearCacheConfig mapFoo = clientConfig.getNearCacheConfig("fooMap");
final NearCacheConfig mapStudentFoo = clientConfig.getNearCacheConfig("fooMapStudent");
assertEquals(genericNearCacheConfig, mapFoo);
assertEquals(specificNearCacheConfig, mapStudentFoo);
}
use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientAuthenticationTest method testAuthenticationWithCustomCredentials_when_singleNode.
@Test
public void testAuthenticationWithCustomCredentials_when_singleNode() {
PortableFactory factory = new CustomCredentialsPortableFactory();
// with this config, the server will authenticate any credential of type CustomCredentials
Config config = new Config();
config.getGroupConfig().setName(USERNAME).setPassword(PASSWORD);
config.getSerializationConfig().addPortableFactory(1, factory);
hazelcastFactory.newHazelcastInstance(config);
ClientConfig clientConfig = new ClientConfig();
// make sure there are no credentials sent over the wire
clientConfig.getSecurityConfig().setCredentials(new CustomCredentials());
hazelcastFactory.newHazelcastClient(clientConfig);
}
use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientOwnershipTest method test_ownerShip_afterClusterRestart.
@Test
public void test_ownerShip_afterClusterRestart() {
HazelcastInstance instance = hazelcastFactory.newHazelcastInstance();
ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().setConnectionAttemptLimit(Integer.MAX_VALUE);
final HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
instance.shutdown();
final HazelcastInstance instance2 = hazelcastFactory.newHazelcastInstance();
// wait for client to connect to node
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(1, client.getCluster().getMembers().size());
assertEquals(1, instance2.getCluster().getMembers().size());
}
});
final String instanceUuid = instance2.getLocalEndpoint().getUuid();
final ClientEngineImpl clientEngine2 = getClientEngineImpl(instance2);
final String clientUuid = client.getLocalEndpoint().getUuid();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(instanceUuid, clientEngine2.getOwnerUuid(clientUuid));
}
});
}
use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.
the class ClientReconnectTest method testClientReconnectOnClusterDown.
@Test
public void testClientReconnectOnClusterDown() throws Exception {
final HazelcastInstance h1 = hazelcastFactory.newHazelcastInstance();
ClientConfig clientConfig = new ClientConfig();
clientConfig.getNetworkConfig().setConnectionAttemptLimit(Integer.MAX_VALUE);
final HazelcastInstance client = hazelcastFactory.newHazelcastClient(clientConfig);
final CountDownLatch connectedLatch = new CountDownLatch(2);
client.getLifecycleService().addLifecycleListener(new LifecycleListener() {
@Override
public void stateChanged(LifecycleEvent event) {
connectedLatch.countDown();
}
});
IMap<String, String> m = client.getMap("default");
h1.shutdown();
hazelcastFactory.newHazelcastInstance();
assertOpenEventually(connectedLatch);
assertNull(m.put("test", "test"));
assertEquals("test", m.get("test"));
}
Aggregations