@Test
 public void containsKey() {
   HazelcastClient hClient = getHazelcastClient();
   MultiMap<String, Integer> multiMap = hClient.getMultiMap("containsKey");
   assertFalse(multiMap.containsKey("a"));
   assertTrue(multiMap.put("a", 1));
   assertTrue(multiMap.containsKey("a"));
 }
Пример #2
0
  @Test
  public void testContainsKey_whenKeyExists() {
    final MultiMap mm = client.getMultiMap(randomString());
    mm.put("key1", "value1");

    assertTrue(mm.containsKey("key1"));
  }
 @Test
 public void testMultiMapContainsKey() {
   HazelcastClient hClient = getHazelcastClient();
   MultiMap<String, String> map = hClient.getMultiMap("testMultiMapContainsKey");
   map.put("Hello", "World");
   assertTrue(map.containsKey("Hello"));
 }
 @Test
 public void testMultiMapPutAndGet() {
   HazelcastClient hClient = getHazelcastClient();
   MultiMap<String, String> map = hClient.getMultiMap("testMultiMapPutAndGet");
   map.put("Hello", "World");
   Collection<String> values = map.get("Hello");
   assertEquals("World", values.iterator().next());
   map.put("Hello", "Europe");
   map.put("Hello", "America");
   map.put("Hello", "Asia");
   map.put("Hello", "Africa");
   map.put("Hello", "Antarctica");
   map.put("Hello", "Australia");
   values = map.get("Hello");
   assertEquals(7, values.size());
   assertTrue(map.containsKey("Hello"));
   assertFalse(map.containsKey("Hi"));
 }
 @Test
 public void testTransactionAtomicity_whenMultiMapContainsKeyIsUsed_withoutTransaction()
     throws InterruptedException {
   final HazelcastInstance hz = Hazelcast.newHazelcastInstance(createConfigWithDummyTxService());
   final String name = HazelcastTestSupport.generateRandomString(5);
   Thread producerThread = startProducerThread(hz, name);
   try {
     IQueue<String> q = hz.getQueue(name);
     for (int i = 0; i < 1000; i++) {
       String id = q.poll();
       if (id != null) {
         MultiMap<Object, Object> multiMap = hz.getMultiMap(name);
         assertTrue(multiMap.containsKey(id));
         multiMap.remove(id);
       } else {
         LockSupport.parkNanos(100);
       }
     }
   } finally {
     stopProducerThread(producerThread);
   }
 }
Пример #6
0
  @Test(expected = NullPointerException.class)
  public void testContainsKey_whenKeyNull() {
    final MultiMap mm = client.getMultiMap(randomString());

    mm.containsKey(null);
  }
Пример #7
0
  @Test
  public void testContainsKey_whenKeyNotExists() {
    final MultiMap mm = client.getMultiMap(randomString());

    assertFalse(mm.containsKey("NOT_THERE"));
  }
 public boolean containsKey(K key) {
   return delegate.containsKey(key);
 }