5 |
|
*/ |
6 |
|
|
7 |
|
import junit.framework.*; |
8 |
< |
import java.util.*; |
9 |
< |
import java.util.concurrent.*; |
10 |
< |
import java.io.*; |
8 |
> |
import java.util.Arrays; |
9 |
> |
import java.util.BitSet; |
10 |
> |
import java.util.Collection; |
11 |
> |
import java.util.Comparator; |
12 |
> |
import java.util.Iterator; |
13 |
> |
import java.util.NavigableSet; |
14 |
> |
import java.util.NoSuchElementException; |
15 |
> |
import java.util.Random; |
16 |
> |
import java.util.Set; |
17 |
> |
import java.util.SortedSet; |
18 |
> |
import java.util.concurrent.ConcurrentSkipListSet; |
19 |
|
|
20 |
|
public class ConcurrentSkipListSubSetTest extends JSR166TestCase { |
21 |
|
public static void main(String[] args) { |
491 |
|
* A deserialized serialized set has same elements |
492 |
|
*/ |
493 |
|
public void testSerialization() throws Exception { |
494 |
< |
NavigableSet q = populatedSet(SIZE); |
495 |
< |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
496 |
< |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
497 |
< |
out.writeObject(q); |
498 |
< |
out.close(); |
499 |
< |
|
500 |
< |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
501 |
< |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
502 |
< |
NavigableSet r = (NavigableSet)in.readObject(); |
503 |
< |
assertEquals(q.size(), r.size()); |
504 |
< |
while (!q.isEmpty()) |
505 |
< |
assertEquals(q.pollFirst(), r.pollFirst()); |
494 |
> |
NavigableSet x = populatedSet(SIZE); |
495 |
> |
NavigableSet y = serialClone(x); |
496 |
> |
|
497 |
> |
assertTrue(x != y); |
498 |
> |
assertEquals(x.size(), y.size()); |
499 |
> |
assertEquals(x, y); |
500 |
> |
assertEquals(y, x); |
501 |
> |
while (!x.isEmpty()) { |
502 |
> |
assertFalse(y.isEmpty()); |
503 |
> |
assertEquals(x.pollFirst(), y.pollFirst()); |
504 |
> |
} |
505 |
> |
assertTrue(y.isEmpty()); |
506 |
|
} |
507 |
|
|
508 |
|
/** |
991 |
|
* A deserialized serialized set has same elements |
992 |
|
*/ |
993 |
|
public void testDescendingSerialization() throws Exception { |
994 |
< |
NavigableSet q = populatedSet(SIZE); |
995 |
< |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
996 |
< |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
997 |
< |
out.writeObject(q); |
998 |
< |
out.close(); |
999 |
< |
|
1000 |
< |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
1001 |
< |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
1002 |
< |
NavigableSet r = (NavigableSet)in.readObject(); |
1003 |
< |
assertEquals(q.size(), r.size()); |
1004 |
< |
while (!q.isEmpty()) |
1005 |
< |
assertEquals(q.pollFirst(), r.pollFirst()); |
994 |
> |
NavigableSet x = dset5(); |
995 |
> |
NavigableSet y = serialClone(x); |
996 |
> |
|
997 |
> |
assertTrue(x != y); |
998 |
> |
assertEquals(x.size(), y.size()); |
999 |
> |
assertEquals(x, y); |
1000 |
> |
assertEquals(y, x); |
1001 |
> |
while (!x.isEmpty()) { |
1002 |
> |
assertFalse(y.isEmpty()); |
1003 |
> |
assertEquals(x.pollFirst(), y.pollFirst()); |
1004 |
> |
} |
1005 |
> |
assertTrue(y.isEmpty()); |
1006 |
|
} |
1007 |
|
|
1008 |
|
/** |