--- jsr166/src/test/tck/LinkedBlockingQueueTest.java 2003/08/31 19:24:55 1.1 +++ jsr166/src/test/tck/LinkedBlockingQueueTest.java 2003/09/07 20:39:11 1.2 @@ -8,6 +8,7 @@ import junit.framework.*; import java.util.*; import java.util.concurrent.*; +import java.io.*; public class LinkedBlockingQueueTest extends TestCase { @@ -488,7 +489,7 @@ public class LinkedBlockingQueueTest ext assertTrue(q.remove(new Integer(i))); assertFalse(q.remove(new Integer(i+1))); } - assert(q.isEmpty()); + assertTrue(q.isEmpty()); } public void testContains(){ @@ -711,4 +712,25 @@ public class LinkedBlockingQueueTest ext } + public void testSerialization() { + LinkedBlockingQueue q = fullQueue(N); + + try { + ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); + ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); + out.writeObject(q); + out.close(); + + ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); + ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); + LinkedBlockingQueue r = (LinkedBlockingQueue)in.readObject(); + assertEquals(q.size(), r.size()); + while (!q.isEmpty()) + assertEquals(q.remove(), r.remove()); + } catch(Exception e){ + e.printStackTrace(); + fail("unexpected exception"); + } + } + }