Search in sources :

Example 1 with ServiceNotFoundException

use of com.hazelcast.spi.exception.ServiceNotFoundException in project hazelcast by hazelcast.

the class ClientICacheManagerTest method getCache_when_serviceNotFoundExceptionIsThrown_then_illegalStateExceptionIsThrown.

@Test
public void getCache_when_serviceNotFoundExceptionIsThrown_then_illegalStateExceptionIsThrown() {
    // when HazelcastException with ServiceNotFoundException cause was thrown by hzInstance.getDistributedObject
    // (i.e. cache support is not available server-side)
    HazelcastInstance hzInstance = mock(HazelcastInstance.class);
    HazelcastException hzException = new HazelcastException("mock exception", new ServiceNotFoundException("mock exception"));
    when(hzInstance.getDistributedObject(anyString(), anyString())).thenThrow(hzException);
    ClientICacheManager clientCacheManager = new ClientICacheManager(hzInstance);
    // then an IllegalStateException will be thrown by getCache
    thrown.expect(IllegalStateException.class);
    clientCacheManager.getCache("any-cache");
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) HazelcastException(com.hazelcast.core.HazelcastException) ClientServiceNotFoundException(com.hazelcast.client.spi.impl.ClientServiceNotFoundException) ServiceNotFoundException(com.hazelcast.spi.exception.ServiceNotFoundException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

ClientServiceNotFoundException (com.hazelcast.client.spi.impl.ClientServiceNotFoundException)1 HazelcastException (com.hazelcast.core.HazelcastException)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 ServiceNotFoundException (com.hazelcast.spi.exception.ServiceNotFoundException)1 ParallelTest (com.hazelcast.test.annotation.ParallelTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 Test (org.junit.Test)1