use of com.hazelcast.client.spi.impl.listener.ClientEventRegistration in project hazelcast by hazelcast.
the class ListenerLeakTestNonSmartRouting method testQueueListeners.
@Test
public void testQueueListeners() {
Collection<Node> nodes = createNodes();
HazelcastInstance client = newHazelcastClient();
IQueue<Object> queue = client.getQueue(randomString());
String id = queue.addItemListener(mock(ItemListener.class), false);
Collection<ClientEventRegistration> registrations = getClientEventRegistrations(client, id);
assertTrue(queue.removeItemListener(id));
assertNoLeftOver(nodes, client, id, registrations);
}
use of com.hazelcast.client.spi.impl.listener.ClientEventRegistration in project hazelcast by hazelcast.
the class ListenerLeakTestNonSmartRouting method testListListeners.
@Test
public void testListListeners() {
Collection<Node> nodes = createNodes();
HazelcastInstance client = newHazelcastClient();
IList<Object> list = client.getList(randomString());
String id = list.addItemListener(mock(ItemListener.class), false);
Collection<ClientEventRegistration> registrations = getClientEventRegistrations(client, id);
assertTrue(list.removeItemListener(id));
assertNoLeftOver(nodes, client, id, registrations);
}
use of com.hazelcast.client.spi.impl.listener.ClientEventRegistration in project hazelcast by hazelcast.
the class ListenerLeakTestNonSmartRouting method testReplicatedMapListeners.
@Test
public void testReplicatedMapListeners() {
Collection<Node> nodes = createNodes();
HazelcastInstance client = newHazelcastClient();
ReplicatedMap<Object, Object> replicatedMap = client.getReplicatedMap(randomString());
String id = replicatedMap.addEntryListener(mock(EntryListener.class));
Collection<ClientEventRegistration> registrations = getClientEventRegistrations(client, id);
assertTrue(replicatedMap.removeEntryListener(id));
assertNoLeftOver(nodes, client, id, registrations);
}
use of com.hazelcast.client.spi.impl.listener.ClientEventRegistration in project hazelcast by hazelcast.
the class AbstractListenersOnReconnectTest method validateRegistrations.
private void validateRegistrations(final int clusterSize, final String registrationId, final HazelcastClientInstanceImpl clientInstanceImpl) {
final boolean smartRouting = clientInstanceImpl.getClientConfig().getNetworkConfig().isSmartRouting();
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
int size = smartRouting ? clusterSize : 1;
Collection<ClientEventRegistration> registrations = getClientEventRegistrations(client, registrationId);
assertEquals(size, registrations.size());
if (smartRouting) {
Collection<Member> members = clientInstanceImpl.getClientClusterService().getMemberList();
for (ClientEventRegistration registration : registrations) {
Connection registeredSubscriber = registration.getSubscriber();
boolean contains = false;
for (Member member : members) {
contains |= registeredSubscriber.getEndPoint().equals(member.getAddress());
}
assertTrue("Registered member " + registeredSubscriber + " is not in the cluster member list " + members, contains);
}
} else {
ClientEventRegistration registration = registrations.iterator().next();
assertEquals(clientInstanceImpl.getClientClusterService().getOwnerConnectionAddress(), registration.getSubscriber().getEndPoint());
}
}
});
}
Aggregations