use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.
the class ConnectedClientOperationTest method testGetConnectedClientsOperation_WhenMoreThanZeroClientConnects.
@Test
public void testGetConnectedClientsOperation_WhenMoreThanZeroClientConnects() throws Exception {
HazelcastInstance instance = factory.newHazelcastInstance();
factory.newHazelcastClient();
factory.newHazelcastClient();
Node node = TestUtil.getNode(instance);
Operation operation = new GetConnectedClientsOperation();
OperationService operationService = node.nodeEngine.getOperationService();
Future<Map<String, ClientType>> future = operationService.invokeOnTarget(ClientEngineImpl.SERVICE_NAME, operation, node.address);
Map<String, ClientType> clients = future.get();
assertEquals(2, clients.size());
}
use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.
the class MembershipListenerTest method whenMemberAdded_thenMemberAddedEvent.
@Test
public void whenMemberAdded_thenMemberAddedEvent() throws Exception {
final HazelcastInstance server1 = hazelcastFactory.newHazelcastInstance();
final MemberShipEventLogger listener = new MemberShipEventLogger();
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
client.getCluster().addMembershipListener(listener);
//start a second server and verify that the listener receives it.
final HazelcastInstance server2 = hazelcastFactory.newHazelcastInstance();
//verify that the listener receives member added event.
assertTrueEventually(new AssertTask() {
@Override
public void run() {
assertNotEquals("Expecting one or more events", 0, listener.events.size());
MembershipEvent event = (MembershipEvent) listener.events.getLast();
assertEquals("Last event should be member added", MembershipEvent.MEMBER_ADDED, event.getEventType());
assertEquals(server2.getCluster().getLocalMember(), event.getMember());
assertEquals(getMembers(server1, server2), event.getMembers());
}
});
}
use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.
the class MembershipListenerTest method removedNullListener_thenException.
@Test(expected = NullPointerException.class)
public void removedNullListener_thenException() throws Exception {
hazelcastFactory.newHazelcastInstance();
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
assertFalse(client.getCluster().removeMembershipListener(null));
}
use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.
the class MembershipListenerTest method removedPhantomListener_thenFalse.
@Test
public void removedPhantomListener_thenFalse() throws Exception {
hazelcastFactory.newHazelcastInstance();
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
assertFalse(client.getCluster().removeMembershipListener(randomString()));
}
use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.
the class MembershipListenerTest method addNullListener_thenException.
@Test(expected = java.lang.NullPointerException.class)
public void addNullListener_thenException() throws Exception {
hazelcastFactory.newHazelcastInstance();
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
client.getCluster().addMembershipListener(null);
}
Aggregations