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

Comparing jsr166/src/test/tck/AtomicReferenceTest.java (file contents):
Revision 1.1 by dl, Sun Aug 31 19:24:53 2003 UTC vs.
Revision 1.2 by dl, Sun Sep 7 20:39:11 2003 UTC

# Line 7 | Line 7
7  
8   import junit.framework.*;
9   import java.util.concurrent.atomic.*;
10 + import java.io.*;
11  
12   public class AtomicReferenceTest extends TestCase {
13      public static void main (String[] args) {
# Line 71 | Line 72 | public class AtomicReferenceTest extends
72          assertEquals(m10,ai.getAndSet(one));
73      }
74  
75 +    public void testSerialization() {
76 +        AtomicReference l = new AtomicReference();
77 +
78 +        try {
79 +            l.set(one);
80 +            ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
81 +            ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
82 +            out.writeObject(l);
83 +            out.close();
84 +
85 +            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
86 +            ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
87 +            AtomicReference r = (AtomicReference) in.readObject();
88 +            assertEquals(l.get(), r.get());
89 +        } catch(Exception e){
90 +            e.printStackTrace();
91 +            fail("unexpected exception");
92 +        }
93 +    }
94 +
95   }
96  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines