8 |
|
|
9 |
|
import junit.framework.*; |
10 |
|
import java.util.*; |
11 |
< |
import java.util.concurrent.*; |
12 |
< |
import java.util.Enumeration; |
13 |
< |
import java.io.*; |
11 |
> |
import java.util.concurrent.ConcurrentHashMap; |
12 |
|
|
13 |
|
public class ConcurrentHashMapTest extends JSR166TestCase { |
14 |
|
public static void main(String[] args) { |
549 |
|
* A deserialized map equals original |
550 |
|
*/ |
551 |
|
public void testSerialization() throws Exception { |
552 |
< |
ConcurrentHashMap q = map5(); |
552 |
> |
Map x = map5(); |
553 |
> |
Map y = serialClone(x); |
554 |
|
|
555 |
< |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
556 |
< |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
557 |
< |
out.writeObject(q); |
558 |
< |
out.close(); |
560 |
< |
|
561 |
< |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
562 |
< |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
563 |
< |
ConcurrentHashMap r = (ConcurrentHashMap)in.readObject(); |
564 |
< |
assertEquals(q.size(), r.size()); |
565 |
< |
assertTrue(q.equals(r)); |
566 |
< |
assertTrue(r.equals(q)); |
555 |
> |
assertTrue(x != y); |
556 |
> |
assertEquals(x.size(), y.size()); |
557 |
> |
assertEquals(x, y); |
558 |
> |
assertEquals(y, x); |
559 |
|
} |
560 |
|
|
561 |
|
/** |