@Test public void testHazelcastInstances() { assertNotNull(map1); assertNotNull(map2); assertNotNull(multiMap); assertNotNull(replicatedMap); assertNotNull(queue); assertNotNull(topic); assertNotNull(set); assertNotNull(list); assertNotNull(executorService); assertNotNull(idGenerator); assertNotNull(atomicLong); assertNotNull(atomicReference); assertNotNull(countDownLatch); assertNotNull(semaphore); assertNotNull(lock); assertEquals("map1", map1.getName()); assertEquals("map2", map2.getName()); assertEquals("testMultimap", multiMap.getName()); assertEquals("replicatedMap", replicatedMap.getName()); assertEquals("testQ", queue.getName()); assertEquals("testTopic", topic.getName()); assertEquals("set", set.getName()); assertEquals("list", list.getName()); assertEquals("idGenerator", idGenerator.getName()); assertEquals("atomicLong", atomicLong.getName()); assertEquals("atomicReference", atomicReference.getName()); assertEquals("countDownLatch", countDownLatch.getName()); assertEquals("semaphore", semaphore.getName()); }
@Test(timeout = 60000) public void testMapReduceWithList() throws Exception { Config config = buildConfig(); HazelcastInstance h1 = hazelcastFactory.newHazelcastInstance(config); HazelcastInstance h2 = hazelcastFactory.newHazelcastInstance(config); HazelcastInstance h3 = hazelcastFactory.newHazelcastInstance(config); assertClusterSizeEventually(3, h1); assertClusterSizeEventually(3, h2); assertClusterSizeEventually(3, h3); HazelcastInstance client = hazelcastFactory.newHazelcastClient(); int expectedResult = 0; IList<Integer> list = h1.getList("default"); for (int o = 0; o < 100; o++) { list.add(o); expectedResult += o; } JobTracker jobTracker = client.getJobTracker("default"); Job<String, Integer> job = jobTracker.newJob(KeyValueSource.fromList(list)); ICompletableFuture<Map<String, Integer>> ICompletableFuture = job.chunkSize(10) .mapper(new ListSetMapReduceTest.ListSetMapper()) .combiner(new ListSetMapReduceTest.ListSetCombinerFactory()) .reducer(new ListSetMapReduceTest.ListSetReducerFactory()) .submit(); Map<String, Integer> result = ICompletableFuture.get(); assertEquals(1, result.size()); int count = 0; for (Map.Entry<String, Integer> entry : result.entrySet()) { assertEquals(list.getName(), entry.getKey()); assertEquals(expectedResult, (int) entry.getValue()); } }