8 |
|
import junit.framework.*; |
9 |
|
import java.util.*; |
10 |
|
import java.util.concurrent.*; |
11 |
+ |
import java.io.*; |
12 |
|
|
13 |
|
public class ConcurrentLinkedQueueTest extends TestCase { |
14 |
|
private static final int N = 10; |
224 |
|
assertTrue(q.remove(new Integer(i))); |
225 |
|
assertFalse(q.remove(new Integer(i+1))); |
226 |
|
} |
227 |
< |
assert(q.isEmpty()); |
227 |
> |
assertTrue(q.isEmpty()); |
228 |
|
} |
229 |
|
|
230 |
|
public void testContains(){ |
380 |
|
} |
381 |
|
} |
382 |
|
|
383 |
+ |
public void testSerialization() { |
384 |
+ |
ConcurrentLinkedQueue q = fullQueue(N); |
385 |
+ |
try { |
386 |
+ |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
387 |
+ |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
388 |
+ |
out.writeObject(q); |
389 |
+ |
out.close(); |
390 |
+ |
|
391 |
+ |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
392 |
+ |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
393 |
+ |
ConcurrentLinkedQueue r = (ConcurrentLinkedQueue)in.readObject(); |
394 |
+ |
assertEquals(q.size(), r.size()); |
395 |
+ |
while (!q.isEmpty()) |
396 |
+ |
assertEquals(q.remove(), r.remove()); |
397 |
+ |
} catch(Exception e){ |
398 |
+ |
e.printStackTrace(); |
399 |
+ |
fail("unexpected exception"); |
400 |
+ |
} |
401 |
+ |
} |
402 |
+ |
|
403 |
|
} |