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

Comparing jsr166/src/test/tck/CopyOnWriteArrayListTest.java (file contents):
Revision 1.21 by jsr166, Sun May 29 13:45:35 2011 UTC vs.
Revision 1.22 by jsr166, Tue May 31 16:16:23 2011 UTC

# Line 7 | Line 7
7   */
8  
9   import junit.framework.*;
10 < import java.util.*;
11 < import java.util.concurrent.*;
12 < import java.io.*;
10 > import java.util.Arrays;
11 > import java.util.Iterator;
12 > import java.util.LinkedList;
13 > import java.util.List;
14 > import java.util.ListIterator;
15 > import java.util.Vector;
16 > import java.util.concurrent.CopyOnWriteArrayList;
17  
18   public class CopyOnWriteArrayListTest extends JSR166TestCase {
19  
# Line 596 | Line 600 | public class CopyOnWriteArrayListTest ex
600       * a deserialized serialized list is equal
601       */
602      public void testSerialization() throws Exception {
603 <        CopyOnWriteArrayList q = populatedArray(SIZE);
603 >        List x = populatedArray(SIZE);
604 >        List y = serialClone(x);
605  
606 <        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
607 <        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
608 <        out.writeObject(q);
609 <        out.close();
610 <
611 <        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
612 <        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
613 <        CopyOnWriteArrayList r = (CopyOnWriteArrayList)in.readObject();
614 <        assertEquals(q.size(), r.size());
615 <        assertTrue(q.equals(r));
616 <        assertTrue(r.equals(q));
606 >        assertTrue(x != y);
607 >        assertEquals(x.size(), y.size());
608 >        assertEquals(x.toString(), y.toString());
609 >        assertTrue(Arrays.equals(x.toArray(), y.toArray()));
610 >        assertEquals(x, y);
611 >        assertEquals(y, x);
612 >        while (!x.isEmpty()) {
613 >            assertFalse(y.isEmpty());
614 >            assertEquals(x.remove(0), y.remove(0));
615 >        }
616 >        assertTrue(y.isEmpty());
617      }
618  
619   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines