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

Comparing jsr166/src/test/tck/AtomicLongTest.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 AtomicLongTest extends TestCase {
13      public static void main (String[] args) {
# Line 115 | Line 116 | public class AtomicLongTest extends Test
116          assertEquals(1,ai.get());
117      }
118  
119 +    public void testSerialization() {
120 +        AtomicLong l = new AtomicLong();
121 +
122 +        try {
123 +            l.set(-22);
124 +            ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
125 +            ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
126 +            out.writeObject(l);
127 +            out.close();
128 +
129 +            ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
130 +            ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
131 +            AtomicLong r = (AtomicLong) in.readObject();
132 +            assertEquals(l.get(), r.get());
133 +        } catch(Exception e){
134 +            e.printStackTrace();
135 +            fail("unexpected exception");
136 +        }
137 +    }
138  
139   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines