Search in sources :

Example 1 with MapListenerAdapter

use of com.hazelcast.map.impl.MapListenerAdapter in project hazelcast by hazelcast.

the class MapPreconditionsTest method testAddEntryListenerWithMapListenerAndPredicate_NullPredicate.

@Test(expected = NullPointerException.class)
public void testAddEntryListenerWithMapListenerAndPredicate_NullPredicate() throws Exception {
    MapListener mapListener = new MapListenerAdapter() {

        public void onEntryEvent(EntryEvent event) {
            System.out.println("-");
        }
    };
    Predicate predicate = null;
    map.addEntryListener(mapListener, predicate, true);
}
Also used : MapListener(com.hazelcast.map.listener.MapListener) MapListenerAdapter(com.hazelcast.map.impl.MapListenerAdapter) EntryEvent(com.hazelcast.core.EntryEvent) Predicate(com.hazelcast.query.Predicate) TruePredicate(com.hazelcast.query.TruePredicate) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 2 with MapListenerAdapter

use of com.hazelcast.map.impl.MapListenerAdapter in project hazelcast by hazelcast.

the class MapListenerAdapterTest method testMapListenerAdapter_whenEntryExpired.

@Test
public void testMapListenerAdapter_whenEntryExpired() {
    String mapName = randomMapName();
    Config cfg = new Config();
    TestHazelcastInstanceFactory instanceFactory = createHazelcastInstanceFactory(1);
    HazelcastInstance instance = instanceFactory.newHazelcastInstance(cfg);
    IMap map = instance.getMap(mapName);
    final CountDownLatch expirationLatch = new CountDownLatch(1);
    map.addEntryListener(new MapListenerAdapter() {

        public void onEntryEvent(EntryEvent event) {
            expirationLatch.countDown();
        }
    }, false);
    map.put(1, 1, 100, TimeUnit.MILLISECONDS);
    sleepSeconds(1);
    // trigger immediate expiration.
    map.get(1);
    assertOpenEventually(expirationLatch);
}
Also used : Config(com.hazelcast.config.Config) MapListenerAdapter(com.hazelcast.map.impl.MapListenerAdapter) CountDownLatch(java.util.concurrent.CountDownLatch) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 3 with MapListenerAdapter

use of com.hazelcast.map.impl.MapListenerAdapter in project hazelcast by hazelcast.

the class MapPreconditionsTest method testAddEntryListenerWithMapListenerAndPredicateAndKey_NullPredicate.

@Test(expected = NullPointerException.class)
public void testAddEntryListenerWithMapListenerAndPredicateAndKey_NullPredicate() {
    MapListener mapListener = new MapListenerAdapter() {

        public void onEntryEvent(EntryEvent event) {
            System.out.println("-");
        }
    };
    Predicate predicate = null;
    map.addEntryListener(mapListener, predicate, null, true);
}
Also used : MapListener(com.hazelcast.map.listener.MapListener) MapListenerAdapter(com.hazelcast.map.impl.MapListenerAdapter) EntryEvent(com.hazelcast.core.EntryEvent) TruePredicate(com.hazelcast.query.TruePredicate) Predicate(com.hazelcast.query.Predicate) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 4 with MapListenerAdapter

use of com.hazelcast.map.impl.MapListenerAdapter in project hazelcast by hazelcast.

the class MapPreconditionsTest method testAddLocalEntryListenerWithMapListenerAndPredicate_NullPredicate.

@Test(expected = NullPointerException.class)
public void testAddLocalEntryListenerWithMapListenerAndPredicate_NullPredicate() {
    MapListener mapListener = new MapListenerAdapter() {

        public void onEntryEvent(EntryEvent event) {
            System.out.println("-");
        }
    };
    Predicate predicate = null;
    map.addLocalEntryListener(mapListener, predicate, true);
}
Also used : MapListener(com.hazelcast.map.listener.MapListener) MapListenerAdapter(com.hazelcast.map.impl.MapListenerAdapter) EntryEvent(com.hazelcast.core.EntryEvent) TruePredicate(com.hazelcast.query.TruePredicate) Predicate(com.hazelcast.query.Predicate) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 5 with MapListenerAdapter

use of com.hazelcast.map.impl.MapListenerAdapter in project hazelcast by hazelcast.

the class MapPreconditionsTest method testAddEntryListenerWithMapListenerAndPredicate_NullPredicate.

@Test(expected = NullPointerException.class)
public void testAddEntryListenerWithMapListenerAndPredicate_NullPredicate() {
    MapListener mapListener = new MapListenerAdapter() {

        public void onEntryEvent(EntryEvent event) {
            System.out.println("-");
        }
    };
    Predicate predicate = null;
    map.addEntryListener(mapListener, predicate, true);
}
Also used : MapListener(com.hazelcast.map.listener.MapListener) MapListenerAdapter(com.hazelcast.map.impl.MapListenerAdapter) EntryEvent(com.hazelcast.core.EntryEvent) TruePredicate(com.hazelcast.query.TruePredicate) Predicate(com.hazelcast.query.Predicate) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

MapListenerAdapter (com.hazelcast.map.impl.MapListenerAdapter)11 ParallelTest (com.hazelcast.test.annotation.ParallelTest)11 QuickTest (com.hazelcast.test.annotation.QuickTest)11 Test (org.junit.Test)11 EntryEvent (com.hazelcast.core.EntryEvent)10 MapListener (com.hazelcast.map.listener.MapListener)10 Predicate (com.hazelcast.query.Predicate)8 TruePredicate (com.hazelcast.query.TruePredicate)8 Config (com.hazelcast.config.Config)1 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)1 CountDownLatch (java.util.concurrent.CountDownLatch)1