ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/test/tck/LinkedBlockingQueueTest.java
(Generate patch)

Comparing jsr166/src/test/tck/LinkedBlockingQueueTest.java (file contents):
Revision 1.1 by dl, Sun Aug 31 19:24:55 2003 UTC vs.
Revision 1.2 by dl, Sun Sep 7 20:39:11 2003 UTC

# Line 8 | Line 8
8   import junit.framework.*;
9   import java.util.*;
10   import java.util.concurrent.*;
11 + import java.io.*;
12  
13   public class LinkedBlockingQueueTest extends TestCase {
14  
# Line 488 | Line 489 | public class LinkedBlockingQueueTest ext
489              assertTrue(q.remove(new Integer(i)));
490              assertFalse(q.remove(new Integer(i+1)));
491          }
492 <        assert(q.isEmpty());
492 >        assertTrue(q.isEmpty());
493      }
494          
495      public void testContains(){
# Line 711 | Line 712 | public class LinkedBlockingQueueTest ext
712  
713      }
714  
715 +    public void testSerialization() {
716 +        LinkedBlockingQueue q = fullQueue(N);
717 +
718 +        try {
719 +            ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
720 +            ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
721 +            out.writeObject(q);
722 +            out.close();
723 +
724 +            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
725 +            ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
726 +            LinkedBlockingQueue r = (LinkedBlockingQueue)in.readObject();
727 +            assertEquals(q.size(), r.size());
728 +            while (!q.isEmpty())
729 +                assertEquals(q.remove(), r.remove());
730 +        } catch(Exception e){
731 +            e.printStackTrace();
732 +            fail("unexpected exception");
733 +        }
734 +    }
735 +
736   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines