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.1 by dl, Sun Aug 31 19:24:54 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 CopyOnWriteArrayListTest extends TestCase{
14      
# Line 532 | Line 533 | public class CopyOnWriteArrayListTest ex
533              fail("List subList(int, int) should throw IndexOutofBounds exception");
534          }catch(IndexOutOfBoundsException e){}
535      }
536 +
537 +    public void testSerialization() {
538 +        CopyOnWriteArrayList q = fullArray(10);
539 +
540 +        try {
541 +            ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
542 +            ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
543 +            out.writeObject(q);
544 +            out.close();
545 +
546 +            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
547 +            ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
548 +            CopyOnWriteArrayList r = (CopyOnWriteArrayList)in.readObject();
549 +            assertEquals(q.size(), r.size());
550 +            assertTrue(q.equals(r));
551 +            assertTrue(r.equals(q));
552 +        } catch(Exception e){
553 +            e.printStackTrace();
554 +            fail("unexpected exception");
555 +        }
556 +    }
557      
558   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines