--- jsr166/src/test/tck/ConcurrentHashMapTest.java 2011/03/15 19:47:06 1.23 +++ jsr166/src/test/tck/ConcurrentHashMapTest.java 2011/11/26 05:19:17 1.26 @@ -8,9 +8,7 @@ import junit.framework.*; import java.util.*; -import java.util.concurrent.*; -import java.util.Enumeration; -import java.io.*; +import java.util.concurrent.ConcurrentHashMap; public class ConcurrentHashMapTest extends JSR166TestCase { public static void main(String[] args) { @@ -42,7 +40,7 @@ public class ConcurrentHashMapTest exten public void testClear() { ConcurrentHashMap map = map5(); map.clear(); - assertEquals(map.size(), 0); + assertEquals(0, map.size()); } /** @@ -275,7 +273,6 @@ public class ConcurrentHashMapTest exten assertEquals("Z", map.get(one)); } - /** * replace value fails when the given key not mapped to expected value */ @@ -296,7 +293,6 @@ public class ConcurrentHashMapTest exten assertEquals("Z", map.get(one)); } - /** * remove removes the correct key-value pair from the map */ @@ -337,7 +333,7 @@ public class ConcurrentHashMapTest exten ConcurrentHashMap map = map5(); String s = map.toString(); for (int i = 1; i <= 5; ++i) { - assertTrue(s.indexOf(String.valueOf(i)) >= 0); + assertTrue(s.contains(String.valueOf(i))); } } @@ -483,7 +479,6 @@ public class ConcurrentHashMapTest exten } catch (NullPointerException success) {} } - /** * replace(x, null) throws NPE */ @@ -517,7 +512,6 @@ public class ConcurrentHashMapTest exten } catch (NullPointerException success) {} } - /** * remove(null) throws NPE */ @@ -555,22 +549,15 @@ public class ConcurrentHashMapTest exten * A deserialized map equals original */ public void testSerialization() throws Exception { - ConcurrentHashMap q = map5(); + Map x = map5(); + Map y = serialClone(x); - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(q); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - ConcurrentHashMap r = (ConcurrentHashMap)in.readObject(); - assertEquals(q.size(), r.size()); - assertTrue(q.equals(r)); - assertTrue(r.equals(q)); + assertTrue(x != y); + assertEquals(x.size(), y.size()); + assertEquals(x, y); + assertEquals(y, x); } - /** * SetValue of an EntrySet entry sets value in the map. */