Warning:
ˆ This method uses hashCode and equals of binary form of the key, not the actual implementations of hashCode and equals defined in key's class.
305306307308309310311312313314315
} }, 1); addOperation(operations, new Runnable() { public void run() { IMap map = hazelcast.getMap("myMap"); map.containsKey(random.nextInt(SIZE)); } }, 2); addOperation(operations, new Runnable() { public void run() { IMap map = hazelcast.getMap("myMap");
6869707172737475767778
stats.increment("get"); } else if (operation < 3) { map.remove(key); stats.increment("remove"); } else if (operation < 4) { map.containsKey(key); stats.increment("containsKey"); } else if (operation < 5) { Object value = String.valueOf(key); map.containsValue(value); stats.increment("containsValue");
169170171172173174175176177178179
private boolean checkKeysIn(HazelcastInstance[] cluster, String mapName, int start, int end) { HazelcastInstance node = getNode(cluster); IMap m = node.getMap(mapName); for (; start < end; start++) { if (!m.containsKey(start)) { return false; } } return true; }
196197198199200201202203204205206
private boolean checkKeysNotIn(HazelcastInstance[] cluster, String mapName, int start, int end) { HazelcastInstance node = getNode(cluster); IMap m = node.getMap(mapName); for (; start < end; start++) { if (m.containsKey(start)) { return false; } } return true; }
144145146147148149150151152153154
@Test public void testContains() throws Exception { final IMap map = createMap(); fillMap(map); assertFalse(map.containsKey("key10")); assertTrue(map.containsKey("key1")); assertFalse(map.containsValue("value10")); assertTrue(map.containsValue("value1"));
145146147148149150151152153154155
public void testContains() throws Exception { final IMap map = createMap(); fillMap(map); assertFalse(map.containsKey("key10")); assertTrue(map.containsKey("key1")); assertFalse(map.containsValue("value10")); assertTrue(map.containsValue("value1")); }
415416417418419420421422423424425
} @Test(expected = NullPointerException.class) public void testNearCacheContainsNullKey() { final IMap map = client.getMap(randomMapName(NEAR_CACHE_WITH_INVALIDATION)); map.containsKey(null); } @Test public void testNearCacheContainsKey() { final IMap map = client.getMap(randomMapName(NEAR_CACHE_WITH_INVALIDATION));
426427428429430431432433434435436
final Object key = "key"; map.put(key, "value"); map.get(key); assertTrue(map.containsKey(key)); } @Test public void testNearCacheContainsKey_whenKeyAbsent() { final IMap map = client.getMap(randomMapName(NEAR_CACHE_WITH_INVALIDATION));
433434435436437438439440441442443
@Test public void testNearCacheContainsKey_whenKeyAbsent() { final IMap map = client.getMap(randomMapName(NEAR_CACHE_WITH_INVALIDATION)); assertFalse(map.containsKey("NOT_THERE")); } @Test public void testNearCacheContainsKey_afterRemove() { final IMap map = client.getMap(randomMapName(NEAR_CACHE_WITH_INVALIDATION));