[cvs] / jsr166 / src / test / tck / ArrayBlockingQueueTest.java Repository:
ViewVC logotype

Diff of /jsr166/src/test/tck/ArrayBlockingQueueTest.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.48, Mon May 30 22:43:20 2011 UTC revision 1.49, Tue May 31 16:16:23 2011 UTC
# Line 12  Line 12 
12  import java.util.Collection;  import java.util.Collection;
13  import java.util.Iterator;  import java.util.Iterator;
14  import java.util.NoSuchElementException;  import java.util.NoSuchElementException;
15    import java.util.Queue;
16  import java.util.concurrent.ArrayBlockingQueue;  import java.util.concurrent.ArrayBlockingQueue;
17  import java.util.concurrent.BlockingQueue;  import java.util.concurrent.BlockingQueue;
18  import java.util.concurrent.CountDownLatch;  import java.util.concurrent.CountDownLatch;
19  import java.util.concurrent.Executors;  import java.util.concurrent.Executors;
20  import java.util.concurrent.ExecutorService;  import java.util.concurrent.ExecutorService;
21  import static java.util.concurrent.TimeUnit.MILLISECONDS;  import static java.util.concurrent.TimeUnit.MILLISECONDS;
 import java.io.*;  
22    
23  public class ArrayBlockingQueueTest extends JSR166TestCase {  public class ArrayBlockingQueueTest extends JSR166TestCase {
24    
# Line 768  Line 768 
768       * A deserialized serialized queue has same elements in same order       * A deserialized serialized queue has same elements in same order
769       */       */
770      public void testSerialization() throws Exception {      public void testSerialization() throws Exception {
771          ArrayBlockingQueue q = populatedQueue(SIZE);          Queue x = populatedQueue(SIZE);
772            Queue y = serialClone(x);
773    
774          ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);          assertTrue(x != y);
775          ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));          assertEquals(x.size(), y.size());
776          out.writeObject(q);          assertEquals(x.toString(), y.toString());
777          out.close();          assertTrue(Arrays.equals(x.toArray(), y.toArray()));
778            while (!x.isEmpty()) {
779          ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());              assertFalse(y.isEmpty());
780          ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));              assertEquals(x.remove(), y.remove());
781          ArrayBlockingQueue r = (ArrayBlockingQueue)in.readObject();          }
782          assertEquals(q.size(), r.size());          assertTrue(y.isEmpty());
         while (!q.isEmpty())  
             assertEquals(q.remove(), r.remove());  
783      }      }
784    
785      /**      /**

Legend:
Removed from v.1.48  
changed lines
  Added in v.1.49

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8