13 |
|
import java.util.Comparator; |
14 |
|
import java.util.Iterator; |
15 |
|
import java.util.NoSuchElementException; |
16 |
+ |
import java.util.Queue; |
17 |
|
import java.util.concurrent.PriorityBlockingQueue; |
18 |
|
import java.util.concurrent.BlockingQueue; |
19 |
|
import java.util.concurrent.CountDownLatch; |
20 |
|
import java.util.concurrent.Executors; |
21 |
|
import java.util.concurrent.ExecutorService; |
22 |
|
import static java.util.concurrent.TimeUnit.MILLISECONDS; |
22 |
– |
import java.io.*; |
23 |
|
|
24 |
|
public class PriorityBlockingQueueTest extends JSR166TestCase { |
25 |
|
|
662 |
|
* A deserialized serialized queue has same elements |
663 |
|
*/ |
664 |
|
public void testSerialization() throws Exception { |
665 |
< |
PriorityBlockingQueue q = populatedQueue(SIZE); |
666 |
< |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
667 |
< |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
668 |
< |
out.writeObject(q); |
669 |
< |
out.close(); |
670 |
< |
|
671 |
< |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
672 |
< |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
673 |
< |
PriorityBlockingQueue r = (PriorityBlockingQueue)in.readObject(); |
674 |
< |
assertEquals(q.size(), r.size()); |
675 |
< |
while (!q.isEmpty()) |
676 |
< |
assertEquals(q.remove(), r.remove()); |
665 |
> |
Queue x = populatedQueue(SIZE); |
666 |
> |
Queue y = serialClone(x); |
667 |
> |
|
668 |
> |
assertTrue(x != y); |
669 |
> |
assertEquals(x.size(), y.size()); |
670 |
> |
while (!x.isEmpty()) { |
671 |
> |
assertFalse(y.isEmpty()); |
672 |
> |
assertEquals(x.remove(), y.remove()); |
673 |
> |
} |
674 |
> |
assertTrue(y.isEmpty()); |
675 |
|
} |
676 |
|
|
677 |
|
/** |