use of com.hazelcast.core.EntryEvent in project hazelcast by hazelcast.
the class BasicMapTest method testMapQueryListener.
@Test
public void testMapQueryListener() {
IMap<Object, Object> map = getInstance().getMap(randomMapName());
final Object[] addedKey = new Object[1];
final Object[] addedValue = new Object[1];
final Object[] updatedKey = new Object[1];
final Object[] oldValue = new Object[1];
final Object[] newValue = new Object[1];
final Object[] removedKey = new Object[1];
final Object[] removedValue = new Object[1];
EntryListener<Object, Object> listener = new EntryAdapter<Object, Object>() {
@Override
public void entryAdded(EntryEvent<Object, Object> event) {
addedKey[0] = event.getKey();
addedValue[0] = event.getValue();
}
@Override
public void entryRemoved(EntryEvent<Object, Object> event) {
removedKey[0] = event.getKey();
removedValue[0] = event.getOldValue();
}
@Override
public void entryUpdated(EntryEvent<Object, Object> event) {
updatedKey[0] = event.getKey();
oldValue[0] = event.getOldValue();
newValue[0] = event.getValue();
}
@Override
public void entryEvicted(EntryEvent<Object, Object> event) {
}
@Override
public void mapEvicted(MapEvent event) {
}
@Override
public void mapCleared(MapEvent event) {
}
};
map.addEntryListener(listener, new StartsWithPredicate("a"), null, true);
map.put("key1", "abc");
map.put("key2", "bcd");
map.put("key2", "axyz");
map.remove("key1");
assertTrueEventually(new AssertTask() {
@Override
public void run() {
assertEquals("key1", addedKey[0]);
assertEquals("abc", addedValue[0]);
assertEquals("key2", updatedKey[0]);
assertEquals("bcd", oldValue[0]);
assertEquals("axyz", newValue[0]);
assertEquals("key1", removedKey[0]);
assertEquals("abc", removedValue[0]);
}
});
}
use of com.hazelcast.core.EntryEvent in project camel by apache.
the class HazelcastReplicatedmapConsumerTest method testEvict.
/*
* mail from talip (hazelcast) on 21.02.2011: MultiMap doesn't support eviction yet. We can and should add this feature.
*/
@Test
@SuppressWarnings("unchecked")
public void testEvict() throws InterruptedException {
MockEndpoint out = getMockEndpoint("mock:evicted");
out.expectedMessageCount(1);
EntryEvent<Object, Object> event = new EntryEvent<Object, Object>("foo", null, EntryEventType.EVICTED.getType(), "4711", "my-foo");
argument.getValue().entryEvicted(event);
assertMockEndpointsSatisfied(30000, TimeUnit.MILLISECONDS);
}
use of com.hazelcast.core.EntryEvent in project camel by apache.
the class HazelcastMapConsumerTest method testUpdate.
@Test
@SuppressWarnings("unchecked")
public void testUpdate() throws InterruptedException {
MockEndpoint out = getMockEndpoint("mock:updated");
out.expectedMessageCount(1);
EntryEvent<Object, Object> event = new EntryEvent<Object, Object>("foo", null, EntryEventType.UPDATED.getType(), "4711", "my-foo");
argument.getValue().entryUpdated(event);
assertMockEndpointsSatisfied(5000, TimeUnit.MILLISECONDS);
this.checkHeaders(out.getExchanges().get(0).getIn().getHeaders(), HazelcastConstants.UPDATED);
}
use of com.hazelcast.core.EntryEvent in project camel by apache.
the class HazelcastMapConsumerTest method testEnict.
@Test
@SuppressWarnings("unchecked")
public void testEnict() throws InterruptedException {
MockEndpoint out = super.getMockEndpoint("mock:evicted");
out.expectedMessageCount(1);
EntryEvent<Object, Object> event = new EntryEvent<Object, Object>("foo", null, EntryEventType.EVICTED.getType(), "4711", "my-foo");
argument.getValue().entryEvicted(event);
assertMockEndpointsSatisfied(30000, TimeUnit.MILLISECONDS);
}
use of com.hazelcast.core.EntryEvent in project wildfly-camel by wildfly-extras.
the class HazelcastMapConsumerIntegrationTest method testEvict.
@Test
@SuppressWarnings("unchecked")
public void testEvict() throws Exception {
CamelContext camelctx = createCamelContext();
camelctx.start();
try {
MockEndpoint mock = camelctx.getEndpoint("mock:evicted", MockEndpoint.class);
mock.expectedMessageCount(1);
EntryEvent<Object, Object> event = new EntryEvent<Object, Object>("foo", null, EntryEventType.EVICTED.getType(), "4711", "my-foo");
argument.getValue().entryEvicted(event);
mock.assertIsSatisfied(3000);
} finally {
camelctx.stop();
}
}
Aggregations