@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));
   }
 }
Пример #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);
   }
 }
Пример #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));
 }
 /**
  * Returns the status of whether the worker is enabled or not
  *
  * @param id the id of the worker to test
  * @return true if the worker is enabled, false otherwise
  */
 @Override
 public boolean workerEnabled(String id) {
   return workerEnabled.containsKey(id) && workerEnabled.get(id);
 }