Search in sources :

Example 1 with ClientListenerRegistration

use of com.hazelcast.client.impl.spi.impl.listener.ClientListenerRegistration in project hazelcast by hazelcast.

the class ClientQueryCacheDestroyResourcesTest method destroy_deregisters_listeners.

@Test
public void destroy_deregisters_listeners() {
    QueryCache<String, String> queryCache1 = map1.getQueryCache(QUERY_CACHE_NAME_1);
    QueryCache<String, String> queryCache2 = map2.getQueryCache(QUERY_CACHE_NAME_2);
    QueryCache<String, String> queryCache3 = map3.getQueryCache(QUERY_CACHE_NAME_3);
    HazelcastClientInstanceImpl client = getHazelcastClientInstanceImpl(clientInstance);
    ClientListenerServiceImpl listenerService = (ClientListenerServiceImpl) client.getListenerService();
    int numberOfListenersBeforeDestroy = listenerService.getRegistrations().size();
    queryCache1.destroy();
    queryCache2.destroy();
    queryCache3.destroy();
    final Map<UUID, ClientListenerRegistration> registrations = listenerService.getRegistrations();
    // we expect at least 1 for backup listener and 1 listener for ProxyManager and
    // we expect 3 listeners to be deleted one for each queryCache.
    assertEquals(registrations.toString(), 3, numberOfListenersBeforeDestroy - registrations.size());
}
Also used : ClientListenerServiceImpl(com.hazelcast.client.impl.spi.impl.listener.ClientListenerServiceImpl) HazelcastClientInstanceImpl(com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl) UUID(java.util.UUID) ClientListenerRegistration(com.hazelcast.client.impl.spi.impl.listener.ClientListenerRegistration) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

HazelcastClientInstanceImpl (com.hazelcast.client.impl.clientside.HazelcastClientInstanceImpl)1 ClientListenerRegistration (com.hazelcast.client.impl.spi.impl.listener.ClientListenerRegistration)1 ClientListenerServiceImpl (com.hazelcast.client.impl.spi.impl.listener.ClientListenerServiceImpl)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 UUID (java.util.UUID)1 Test (org.junit.Test)1