8 |
|
import junit.framework.*; |
9 |
|
import java.util.*; |
10 |
|
import java.util.concurrent.*; |
11 |
+ |
import java.io.*; |
12 |
|
|
13 |
|
public class SynchronousQueueTest extends TestCase { |
14 |
|
|
289 |
|
for (int i = 1; i < N; i+=2) { |
290 |
|
assertFalse(q.remove(new Integer(i))); |
291 |
|
} |
292 |
< |
assert(q.isEmpty()); |
292 |
> |
assertTrue(q.isEmpty()); |
293 |
|
} |
294 |
|
|
295 |
|
public void testContains(){ |
441 |
|
|
442 |
|
} |
443 |
|
|
444 |
+ |
public void testSerialization() { |
445 |
+ |
SynchronousQueue q = new SynchronousQueue(); |
446 |
+ |
try { |
447 |
+ |
ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); |
448 |
+ |
ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); |
449 |
+ |
out.writeObject(q); |
450 |
+ |
out.close(); |
451 |
+ |
|
452 |
+ |
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); |
453 |
+ |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); |
454 |
+ |
SynchronousQueue r = (SynchronousQueue)in.readObject(); |
455 |
+ |
assertEquals(q.size(), r.size()); |
456 |
+ |
while (!q.isEmpty()) |
457 |
+ |
assertEquals(q.remove(), r.remove()); |
458 |
+ |
} catch(Exception e){ |
459 |
+ |
fail("unexpected exception"); |
460 |
+ |
} |
461 |
+ |
} |
462 |
+ |
|
463 |
|
} |