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

Comparing jsr166/src/test/tck/AtomicBooleanTest.java (file contents):
Revision 1.1 by dl, Sun Aug 31 19:24:52 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 AtomicBooleanTest extends TestCase {
13      public static void main (String[] args) {
# Line 65 | Line 66 | public class AtomicBooleanTest extends T
66          assertEquals(true,ai.get());
67      }
68  
69 +    public void testSerialization() {
70 +        AtomicBoolean l = new AtomicBoolean();
71 +
72 +        try {
73 +            l.set(true);
74 +            ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
75 +            ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
76 +            out.writeObject(l);
77 +            out.close();
78 +
79 +            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
80 +            ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
81 +            AtomicBoolean r = (AtomicBoolean) in.readObject();
82 +            assertEquals(l.get(), r.get());
83 +        } catch(Exception e){
84 +            e.printStackTrace();
85 +            fail("unexpected exception");
86 +        }
87 +    }
88 +
89  
90   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines