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

Comparing jsr166/src/test/tck/AtomicIntegerTest.java (file contents):
Revision 1.21 by jsr166, Tue Mar 15 19:47:06 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.AtomicInteger;
11  
12   public class AtomicIntegerTest extends JSR166TestCase {
13      public static void main(String[] args) {
# Line 193 | Line 192 | public class AtomicIntegerTest extends J
192       * a deserialized serialized atomic holds same value
193       */
194      public void testSerialization() throws Exception {
195 <        AtomicInteger l = new AtomicInteger();
196 <
197 <        l.set(22);
198 <        ByteArrayOutputStream bout = new ByteArrayOutputStream(10000);
199 <        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout));
200 <        out.writeObject(l);
201 <        out.close();
202 <
204 <        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
205 <        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin));
206 <        AtomicInteger r = (AtomicInteger) in.readObject();
207 <        assertEquals(l.get(), r.get());
195 >        AtomicInteger x = new AtomicInteger();
196 >        AtomicInteger y = serialClone(x);
197 >        assertTrue(x != y);
198 >        x.set(22);
199 >        AtomicInteger z = serialClone(x);
200 >        assertEquals(22, x.get());
201 >        assertEquals(0, y.get());
202 >        assertEquals(22, z.get());
203      }
204  
205      /**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines