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.17 by jsr166, Tue Mar 15 19:47:06 2011 UTC vs.
Revision 1.18 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.AtomicReference;
11  
12   public class AtomicReferenceTest extends JSR166TestCase {
13      public static void main(String[] args) {
# Line 118 | Line 117 | public class AtomicReferenceTest extends
117       * a deserialized serialized atomic holds same value
118       */
119      public void testSerialization() throws Exception {
120 <        AtomicReference l = new AtomicReference();
121 <
122 <        l.set(one);
123 <        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
124 <        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
125 <        out.writeObject(l);
126 <        out.close();
127 <
129 <        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
130 <        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
131 <        AtomicReference r = (AtomicReference) in.readObject();
132 <        assertEquals(l.get(), r.get());
120 >        AtomicReference x = new AtomicReference();
121 >        AtomicReference y = serialClone(x);
122 >        assertTrue(x != y);
123 >        x.set(one);
124 >        AtomicReference z = serialClone(x);
125 >        assertEquals(one, x.get());
126 >        assertEquals(null, y.get());
127 >        assertEquals(one, z.get());
128      }
129  
130      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines