--- jsr166/src/test/tck/AtomicLongArrayTest.java 2010/10/09 19:30:34 1.18 +++ jsr166/src/test/tck/AtomicLongArrayTest.java 2011/05/31 16:16:23 1.21 @@ -1,15 +1,14 @@ /* * 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.*; +import java.util.Arrays; +import java.util.concurrent.atomic.AtomicLongArray; public class AtomicLongArrayTest extends JSR166TestCase { public static void main(String[] args) { @@ -309,20 +308,14 @@ public class AtomicLongArrayTest extends * a deserialized serialized array holds same values */ public void testSerialization() throws Exception { - AtomicLongArray l = new AtomicLongArray(SIZE); + AtomicLongArray x = new AtomicLongArray(SIZE); for (int i = 0; i < SIZE; ++i) - l.set(i, -i); - - 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)); - AtomicLongArray r = (AtomicLongArray) in.readObject(); + x.set(i, -i); + AtomicLongArray y = serialClone(x); + assertTrue(x != y); + assertEquals(x.length(), y.length()); for (int i = 0; i < SIZE; ++i) { - assertEquals(l.get(i), r.get(i)); + assertEquals(x.get(i), y.get(i)); } } @@ -335,5 +328,4 @@ public class AtomicLongArrayTest extends assertEquals(Arrays.toString(a), ai.toString()); } - }