[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.1, Sun Aug 31 19:24:52 2003 UTC revision 1.2, Sun Sep 7 20:39:11 2003 UTC
# Line 8  Line 8 
8  import junit.framework.*;  import junit.framework.*;
9  import java.util.*;  import java.util.*;
10  import java.util.concurrent.*;  import java.util.concurrent.*;
11    import java.io.*;
12    
13  public class ArrayBlockingQueueTest extends TestCase {  public class ArrayBlockingQueueTest extends TestCase {
14    
# Line 499  Line 500 
500              assertTrue(q.remove(new Integer(i)));              assertTrue(q.remove(new Integer(i)));
501              assertFalse(q.remove(new Integer(i+1)));              assertFalse(q.remove(new Integer(i+1)));
502          }          }
503          assert(q.isEmpty());          assertTrue(q.isEmpty());
504      }      }
505    
506      public void testContains(){      public void testContains(){
# Line 722  Line 723 
723    
724      }      }
725    
726        public void testSerialization() {
727            ArrayBlockingQueue q = fullQueue(N);
728    
729            try {
730                ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
731                ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
732                out.writeObject(q);
733                out.close();
734    
735                ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
736                ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
737                ArrayBlockingQueue r = (ArrayBlockingQueue)in.readObject();
738                assertEquals(q.size(), r.size());
739                while (!q.isEmpty())
740                    assertEquals(q.remove(), r.remove());
741            } catch(Exception e){
742                fail("unexpected exception");
743            }
744        }
745    
746    
747  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8