Search in sources :

Example 6 with HazelcastClientCachingProvider

use of com.hazelcast.client.cache.impl.HazelcastClientCachingProvider in project hazelcast by hazelcast.

the class ClientManagerTest method testMultiClusterMultipleClients.

@Test
public void testMultiClusterMultipleClients() {
    final String cacheName = "test";
    final String key1 = "key1";
    final String valuecm1 = "Value-is-cm1";
    final String valuecm2 = "Value-is-cm2";
    final HazelcastClientCachingProvider cachingProvider = new HazelcastClientCachingProvider();
    final CacheManager cm1 = cachingProvider.getCacheManager(uri1, null);
    final CacheManager cm2 = cachingProvider.getCacheManager(uri2, null);
    final CacheConfig<String, String> cacheConfig = new CacheConfig<String, String>();
    final Cache<String, String> cache1 = cm1.createCache(cacheName, cacheConfig);
    final Cache<String, String> cache2 = cm2.createCache(cacheName, cacheConfig);
    cache1.put(key1, valuecm1);
    cache2.put(key1, valuecm2);
    assertEquals(valuecm1, cache1.get(key1));
    assertEquals(valuecm2, cache2.get(key1));
    cachingProvider.close(uri1, null);
    cachingProvider.close(uri2, null);
    final CacheManager cm11 = cachingProvider.getCacheManager(uri1, null);
    final Cache<String, String> cache11 = cm11.getCache(cacheName);
    assertEquals(valuecm1, cache11.get(key1));
    cm11.close();
}
Also used : HazelcastClientCachingProvider(com.hazelcast.client.cache.impl.HazelcastClientCachingProvider) CacheManager(javax.cache.CacheManager) CacheConfig(com.hazelcast.config.CacheConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

HazelcastClientCachingProvider (com.hazelcast.client.cache.impl.HazelcastClientCachingProvider)6 ClientConfig (com.hazelcast.client.config.ClientConfig)5 CacheManager (javax.cache.CacheManager)5 Test (org.junit.Test)5 HazelcastInstance (com.hazelcast.core.HazelcastInstance)4 CacheCreationTest (com.hazelcast.cache.CacheCreationTest)3 SlowTest (com.hazelcast.test.annotation.SlowTest)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 MutableConfiguration (javax.cache.configuration.MutableConfiguration)3 AssertTask (com.hazelcast.test.AssertTask)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 CacheListenerTest (com.hazelcast.cache.CacheListenerTest)1 HazelcastClientCacheManager (com.hazelcast.client.cache.impl.HazelcastClientCacheManager)1 HazelcastClientProxy (com.hazelcast.client.impl.clientside.HazelcastClientProxy)1 CacheConfig (com.hazelcast.config.CacheConfig)1 NearCacheConfig (com.hazelcast.config.NearCacheConfig)1 HazelcastOverloadException (com.hazelcast.core.HazelcastOverloadException)1 IExecutorService (com.hazelcast.core.IExecutorService)1 OperationTimeoutException (com.hazelcast.core.OperationTimeoutException)1 ExecutorServiceTestSupport (com.hazelcast.executor.ExecutorServiceTestSupport)1