@Test
 public void containsKey() {
   HazelcastClient hClient = getHazelcastClient();
   IMap map = hClient.getMap("containsKey");
   int counter = 100;
   for (int i = 0; i < counter; i++) {
     assertNull(map.put(i, i));
     assertEquals(i, map.get(i));
   }
   for (int i = 0; i < counter; i++) {
     assertTrue(map.containsKey(i));
   }
 }
Exemple #2
0
 /**
  * Test for issue 614
  *
  * @throws InterruptedException
  */
 @Test
 public void testContainsKeyShouldDelayEviction() throws InterruptedException {
   Config cfg = new Config();
   String mapname = "testContainsKeyShouldDelayEviction";
   cfg.getMapConfig(mapname).setMaxIdleSeconds(3);
   TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(1);
   HazelcastInstance instance = factory.newHazelcastInstance(cfg);
   IMap<Object, Object> map = instance.getMap(mapname);
   map.put(1, 1);
   for (int i = 0; i < 20; i++) {
     assertTrue(map.containsKey(1));
     Thread.sleep(500);
   }
 }
Exemple #3
0
 /**
  * Test for the issue 477. Updates should also update the TTL
  *
  * @throws Exception
  */
 @Test
 public void testMapPutWithTTL() throws Exception {
   int n = 1;
   TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(n);
   IMap<Integer, String> map = factory.newHazelcastInstance(null).getMap("testMapPutWithTTL");
   map.put(1, "value0", 100, TimeUnit.MILLISECONDS);
   assertEquals(true, map.containsKey(1));
   Thread.sleep(2500);
   assertEquals(false, map.containsKey(1));
   map.put(1, "value1", 10, TimeUnit.SECONDS);
   assertEquals(true, map.containsKey(1));
   Thread.sleep(5000);
   assertEquals(true, map.containsKey(1));
   map.put(1, "value2", 10, TimeUnit.SECONDS);
   Thread.sleep(5000);
   assertEquals(true, map.containsKey(1));
   map.put(1, "value3", 10, TimeUnit.SECONDS);
   assertEquals(true, map.containsKey(1));
 }