ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/ConcurrentHashMap8Test.java
(Generate patch)

Comparing jsr166/src/test/tck/ConcurrentHashMap8Test.java (file contents):
Revision 1.3 by dl, Fri Mar 22 14:11:32 2013 UTC vs.
Revision 1.4 by jsr166, Fri Mar 22 16:10:19 2013 UTC

# Line 68 | Line 68 | public class ConcurrentHashMap8Test exte
68          map.computeIfAbsent(six, (x) -> null);
69          assertFalse(map.containsKey(six));
70      }
71 <    
71 >
72      /**
73       * computeIfPresent does not replace  if the key is already present
74       */
# Line 380 | Line 380 | public class ConcurrentHashMap8Test exte
380              elements[i] = i;
381          Collections.shuffle(Arrays.asList(elements));
382          Collection<Integer> full = populatedSet(elements);
383 <        
383 >
384          assertTrue(Arrays.asList(elements).containsAll(Arrays.asList(full.toArray())));
385          assertTrue(full.containsAll(Arrays.asList(full.toArray())));
386          assertSame(Object[].class, full.toArray().getClass());
# Line 442 | Line 442 | public class ConcurrentHashMap8Test exte
442  
443      static final int SIZE = 10000;
444      static ConcurrentHashMap<Long, Long> longMap;
445 <    
445 >
446      static ConcurrentHashMap<Long, Long> longMap() {
447          if (longMap == null) {
448              longMap = new ConcurrentHashMap<Long, Long>(SIZE);
# Line 456 | Line 456 | public class ConcurrentHashMap8Test exte
456      static class AddKeys implements BiFunction<Map.Entry<Long,Long>, Map.Entry<Long,Long>, Map.Entry<Long,Long>> {
457          public Map.Entry<Long,Long> apply(Map.Entry<Long,Long> x, Map.Entry<Long,Long> y) {
458              return new AbstractMap.SimpleEntry<Long,Long>
459 <             (Long.valueOf(x.getKey().longValue() + y.getKey().longValue()),
459 >             (Long.valueOf(x.getKey().longValue() + y.getKey().longValue()),
460                Long.valueOf(1L));
461          }
462      }
# Line 726 | Line 726 | public class ConcurrentHashMap8Test exte
726          ConcurrentHashMap<Long, Long> m = longMap();
727          Long r = m.reduceSequentially((Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()),
728                                   (Long x, Long y) -> Long.valueOf(x.longValue() + y.longValue()));
729 <        
729 >
730          assertEquals((long)r, (long)3 * SIZE * (SIZE - 1) / 2);
731      }
732  
# Line 877 | Line 877 | public class ConcurrentHashMap8Test exte
877      public void testSearchKeysSequentially() {
878          ConcurrentHashMap<Long, Long> m = longMap();
879          Long r;
880 <        r = m.searchKeysSequentially((Long x) -> x.longValue() == (long)(SIZE/2)? x : null);
880 >        r = m.searchKeysSequentially((Long x) -> x.longValue() == (long)(SIZE/2) ? x : null);
881          assertEquals((long)r, (long)(SIZE/2));
882 <        r = m.searchKeysSequentially((Long x) -> x.longValue() < 0L? x : null);
882 >        r = m.searchKeysSequentially((Long x) -> x.longValue() < 0L ? x : null);
883          assertNull(r);
884      }
885  
# Line 892 | Line 892 | public class ConcurrentHashMap8Test exte
892          Long r;
893          r = m.searchValuesSequentially((Long x) -> x.longValue() == (long)(SIZE/2)? x : null);
894          assertEquals((long)r, (long)(SIZE/2));
895 <        r = m.searchValuesSequentially((Long x) -> x.longValue() < 0L? x : null);
895 >        r = m.searchValuesSequentially((Long x) -> x.longValue() < 0L ? x : null);
896          assertNull(r);
897      }
898  
# Line 903 | Line 903 | public class ConcurrentHashMap8Test exte
903      public void testSearchSequentially() {
904          ConcurrentHashMap<Long, Long> m = longMap();
905          Long r;
906 <        r = m.searchSequentially((Long x, Long y) -> x.longValue() == (long)(SIZE/2)? x : null);
906 >        r = m.searchSequentially((Long x, Long y) -> x.longValue() == (long)(SIZE/2) ? x : null);
907          assertEquals((long)r, (long)(SIZE/2));
908 <        r = m.searchSequentially((Long x, Long y) -> x.longValue() < 0L? x : null);
908 >        r = m.searchSequentially((Long x, Long y) -> x.longValue() < 0L ? x : null);
909          assertNull(r);
910      }
911  
# Line 916 | Line 916 | public class ConcurrentHashMap8Test exte
916      public void testSearchEntriesSequentially() {
917          ConcurrentHashMap<Long, Long> m = longMap();
918          Long r;
919 <        r = m.searchEntriesSequentially((Map.Entry<Long,Long> e) -> e.getKey().longValue() == (long)(SIZE/2)? e.getKey() : null);
919 >        r = m.searchEntriesSequentially((Map.Entry<Long,Long> e) -> e.getKey().longValue() == (long)(SIZE/2) ? e.getKey() : null);
920          assertEquals((long)r, (long)(SIZE/2));
921 <        r = m.searchEntriesSequentially((Map.Entry<Long,Long> e) -> e.getKey().longValue() < 0L? e.getKey() : null);
921 >        r = m.searchEntriesSequentially((Map.Entry<Long,Long> e) -> e.getKey().longValue() < 0L ? e.getKey() : null);
922          assertNull(r);
923      }
924  
# Line 929 | Line 929 | public class ConcurrentHashMap8Test exte
929      public void testSearchKeysInParallel() {
930          ConcurrentHashMap<Long, Long> m = longMap();
931          Long r;
932 <        r = m.searchKeysInParallel((Long x) -> x.longValue() == (long)(SIZE/2)? x : null);
932 >        r = m.searchKeysInParallel((Long x) -> x.longValue() == (long)(SIZE/2) ? x : null);
933          assertEquals((long)r, (long)(SIZE/2));
934 <        r = m.searchKeysInParallel((Long x) -> x.longValue() < 0L? x : null);
934 >        r = m.searchKeysInParallel((Long x) -> x.longValue() < 0L ? x : null);
935          assertNull(r);
936      }
937  
# Line 942 | Line 942 | public class ConcurrentHashMap8Test exte
942      public void testSearchValuesInParallel() {
943          ConcurrentHashMap<Long, Long> m = longMap();
944          Long r;
945 <        r = m.searchValuesInParallel((Long x) -> x.longValue() == (long)(SIZE/2)? x : null);
945 >        r = m.searchValuesInParallel((Long x) -> x.longValue() == (long)(SIZE/2) ? x : null);
946          assertEquals((long)r, (long)(SIZE/2));
947 <        r = m.searchValuesInParallel((Long x) -> x.longValue() < 0L? x : null);
947 >        r = m.searchValuesInParallel((Long x) -> x.longValue() < 0L ? x : null);
948          assertNull(r);
949      }
950  
# Line 955 | Line 955 | public class ConcurrentHashMap8Test exte
955      public void testSearchInParallel() {
956          ConcurrentHashMap<Long, Long> m = longMap();
957          Long r;
958 <        r = m.searchInParallel((Long x, Long y) -> x.longValue() == (long)(SIZE/2)? x : null);
958 >        r = m.searchInParallel((Long x, Long y) -> x.longValue() == (long)(SIZE/2) ? x : null);
959          assertEquals((long)r, (long)(SIZE/2));
960 <        r = m.searchInParallel((Long x, Long y) -> x.longValue() < 0L? x : null);
960 >        r = m.searchInParallel((Long x, Long y) -> x.longValue() < 0L ? x : null);
961          assertNull(r);
962      }
963  
# Line 968 | Line 968 | public class ConcurrentHashMap8Test exte
968      public void testSearchEntriesInParallel() {
969          ConcurrentHashMap<Long, Long> m = longMap();
970          Long r;
971 <        r = m.searchEntriesInParallel((Map.Entry<Long,Long> e) -> e.getKey().longValue() == (long)(SIZE/2)? e.getKey() : null);
971 >        r = m.searchEntriesInParallel((Map.Entry<Long,Long> e) -> e.getKey().longValue() == (long)(SIZE/2) ? e.getKey() : null);
972          assertEquals((long)r, (long)(SIZE/2));
973 <        r = m.searchEntriesInParallel((Map.Entry<Long,Long> e) -> e.getKey().longValue() < 0L? e.getKey() : null);
973 >        r = m.searchEntriesInParallel((Map.Entry<Long,Long> e) -> e.getKey().longValue() < 0L ? e.getKey() : null);
974          assertNull(r);
975      }
976  
# Line 994 | Line 994 | public class ConcurrentHashMap8Test exte
994          assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
995          adder.reset();
996          ConcurrentHashMap.ForkJoinTasks.forEachEntry
997 <            (m,
997 >            (m,
998               (Map.Entry<Long,Long> e) -> adder.add(e.getKey().longValue() + e.getValue().longValue())).invoke();
999          assertEquals(adder.sum(), 3 * SIZE * (SIZE - 1) / 2);
1000          adder.reset();
# Line 1072 | Line 1072 | public class ConcurrentHashMap8Test exte
1072          r = ConcurrentHashMap.ForkJoinTasks.searchEntries
1073              (m, (Map.Entry<Long,Long> e) -> e.getKey().longValue() == (long)(SIZE/2)? e.getKey() : null).invoke();
1074          assertEquals((long)r, (long)(SIZE/2));
1075 <    }            
1075 >    }
1076   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines