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

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

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

revision 1.23, Fri May 27 19:26:42 2011 UTC revision 1.24, Tue May 31 16:16:23 2011 UTC
# Line 5  Line 5 
5   */   */
6    
7  import junit.framework.*;  import junit.framework.*;
8  import java.io.BufferedInputStream;  import java.util.Arrays;
9  import java.io.BufferedOutputStream;  import java.util.ArrayDeque;
10  import java.io.ByteArrayInputStream;  import java.util.Collection;
11  import java.io.ByteArrayOutputStream;  import java.util.Deque;
12  import java.io.ObjectInputStream;  import java.util.Iterator;
13  import java.io.ObjectOutputStream;  import java.util.NoSuchElementException;
14  import java.util.*;  import java.util.Queue;
15    import java.util.Random;
16    
17  public class ArrayDequeTest extends JSR166TestCase {  public class ArrayDequeTest extends JSR166TestCase {
18      public static void main(String[] args) {      public static void main(String[] args) {
# Line 811  Line 812 
812       * A deserialized serialized deque has same elements in same order       * A deserialized serialized deque has same elements in same order
813       */       */
814      public void testSerialization() throws Exception {      public void testSerialization() throws Exception {
815          ArrayDeque q = populatedDeque(SIZE);          Queue x = populatedDeque(SIZE);
816          ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);          Queue y = serialClone(x);
817          ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));  
818          out.writeObject(q);          assertTrue(x != y);
819          out.close();          assertEquals(x.size(), y.size());
820            assertEquals(x.toString(), y.toString());
821          ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());          assertTrue(Arrays.equals(x.toArray(), y.toArray()));
822          ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));          while (!x.isEmpty()) {
823          ArrayDeque r = (ArrayDeque)in.readObject();              assertFalse(y.isEmpty());
824          assertEquals(q.size(), r.size());              assertEquals(x.remove(), y.remove());
825          while (!q.isEmpty())          }
826              assertEquals(q.remove(), r.remove());          assertTrue(y.isEmpty());
827      }      }
828    
829  }  }

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8