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.21 by jsr166, Fri May 27 16:43:23 2011 UTC vs.
Revision 1.22 by jsr166, Tue May 31 16:16:23 2011 UTC

# Line 7 | Line 7
7   */
8  
9   import junit.framework.*;
10 < import java.util.concurrent.atomic.*;
11 < import java.io.*;
10 > import java.util.concurrent.atomic.AtomicLong;
11  
12   public class AtomicLongTest extends JSR166TestCase {
13      public static void main(String[] args) {
# Line 195 | Line 194 | public class AtomicLongTest extends JSR1
194       * a deserialized serialized atomic holds same value
195       */
196      public void testSerialization() throws Exception {
197 <        AtomicLong l = new AtomicLong();
198 <
199 <        l.set(-22);
200 <        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
201 <        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
202 <        out.writeObject(l);
203 <        out.close();
204 <
206 <        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
207 <        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
208 <        AtomicLong r = (AtomicLong) in.readObject();
209 <        assertEquals(l.get(), r.get());
197 >        AtomicLong x = new AtomicLong();
198 >        AtomicLong y = serialClone(x);
199 >        assertTrue(x != y);
200 >        x.set(-22);
201 >        AtomicLong z = serialClone(x);
202 >        assertEquals(-22, x.get());
203 >        assertEquals(0, y.get());
204 >        assertEquals(-22, z.get());
205      }
206  
207      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines