use of com.hazelcast.core.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapListenersTest method testListenerOnKeyEntryRemove_WithOneRemove.
@Test
public void testListenerOnKeyEntryRemove_WithOneRemove() throws InterruptedException {
final Object key = "key";
final int maxItems = 98;
final MultiMap mm = client.getMultiMap(randomString());
MyEntryListener listener = new CountDownValueNotNullListener(maxItems, 1);
final String id = mm.addEntryListener(listener, key, true);
for (int i = 0; i < maxItems; i++) {
mm.put(key, i);
}
mm.remove(key);
assertOpenEventually(listener.removeLatch);
}
use of com.hazelcast.core.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapListenersTest method testListenerOnKeyEntryRemoveEvent_whenValueNotIncluded.
@Test
public void testListenerOnKeyEntryRemoveEvent_whenValueNotIncluded() throws InterruptedException {
final Object key = "key";
final int maxItems = 62;
final MultiMap mm = client.getMultiMap(randomString());
MyEntryListener listener = new CountDownValueNullListener(maxItems);
mm.addEntryListener(listener, key, false);
for (int i = 0; i < maxItems; i++) {
mm.put(key, i);
mm.remove(key, i);
}
assertOpenEventually(listener.removeLatch);
}
use of com.hazelcast.core.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapListenersTest method testListenerOnKey_whenOtherKeysAdded.
@Test
public void testListenerOnKey_whenOtherKeysAdded() throws InterruptedException {
final MultiMap mm = client.getMultiMap(randomString());
final List<EntryEvent> events = new ArrayList<EntryEvent>();
mm.addEntryListener(new EntryAdapter() {
@Override
public void entryAdded(EntryEvent event) {
events.add(event);
}
}, "key", true);
mm.put("key2", "value");
mm.put("key", "value");
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertEquals(1, events.size());
assertEquals("key", events.get(0).getKey());
}
});
}
use of com.hazelcast.core.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapListenersTest method testListenerEntryRemoveEvent.
@Test
public void testListenerEntryRemoveEvent() throws InterruptedException {
final int maxKeys = 25;
final int maxItems = 3;
final MultiMap mm = client.getMultiMap(randomString());
MyEntryListener listener = new CountDownValueNotNullListener(maxKeys * maxItems);
mm.addEntryListener(listener, true);
for (int i = 0; i < maxKeys; i++) {
for (int j = 0; j < maxKeys; j++) {
mm.put(i, j);
mm.remove(i);
}
}
assertOpenEventually(listener.removeLatch);
}
use of com.hazelcast.core.MultiMap in project hazelcast by hazelcast.
the class ClientMultiMapListenersTest method testAddLocalEntryListener_whenNull.
@Test(expected = UnsupportedOperationException.class)
public void testAddLocalEntryListener_whenNull() {
final MultiMap mm = client.getMultiMap(randomString());
mm.addLocalEntryListener(null);
}
Aggregations