Search in sources :

Example 1 with ICacheManager

use of com.hazelcast.core.ICacheManager in project hazelcast by hazelcast.

the class CacheThroughHazelcastInstanceTest method getCache_whenOtherHazelcastExceptionIsThrown_thenFail.

@Test
public void getCache_whenOtherHazelcastExceptionIsThrown_thenFail() {
    // when one attempts to getCache but a HazelcastException other than ServiceNotFoundException is thrown
    HazelcastInstanceImpl hzInstanceImpl = mock(HazelcastInstanceImpl.class);
    when(hzInstanceImpl.getDistributedObject(anyString(), anyString())).thenThrow(new HazelcastException("mock hz exception"));
    // then the thrown HazelcastException is rethrown by getCache
    ICacheManager hzCacheManager = new HazelcastInstanceCacheManager(hzInstanceImpl);
    thrown.expect(HazelcastException.class);
    hzCacheManager.getCache("any-cache");
}
Also used : HazelcastInstanceImpl(com.hazelcast.instance.impl.HazelcastInstanceImpl) HazelcastInstanceCacheManager(com.hazelcast.cache.impl.HazelcastInstanceCacheManager) HazelcastException(com.hazelcast.core.HazelcastException) ICacheManager(com.hazelcast.core.ICacheManager) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with ICacheManager

use of com.hazelcast.core.ICacheManager in project hazelcast by hazelcast.

the class HazelcastConnectorTest method before.

@Before
public void before() {
    sourceName = randomString();
    sinkName = randomString();
    streamSourceName = "stream" + sourceName;
    streamSinkName = "stream" + sinkName;
    // workaround for `cache is not created` exception, create cache locally on all nodes
    ICacheManager cacheManager = instances()[1].getCacheManager();
    cacheManager.getCache(sourceName);
    cacheManager.getCache(sinkName);
    cacheManager.getCache(streamSourceName);
    cacheManager.getCache(streamSinkName);
}
Also used : ICacheManager(com.hazelcast.core.ICacheManager) Before(org.junit.Before)

Example 3 with ICacheManager

use of com.hazelcast.core.ICacheManager in project hazelcast by hazelcast.

the class GetCacheEntryRequestTest method testGetCacheEntry.

@Test
public void testGetCacheEntry() throws Exception {
    GetCacheEntryRequest request = new GetCacheEntryRequest("string", "test", "1");
    ICacheManager hazelcastCacheManager = hz.getCacheManager();
    ICache<String, String> cache = hazelcastCacheManager.getCache("test");
    cache.put("1", "one");
    JsonObject jsonObject = new JsonObject();
    request.writeResponse(managementCenterService, jsonObject);
    JsonObject result = (JsonObject) jsonObject.get("result");
    assertEquals("one", result.get("cacheBrowse_value").asString());
}
Also used : JsonObject(com.eclipsesource.json.JsonObject) GetCacheEntryRequest(com.hazelcast.internal.management.request.GetCacheEntryRequest) ICacheManager(com.hazelcast.core.ICacheManager) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 4 with ICacheManager

use of com.hazelcast.core.ICacheManager in project hazelcast by hazelcast.

the class ClientStatisticsTest method createCache.

private static ICache<Integer, Integer> createCache(HazelcastInstance hazelcastInstance, String testCacheName, HazelcastInstance clientInstance) {
    CachingProvider cachingProvider = getCachingProvider(hazelcastInstance);
    CacheManager cacheManager = cachingProvider.getCacheManager();
    cacheManager.createCache(testCacheName, createCacheConfig());
    ICacheManager clientCacheManager = clientInstance.getCacheManager();
    return clientCacheManager.getCache(testCacheName);
}
Also used : ICacheManager(com.hazelcast.core.ICacheManager) CacheManager(javax.cache.CacheManager) ICacheManager(com.hazelcast.core.ICacheManager) CacheTestSupport.createServerCachingProvider(com.hazelcast.cache.CacheTestSupport.createServerCachingProvider) CachingProvider(javax.cache.spi.CachingProvider)

Aggregations

ICacheManager (com.hazelcast.core.ICacheManager)4 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2 JsonObject (com.eclipsesource.json.JsonObject)1 CacheTestSupport.createServerCachingProvider (com.hazelcast.cache.CacheTestSupport.createServerCachingProvider)1 HazelcastInstanceCacheManager (com.hazelcast.cache.impl.HazelcastInstanceCacheManager)1 HazelcastException (com.hazelcast.core.HazelcastException)1 HazelcastInstanceImpl (com.hazelcast.instance.impl.HazelcastInstanceImpl)1 GetCacheEntryRequest (com.hazelcast.internal.management.request.GetCacheEntryRequest)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 ParallelTest (com.hazelcast.test.annotation.ParallelTest)1 CacheManager (javax.cache.CacheManager)1 CachingProvider (javax.cache.spi.CachingProvider)1 Before (org.junit.Before)1