Beispiel #1
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);
   }
 }
Beispiel #2
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));
 }