10 |
|
import java.util.Collection; |
11 |
|
import java.util.Iterator; |
12 |
|
import java.util.NoSuchElementException; |
13 |
+ |
import java.util.Queue; |
14 |
|
import java.util.concurrent.BlockingDeque; |
15 |
|
import java.util.concurrent.BlockingQueue; |
16 |
|
import java.util.concurrent.CountDownLatch; |
18 |
|
import java.util.concurrent.ExecutorService; |
19 |
|
import java.util.concurrent.LinkedBlockingDeque; |
20 |
|
import static java.util.concurrent.TimeUnit.MILLISECONDS; |
20 |
– |
import java.io.*; |
21 |
|
|
22 |
|
public class LinkedBlockingDequeTest extends JSR166TestCase { |
23 |
|
|
1718 |
|
* A deserialized serialized deque has same elements in same order |
1719 |
|
*/ |
1720 |
|
public void testSerialization() throws Exception { |
1721 |
< |
LinkedBlockingDeque q = populatedDeque(SIZE); |
1721 |
> |
Queue x = populatedDeque(SIZE); |
1722 |
> |
Queue y = serialClone(x); |
1723 |
|
|
1724 |
< |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
1725 |
< |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
1726 |
< |
out.writeObject(q); |
1727 |
< |
out.close(); |
1728 |
< |
|
1729 |
< |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
1730 |
< |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
1731 |
< |
LinkedBlockingDeque r = (LinkedBlockingDeque)in.readObject(); |
1732 |
< |
assertEquals(q.size(), r.size()); |
1732 |
< |
while (!q.isEmpty()) |
1733 |
< |
assertEquals(q.remove(), r.remove()); |
1724 |
> |
assertTrue(x != y); |
1725 |
> |
assertEquals(x.size(), y.size()); |
1726 |
> |
assertEquals(x.toString(), y.toString()); |
1727 |
> |
assertTrue(Arrays.equals(x.toArray(), y.toArray())); |
1728 |
> |
while (!x.isEmpty()) { |
1729 |
> |
assertFalse(y.isEmpty()); |
1730 |
> |
assertEquals(x.remove(), y.remove()); |
1731 |
> |
} |
1732 |
> |
assertTrue(y.isEmpty()); |
1733 |
|
} |
1734 |
|
|
1735 |
|
/** |