Search in sources :

Example 1 with InstanceOfPredicate

use of com.hazelcast.query.impl.predicates.InstanceOfPredicate in project hazelcast by hazelcast.

the class ReplicatedMapListenerTest method testListenToKeyWithPredicate.

@Test
public void testListenToKeyWithPredicate() throws Exception {
    ReplicatedMap<Object, Object> replicatedMap = createClusterAndGetRandomReplicatedMap();
    final EventCountingListener listener = new EventCountingListener();
    replicatedMap.addEntryListener(listener, new InstanceOfPredicate(Integer.class), 2);
    replicatedMap.put(1, 1);
    replicatedMap.put(2, 2);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertEquals(1, listener.keys.size());
            assertEquals(2, listener.keys.peek());
            assertEquals(1, listener.addCount.get());
        }
    });
}
Also used : InstanceOfPredicate(com.hazelcast.query.impl.predicates.InstanceOfPredicate) AssertTask(com.hazelcast.test.AssertTask) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 2 with InstanceOfPredicate

use of com.hazelcast.query.impl.predicates.InstanceOfPredicate in project hazelcast by hazelcast.

the class ClientMapTest method testSerializationServiceNullClassLoaderProblem.

@Test
public void testSerializationServiceNullClassLoaderProblem() throws Exception {
    IMap<Integer, SampleObjects.PortableEmployee> map = client.getMap("test");
    // If the classloader is null the following call throws NullPointerException
    map.values(new InstanceOfPredicate(SampleObjects.PortableEmployee.class));
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) InstanceOfPredicate(com.hazelcast.query.impl.predicates.InstanceOfPredicate) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

InstanceOfPredicate (com.hazelcast.query.impl.predicates.InstanceOfPredicate)2 ParallelTest (com.hazelcast.test.annotation.ParallelTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 Test (org.junit.Test)2 AssertTask (com.hazelcast.test.AssertTask)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1