24 * This file is available under and governed by the GNU General Public |
24 * This file is available under and governed by the GNU General Public |
25 * License version 2 only, as published by the Free Software Foundation. |
25 * License version 2 only, as published by the Free Software Foundation. |
26 * However, the following notice accompanied the original version of this |
26 * However, the following notice accompanied the original version of this |
27 * file: |
27 * file: |
28 * |
28 * |
29 * Written by Doug Lea with assistance from members of JCP JSR-166 |
29 * Written by Doug Lea and Martin Buchholz with assistance from |
30 * Expert Group and released to the public domain, as explained at |
30 * members of JCP JSR-166 Expert Group and released to the public |
|
31 * domain, as explained at |
31 * http://creativecommons.org/publicdomain/zero/1.0/ |
32 * http://creativecommons.org/publicdomain/zero/1.0/ |
32 * Other contributors include Andrew Wright, Jeffrey Hayes, |
33 * Other contributors include Andrew Wright, Jeffrey Hayes, |
33 * Pat Fisher, Mike Judd. |
34 * Pat Fisher, Mike Judd. |
34 */ |
35 */ |
35 |
36 |
43 import java.util.Random; |
44 import java.util.Random; |
44 import java.util.Set; |
45 import java.util.Set; |
45 import java.util.concurrent.ConcurrentHashMap; |
46 import java.util.concurrent.ConcurrentHashMap; |
46 |
47 |
47 import junit.framework.Test; |
48 import junit.framework.Test; |
48 import junit.framework.TestSuite; |
|
49 |
49 |
50 public class ConcurrentHashMapTest extends JSR166TestCase { |
50 public class ConcurrentHashMapTest extends JSR166TestCase { |
51 public static void main(String[] args) { |
51 public static void main(String[] args) { |
52 main(suite(), args); |
52 main(suite(), args); |
53 } |
53 } |
54 public static Test suite() { |
54 public static Test suite() { |
55 return new TestSuite(ConcurrentHashMapTest.class); |
55 class Implementation implements MapImplementation { |
|
56 public Class<?> klazz() { return ConcurrentHashMap.class; } |
|
57 public Map emptyMap() { return new ConcurrentHashMap(); } |
|
58 public Object makeKey(int i) { return i; } |
|
59 public Object makeValue(int i) { return i; } |
|
60 public boolean isConcurrent() { return true; } |
|
61 public boolean permitsNullKeys() { return false; } |
|
62 public boolean permitsNullValues() { return false; } |
|
63 public boolean supportsSetValue() { return true; } |
|
64 } |
|
65 return newTestSuite( |
|
66 ConcurrentHashMapTest.class, |
|
67 MapTest.testSuite(new Implementation())); |
56 } |
68 } |
57 |
69 |
58 /** |
70 /** |
59 * Returns a new map from Integers 1-5 to Strings "A"-"E". |
71 * Returns a new map from Integers 1-5 to Strings "A"-"E". |
60 */ |
72 */ |