Пример #1
0
  @Test
  public void testValueCount_whenKeyNotThere() {
    final Object key = "key1";
    final MultiMap mm = client.getMultiMap(randomString());

    assertEquals(0, mm.valueCount("NOT_THERE"));
  }
Пример #2
0
  @Test
  public void testValueCount() {
    final Object key = "key1";

    final MultiMap mm = client.getMultiMap(randomString());

    mm.put(key, 1);
    mm.put(key, 2);

    assertEquals(2, mm.valueCount(key));
  }
 @Test
 public void testMultiMapValueCount() {
   HazelcastClient hClient = getHazelcastClient();
   MultiMap<Integer, String> map = hClient.getMultiMap("testMultiMapValueCount");
   map.put(1, "World");
   map.put(2, "Africa");
   map.put(1, "America");
   map.put(2, "Antarctica");
   map.put(1, "Asia");
   map.put(1, "Europe");
   map.put(2, "Australia");
   assertEquals(4, map.valueCount(1));
   assertEquals(3, map.valueCount(2));
 }
 @Test
 public void testTransactionAtomicity_whenMultiMapValueCountIsUsed_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);
         assertEquals(1, multiMap.valueCount(id));
         multiMap.remove(id);
       } else {
         LockSupport.parkNanos(100);
       }
     }
   } finally {
     stopProducerThread(producerThread);
   }
 }
 @Override
 public int valueCount(K key) {
   return delegate.valueCount(key);
 }