8 |
|
import junit.framework.*; |
9 |
|
import java.util.*; |
10 |
|
import java.util.concurrent.*; |
11 |
+ |
import java.io.*; |
12 |
|
|
13 |
|
public class PriorityBlockingQueueTest extends TestCase { |
14 |
|
|
480 |
|
assertTrue(q.remove(new Integer(i))); |
481 |
|
assertFalse(q.remove(new Integer(i+1))); |
482 |
|
} |
483 |
< |
assert(q.isEmpty()); |
483 |
> |
assertTrue(q.isEmpty()); |
484 |
|
} |
485 |
|
|
486 |
|
public void testContains(){ |
642 |
|
|
643 |
|
} |
644 |
|
|
645 |
+ |
public void testSerialization() { |
646 |
+ |
PriorityBlockingQueue q = fullQueue(N); |
647 |
+ |
try { |
648 |
+ |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
649 |
+ |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
650 |
+ |
out.writeObject(q); |
651 |
+ |
out.close(); |
652 |
+ |
|
653 |
+ |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
654 |
+ |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
655 |
+ |
PriorityBlockingQueue r = (PriorityBlockingQueue)in.readObject(); |
656 |
+ |
assertEquals(q.size(), r.size()); |
657 |
+ |
while (!q.isEmpty()) |
658 |
+ |
assertEquals(q.remove(), r.remove()); |
659 |
+ |
} catch(Exception e){ |
660 |
+ |
fail("unexpected exception"); |
661 |
+ |
} |
662 |
+ |
} |
663 |
+ |
|
664 |
|
} |