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.17 by jsr166, Sun Nov 22 18:55:56 2009 UTC vs.
Revision 1.22 by jsr166, Tue May 31 16:16:23 2011 UTC

# Line 1 | Line 1
1   /*
2   * Written by Doug Lea with assistance from members of JCP JSR-166
3   * Expert Group and released to the public domain, as explained at
4 < * http://creativecommons.org/licenses/publicdomain
4 > * http://creativecommons.org/publicdomain/zero/1.0/
5   * Other contributors include Andrew Wright, Jeffrey Hayes,
6   * Pat Fisher, Mike Judd.
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) {
14 <        junit.textui.TestRunner.run (suite());
13 >    public static void main(String[] args) {
14 >        junit.textui.TestRunner.run(suite());
15      }
16      public static Test suite() {
17          return new TestSuite(AtomicLongTest.class);
# Line 73 | Line 72 | public class AtomicLongTest extends JSR1
72          assertTrue(ai.compareAndSet(2,-4));
73          assertEquals(-4,ai.get());
74          assertFalse(ai.compareAndSet(-5,7));
75 <        assertFalse((7 == ai.get()));
75 >        assertEquals(-4,ai.get());
76          assertTrue(ai.compareAndSet(-4,7));
77          assertEquals(7,ai.get());
78      }
# 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      /**
# Line 241 | Line 236 | public class AtomicLongTest extends JSR1
236          assertEquals(0L, ai.longValue());
237          for (long x : VALUES) {
238              ai.set(x);
239 <            assertEquals((long)x, ai.longValue());
239 >            assertEquals(x, ai.longValue());
240          }
241      }
242  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines