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