Search in sources :

Example 36 with ClientConfig

use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.

the class InvalidationMetadataDistortionTest method createClientConfig.

protected ClientConfig createClientConfig() {
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setProperty("hazelcast.invalidation.max.tolerated.miss.count", "0");
    return clientConfig;
}
Also used : ClientConfig(com.hazelcast.client.config.ClientConfig)

Example 37 with ClientConfig

use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.

the class ClientCacheThroughHazelcastInstanceTest method createInstance.

@Override
protected HazelcastInstance createInstance(Config config) {
    if (instanceFactory != null) {
        throw new IllegalStateException("There should not be multiple creation of TestHazelcastFactory!");
    }
    instanceFactory = new TestHazelcastFactory();
    ownerInstance = instanceFactory.newHazelcastInstance(config);
    if (config.getClassLoader() != null) {
        final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
        try {
            ClientConfig clientConfig = new ClientConfig();
            clientConfig.setClassLoader(config.getClassLoader());
            Thread.currentThread().setContextClassLoader(config.getClassLoader());
            return instanceFactory.newHazelcastClient(clientConfig);
        } finally {
            Thread.currentThread().setContextClassLoader(tccl);
        }
    } else {
        return instanceFactory.newHazelcastClient();
    }
}
Also used : TestHazelcastFactory(com.hazelcast.client.test.TestHazelcastFactory) ClientConfig(com.hazelcast.client.config.ClientConfig)

Example 38 with ClientConfig

use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.

the class ClientCacheNearCacheBasicTest method createContext.

@Override
protected <K, V> com.hazelcast.internal.nearcache.NearCacheTestContext<K, V, Data, String> createContext() {
    ClientConfig clientConfig = getClientConfig().addNearCacheConfig(nearCacheConfig);
    CacheConfig<K, V> cacheConfig = createCacheConfig(nearCacheConfig);
    HazelcastInstance member = hazelcastFactory.newHazelcastInstance(getConfig());
    HazelcastClientProxy client = (HazelcastClientProxy) hazelcastFactory.newHazelcastClient(clientConfig);
    CachingProvider memberProvider = HazelcastServerCachingProvider.createCachingProvider(member);
    HazelcastServerCacheManager memberCacheManager = (HazelcastServerCacheManager) memberProvider.getCacheManager();
    NearCacheManager nearCacheManager = client.client.getNearCacheManager();
    CachingProvider provider = HazelcastClientCachingProvider.createCachingProvider(client);
    HazelcastClientCacheManager cacheManager = (HazelcastClientCacheManager) provider.getCacheManager();
    String cacheNameWithPrefix = cacheManager.getCacheNameWithPrefix(DEFAULT_NEAR_CACHE_NAME);
    ICache<K, V> clientCache = cacheManager.createCache(DEFAULT_NEAR_CACHE_NAME, cacheConfig);
    ICache<K, V> memberCache = memberCacheManager.createCache(DEFAULT_NEAR_CACHE_NAME, cacheConfig);
    NearCache<Data, String> nearCache = nearCacheManager.getNearCache(cacheNameWithPrefix);
    return new NearCacheTestContext<K, V, Data, String>(client.getSerializationService(), client, member, new ICacheDataStructureAdapter<K, V>(clientCache), new ICacheDataStructureAdapter<K, V>(memberCache), false, nearCache, nearCacheManager, cacheManager, memberCacheManager);
}
Also used : NearCacheManager(com.hazelcast.internal.nearcache.NearCacheManager) HazelcastServerCacheManager(com.hazelcast.cache.impl.HazelcastServerCacheManager) Data(com.hazelcast.nio.serialization.Data) NearCacheTestContext(com.hazelcast.internal.nearcache.NearCacheTestContext) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientConfig(com.hazelcast.client.config.ClientConfig) HazelcastClientProxy(com.hazelcast.client.impl.HazelcastClientProxy) HazelcastServerCachingProvider(com.hazelcast.cache.impl.HazelcastServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider) HazelcastClientCachingProvider(com.hazelcast.client.cache.impl.HazelcastClientCachingProvider) HazelcastClientCacheManager(com.hazelcast.client.cache.impl.HazelcastClientCacheManager)

Example 39 with ClientConfig

use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.

the class ClientCachePutAllTest method onSetup.

@Override
protected void onSetup() {
    super.onSetup();
    ClientConfig clientConfig = createClientConfig();
    client = clientFactory.newHazelcastClient(clientConfig);
}
Also used : ClientConfig(com.hazelcast.client.config.ClientConfig)

Example 40 with ClientConfig

use of com.hazelcast.client.config.ClientConfig in project hazelcast by hazelcast.

the class ClientCachingProviderTest method createHazelcastInstance.

@Override
protected HazelcastInstance createHazelcastInstance(String instanceName) {
    // Since `HazelcastClient.getHazelcastClientByName(instanceName);` doesn't work on mock client,
    // we are using real instances.
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.setInstanceName(instanceName);
    clientConfig.getGroupConfig().setName("test-group1");
    clientConfig.getGroupConfig().setPassword("test-pass1");
    HazelcastInstance instance = HazelcastClient.newHazelcastClient(clientConfig);
    instances.add(instance);
    return instance;
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ClientConfig(com.hazelcast.client.config.ClientConfig)

Aggregations

ClientConfig (com.hazelcast.client.config.ClientConfig)214 Test (org.junit.Test)129 HazelcastInstance (com.hazelcast.core.HazelcastInstance)110 QuickTest (com.hazelcast.test.annotation.QuickTest)107 ParallelTest (com.hazelcast.test.annotation.ParallelTest)81 Config (com.hazelcast.config.Config)45 NearCacheConfig (com.hazelcast.config.NearCacheConfig)32 NightlyTest (com.hazelcast.test.annotation.NightlyTest)32 CountDownLatch (java.util.concurrent.CountDownLatch)25 AssertTask (com.hazelcast.test.AssertTask)20 Before (org.junit.Before)20 HazelcastClientProxy (com.hazelcast.client.impl.HazelcastClientProxy)16 ClientNetworkConfig (com.hazelcast.client.config.ClientNetworkConfig)15 HazelcastClientCachingProvider (com.hazelcast.client.cache.impl.HazelcastClientCachingProvider)13 CachingProvider (javax.cache.spi.CachingProvider)13 IMap (com.hazelcast.core.IMap)12 LifecycleListener (com.hazelcast.core.LifecycleListener)12 LifecycleEvent (com.hazelcast.core.LifecycleEvent)11 Data (com.hazelcast.nio.serialization.Data)11 NearCacheManager (com.hazelcast.internal.nearcache.NearCacheManager)10