@Test public void putAllMany() { HazelcastClient hClient = getHazelcastClient(); IMap map = hClient.getMap("putAllMany"); int counter = 100; for (int j = 0; j < 4; j++, counter *= 10) { Map tempMap = new HashMap(); for (int i = 0; i < counter; i++) { tempMap.put(i, i); } map.putAll(tempMap); assertEquals(1, map.get(1)); } map.destroy(); }
@Test public void putAll() { HazelcastClient hClient = getHazelcastClient(); IMap map = hClient.getMap("putAll"); int counter = 100; Set keys = new HashSet(counter); for (int i = 0; i < counter; i++) { keys.add(i); } Map all = map.getAll(keys); assertEquals(0, all.size()); Map tempMap = new HashMap(); for (int i = 0; i < counter; i++) { tempMap.put(i, i); } map.putAll(tempMap); for (int i = 0; i < counter; i++) { assertEquals(i, map.get(i)); } all = map.getAll(keys); assertEquals(counter, all.size()); }
@Test public void addListenerAndMultiPut() throws InterruptedException, IOException { HazelcastClient hClient = getHazelcastClient(); final IMap<String, byte[]> map = hClient.getMap("addListenerAndMultiPut"); map.clear(); int counter = 100; assertEquals(0, map.size()); final CountDownLatch entryAddLatch = new CountDownLatch(counter); final CountDownLatch entryUpdatedLatch = new CountDownLatch(counter); final CountDownLatch entryRemovedLatch = new CountDownLatch(counter); CountDownLatchEntryListener<String, byte[]> listener = new CountDownLatchEntryListener<String, byte[]>( entryAddLatch, entryUpdatedLatch, entryRemovedLatch); map.addEntryListener(listener, true); assertNull(map.get("hello")); Map<String, byte[]> many = new HashMap<String, byte[]>(); for (int i = 0; i < counter; i++) { many.put("" + i, new byte[i]); } map.putAll(many); assertTrue(entryAddLatch.await(10, TimeUnit.SECONDS)); // assertTrue(entryUpdatedLatch.await(10, TimeUnit.MILLISECONDS)); // assertTrue(entryRemovedLatch.await(10, TimeUnit.MILLISECONDS)); }