--- jsr166/src/test/tck/ConcurrentHashMapTest.java 2017/03/11 17:33:32 1.53 +++ jsr166/src/test/tck/ConcurrentHashMapTest.java 2017/08/23 05:33:00 1.56 @@ -1,6 +1,7 @@ /* - * Written by Doug Lea with assistance from members of JCP JSR-166 - * Expert Group and released to the public domain, as explained at + * Written by Doug Lea and Martin Buchholz with assistance from + * members of JCP JSR-166 Expert Group and released to the public + * domain, as explained at * http://creativecommons.org/publicdomain/zero/1.0/ * Other contributors include Andrew Wright, Jeffrey Hayes, * Pat Fisher, Mike Judd. @@ -18,14 +19,25 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import junit.framework.Test; -import junit.framework.TestSuite; public class ConcurrentHashMapTest extends JSR166TestCase { public static void main(String[] args) { main(suite(), args); } public static Test suite() { - return new TestSuite(ConcurrentHashMapTest.class); + class Implementation implements MapImplementation { + public Class klazz() { return ConcurrentHashMap.class; } + public Map emptyMap() { return new ConcurrentHashMap(); } + public Object makeKey(int i) { return i; } + public Object makeValue(int i) { return i; } + public boolean isConcurrent() { return true; } + public boolean permitsNullKeys() { return false; } + public boolean permitsNullValues() { return false; } + public boolean supportsSetValue() { return true; } + } + return newTestSuite( + ConcurrentHashMapTest.class, + MapTest.testSuite(new Implementation())); } /** @@ -119,7 +131,7 @@ public class ConcurrentHashMapTest exten ConcurrentHashMap m = new ConcurrentHashMap(); for (int i = 0; i < size; i++) { - assertTrue(m.put(new CI(i), true) == null); + assertNull(m.put(new CI(i), true)); } for (int i = 0; i < size; i++) { assertTrue(m.containsKey(new CI(i))); @@ -140,7 +152,7 @@ public class ConcurrentHashMapTest exten BS bs = new BS(String.valueOf(i)); LexicographicList bis = new LexicographicList(bi); LexicographicList bss = new LexicographicList(bs); - assertTrue(m.putIfAbsent(bis, true) == null); + assertNull(m.putIfAbsent(bis, true)); assertTrue(m.containsKey(bis)); if (m.putIfAbsent(bss, true) == null) assertTrue(m.containsKey(bss)); @@ -784,7 +796,7 @@ public class ConcurrentHashMapTest exten } /** - * A deserialized map equals original + * A deserialized/reserialized map equals original */ public void testSerialization() throws Exception { Map x = map5();