use of com.hazelcast.core.Cluster in project neo4j by neo4j.
the class HazelcastClientTest method shouldReturnEmptyTopologyIfUnableToConnectToHazelcast.
@Test
public void shouldReturnEmptyTopologyIfUnableToConnectToHazelcast() throws Throwable {
// given
HazelcastConnector connector = mock(HazelcastConnector.class);
LogProvider logProvider = mock(LogProvider.class);
Log log = mock(Log.class);
when(logProvider.getLog(any(Class.class))).thenReturn(log);
HazelcastInstance hazelcastInstance = mock(HazelcastInstance.class);
when(connector.connectToHazelcast()).thenThrow(new IllegalStateException());
when(hazelcastInstance.getAtomicReference(anyString())).thenReturn(mock(IAtomicReference.class));
when(hazelcastInstance.getSet(anyString())).thenReturn(new HazelcastSet());
OnDemandJobScheduler jobScheduler = new OnDemandJobScheduler();
HazelcastClient client = new HazelcastClient(connector, jobScheduler, logProvider, config(), myself);
com.hazelcast.core.Cluster cluster = mock(Cluster.class);
when(hazelcastInstance.getCluster()).thenReturn(cluster);
Set<Member> members = asSet(makeMember(1), makeMember(2));
when(cluster.getMembers()).thenReturn(members);
// when
client.start();
jobScheduler.runJob();
CoreTopology topology = client.coreServers();
assertEquals(0, topology.members().size());
}
use of com.hazelcast.core.Cluster in project hazelcast-simulator by hazelcast.
the class HazelcastUtilsTest method testGetHazelcastAddress_withClientWorker_oldHazelcastVersion.
@Test
public void testGetHazelcastAddress_withClientWorker_oldHazelcastVersion() {
Cluster cluster = mock(Cluster.class);
when(cluster.getLocalMember()).thenThrow(new UnsupportedOperationException("Client has no local member!"));
hazelcastInstance = mock(HazelcastInstance.class);
when(hazelcastInstance.getLocalEndpoint()).thenThrow(new NoSuchMethodError("expected exception"));
when(hazelcastInstance.getCluster()).thenReturn(cluster);
String address = getHazelcastAddress("javaclient", "172.16.16.1", hazelcastInstance);
assertEquals("client:172.16.16.1", address);
}
Aggregations