Search in sources :

Example 1 with HazelcastInstanceImplAnswer

use of com.hazelcast.test.starter.answer.HazelcastInstanceImplAnswer in project hazelcast by hazelcast.

the class HazelcastStarter method getHazelcastInstanceImpl.

public static HazelcastInstanceImpl getHazelcastInstanceImpl(HazelcastInstance hz) {
    try {
        HazelcastAPIDelegatingClassloader classloader = getHazelcastAPIDelegatingClassloader(hz);
        Object instance = getHazelcastInstanceImpl(hz, classloader);
        Object node = getFieldValueReflectively(instance, "node");
        HazelcastInstanceImpl proxy = mock(HazelcastInstanceImpl.class, new HazelcastInstanceImplAnswer(instance));
        setFieldValueReflectively(proxy, "node", mock(Node.class, new NodeAnswer(node)));
        return proxy;
    } catch (HazelcastInstanceNotActiveException e) {
        throw new IllegalArgumentException("The given HazelcastInstance is not an active HazelcastInstanceImpl: " + hz.getClass());
    } catch (Exception e) {
        throw rethrowGuardianException(e);
    }
}
Also used : HazelcastInstanceImpl(com.hazelcast.instance.impl.HazelcastInstanceImpl) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) NodeAnswer(com.hazelcast.test.starter.answer.NodeAnswer) HazelcastInstanceImplAnswer(com.hazelcast.test.starter.answer.HazelcastInstanceImplAnswer) Node(com.hazelcast.instance.impl.Node) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) HazelcastStarterUtils.rethrowGuardianException(com.hazelcast.test.starter.HazelcastStarterUtils.rethrowGuardianException) MalformedURLException(java.net.MalformedURLException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)1 HazelcastInstanceImpl (com.hazelcast.instance.impl.HazelcastInstanceImpl)1 Node (com.hazelcast.instance.impl.Node)1 HazelcastStarterUtils.rethrowGuardianException (com.hazelcast.test.starter.HazelcastStarterUtils.rethrowGuardianException)1 HazelcastInstanceImplAnswer (com.hazelcast.test.starter.answer.HazelcastInstanceImplAnswer)1 NodeAnswer (com.hazelcast.test.starter.answer.NodeAnswer)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 MalformedURLException (java.net.MalformedURLException)1