Search in sources :

Example 1 with GenericEvent

use of com.hazelcast.client.map.helpers.GenericEvent in project hazelcast by hazelcast.

the class ClientMapTest method testIssue537.

@Test
@SuppressWarnings("deprecation")
public void testIssue537() throws InterruptedException {
    final CountDownLatch latch = new CountDownLatch(2);
    final CountDownLatch nullLatch = new CountDownLatch(2);
    EntryListener<String, GenericEvent> listener = new EntryAdapter<String, GenericEvent>() {

        @Override
        public void entryAdded(EntryEvent<String, GenericEvent> event) {
            latch.countDown();
        }

        @Override
        public void entryEvicted(EntryEvent<String, GenericEvent> event) {
            GenericEvent value = event.getValue();
            GenericEvent oldValue = event.getOldValue();
            if (value == null) {
                nullLatch.countDown();
            }
            if (oldValue != null) {
                nullLatch.countDown();
            }
            latch.countDown();
        }
    };
    IMap<String, GenericEvent> map = createMap();
    String id = map.addEntryListener(listener, true);
    map.put("key1", new GenericEvent("value1"), 2, TimeUnit.SECONDS);
    assertOpenEventually(latch);
    assertOpenEventually(nullLatch);
    map.removeEntryListener(id);
    map.put("key2", new GenericEvent("value2"));
    assertEquals(1, map.size());
}
Also used : GenericEvent(com.hazelcast.client.map.helpers.GenericEvent) EntryAdapter(com.hazelcast.core.EntryAdapter) EntryEvent(com.hazelcast.core.EntryEvent) CountDownLatch(java.util.concurrent.CountDownLatch) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

GenericEvent (com.hazelcast.client.map.helpers.GenericEvent)1 EntryAdapter (com.hazelcast.core.EntryAdapter)1 EntryEvent (com.hazelcast.core.EntryEvent)1 ParallelTest (com.hazelcast.test.annotation.ParallelTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Test (org.junit.Test)1