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

Comparing jsr166/src/test/tck/ConcurrentHashMapTest.java (file contents):
Revision 1.51 by jsr166, Sat Oct 15 18:51:12 2016 UTC vs.
Revision 1.56 by jsr166, Wed Aug 23 05:33:00 2017 UTC

# Line 1 | Line 1
1   /*
2 < * Written by Doug Lea with assistance from members of JCP JSR-166
3 < * Expert Group and released to the public domain, as explained at
2 > * Written by Doug Lea and Martin Buchholz with assistance from
3 > * members of JCP JSR-166 Expert Group and released to the public
4 > * domain, as explained at
5   * http://creativecommons.org/publicdomain/zero/1.0/
6   * Other contributors include Andrew Wright, Jeffrey Hayes,
7   * Pat Fisher, Mike Judd.
# Line 16 | Line 17 | import java.util.Map;
17   import java.util.Random;
18   import java.util.Set;
19   import java.util.concurrent.ConcurrentHashMap;
19 import java.util.concurrent.ExecutorService;
20 import java.util.concurrent.Executors;
20  
21   import junit.framework.Test;
23 import junit.framework.TestSuite;
22  
23   public class ConcurrentHashMapTest extends JSR166TestCase {
24      public static void main(String[] args) {
25          main(suite(), args);
26      }
27      public static Test suite() {
28 <        return new TestSuite(ConcurrentHashMapTest.class);
28 >        class Implementation implements MapImplementation {
29 >            public Class<?> klazz() { return ConcurrentHashMap.class; }
30 >            public Map emptyMap() { return new ConcurrentHashMap(); }
31 >            public Object makeKey(int i) { return i; }
32 >            public Object makeValue(int i) { return i; }
33 >            public boolean isConcurrent() { return true; }
34 >            public boolean permitsNullKeys() { return false; }
35 >            public boolean permitsNullValues() { return false; }
36 >            public boolean supportsSetValue() { return true; }
37 >        }
38 >        return newTestSuite(
39 >            ConcurrentHashMapTest.class,
40 >            MapTest.testSuite(new Implementation()));
41      }
42  
43      /**
44       * Returns a new map from Integers 1-5 to Strings "A"-"E".
45       */
46      private static ConcurrentHashMap<Integer, String> map5() {
47 <        ConcurrentHashMap map = new ConcurrentHashMap<Integer, String>(5);
47 >        ConcurrentHashMap<Integer, String> map = new ConcurrentHashMap<>(5);
48          assertTrue(map.isEmpty());
49          map.put(one, "A");
50          map.put(two, "B");
# Line 121 | Line 131 | public class ConcurrentHashMapTest exten
131          ConcurrentHashMap<BI, Boolean> m =
132              new ConcurrentHashMap<BI, Boolean>();
133          for (int i = 0; i < size; i++) {
134 <            assertTrue(m.put(new CI(i), true) == null);
134 >            assertNull(m.put(new CI(i), true));
135          }
136          for (int i = 0; i < size; i++) {
137              assertTrue(m.containsKey(new CI(i)));
# Line 142 | Line 152 | public class ConcurrentHashMapTest exten
152              BS bs = new BS(String.valueOf(i));
153              LexicographicList<BI> bis = new LexicographicList<BI>(bi);
154              LexicographicList<BS> bss = new LexicographicList<BS>(bs);
155 <            assertTrue(m.putIfAbsent(bis, true) == null);
155 >            assertNull(m.putIfAbsent(bis, true));
156              assertTrue(m.containsKey(bis));
157              if (m.putIfAbsent(bss, true) == null)
158                  assertTrue(m.containsKey(bss));
# Line 786 | Line 796 | public class ConcurrentHashMapTest exten
796      }
797  
798      /**
799 <     * A deserialized map equals original
799 >     * A deserialized/reserialized map equals original
800       */
801      public void testSerialization() throws Exception {
802          Map x = map5();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines