--- jsr166/src/test/tck/AtomicReferenceTest.java 2009/12/01 09:56:28 1.15 +++ jsr166/src/test/tck/AtomicReferenceTest.java 2011/05/31 16:16:23 1.18 @@ -1,18 +1,17 @@ /* * Written by Doug Lea with assistance from members of JCP JSR-166 * Expert Group and released to the public domain, as explained at - * http://creativecommons.org/licenses/publicdomain + * http://creativecommons.org/publicdomain/zero/1.0/ * Other contributors include Andrew Wright, Jeffrey Hayes, * Pat Fisher, Mike Judd. */ import junit.framework.*; -import java.util.concurrent.atomic.*; -import java.io.*; +import java.util.concurrent.atomic.AtomicReference; public class AtomicReferenceTest extends JSR166TestCase { - public static void main (String[] args) { - junit.textui.TestRunner.run (suite()); + public static void main(String[] args) { + junit.textui.TestRunner.run(suite()); } public static Test suite() { return new TestSuite(AtomicReferenceTest.class); @@ -118,18 +117,14 @@ public class AtomicReferenceTest extends * a deserialized serialized atomic holds same value */ public void testSerialization() throws Exception { - AtomicReference l = new AtomicReference(); - - l.set(one); - ByteArrayOutputStream bout = new ByteArrayOutputStream(10000); - ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(bout)); - out.writeObject(l); - out.close(); - - ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray()); - ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(bin)); - AtomicReference r = (AtomicReference) in.readObject(); - assertEquals(l.get(), r.get()); + AtomicReference x = new AtomicReference(); + AtomicReference y = serialClone(x); + assertTrue(x != y); + x.set(one); + AtomicReference z = serialClone(x); + assertEquals(one, x.get()); + assertEquals(null, y.get()); + assertEquals(one, z.get()); } /**