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");
}
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);
}
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());
}
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);
}
Aggregations