7 |
|
*/ |
8 |
|
|
9 |
|
import junit.framework.*; |
10 |
< |
import java.util.*; |
11 |
< |
import java.util.concurrent.*; |
12 |
< |
import java.io.*; |
10 |
> |
import java.util.Arrays; |
11 |
> |
import java.util.Iterator; |
12 |
> |
import java.util.Set; |
13 |
> |
import java.util.Vector; |
14 |
> |
import java.util.concurrent.CopyOnWriteArraySet; |
15 |
|
|
16 |
|
public class CopyOnWriteArraySetTest extends JSR166TestCase { |
17 |
|
public static void main(String[] args) { |
267 |
|
* A deserialized serialized set is equal |
268 |
|
*/ |
269 |
|
public void testSerialization() throws Exception { |
270 |
< |
CopyOnWriteArraySet q = populatedSet(SIZE); |
270 |
> |
Set x = populatedSet(SIZE); |
271 |
> |
Set y = serialClone(x); |
272 |
|
|
273 |
< |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
274 |
< |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
275 |
< |
out.writeObject(q); |
276 |
< |
out.close(); |
274 |
< |
|
275 |
< |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
276 |
< |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
277 |
< |
CopyOnWriteArraySet r = (CopyOnWriteArraySet)in.readObject(); |
278 |
< |
assertEquals(q.size(), r.size()); |
279 |
< |
assertTrue(q.equals(r)); |
280 |
< |
assertTrue(r.equals(q)); |
273 |
> |
assertTrue(x != y); |
274 |
> |
assertEquals(x.size(), y.size()); |
275 |
> |
assertEquals(x, y); |
276 |
> |
assertEquals(y, x); |
277 |
|
} |
278 |
|
|
279 |
|
} |