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

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

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

revision 1.1, Sun Aug 31 19:24:52 2003 UTC revision 1.2, Sun Sep 7 20:39:11 2003 UTC
# Line 7  Line 7 
7    
8  import junit.framework.*;  import junit.framework.*;
9  import java.util.concurrent.atomic.*;  import java.util.concurrent.atomic.*;
10    import java.io.*;
11    
12  public class AtomicBooleanTest extends TestCase {  public class AtomicBooleanTest extends TestCase {
13      public static void main (String[] args) {      public static void main (String[] args) {
# Line 65  Line 66 
66          assertEquals(true,ai.get());          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  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8