Search in sources :

Example 1 with HazelcastInstanceCacheManager

use of com.hazelcast.cache.impl.HazelcastInstanceCacheManager 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)

Aggregations

HazelcastInstanceCacheManager (com.hazelcast.cache.impl.HazelcastInstanceCacheManager)1 HazelcastException (com.hazelcast.core.HazelcastException)1 ICacheManager (com.hazelcast.core.ICacheManager)1 HazelcastInstanceImpl (com.hazelcast.instance.impl.HazelcastInstanceImpl)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 Test (org.junit.Test)1