Search in sources :

Example 1 with NodeAnswer

use of com.hazelcast.test.starter.answer.NodeAnswer 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)

Example 2 with NodeAnswer

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

the class HazelcastStarter method getNode.

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