--- jsr166/src/test/tck/AtomicIntegerArrayTest.java 2003/08/31 19:24:52 1.1 +++ jsr166/src/test/tck/AtomicIntegerArrayTest.java 2003/09/07 20:39:11 1.2 @@ -7,6 +7,7 @@ import junit.framework.*; import java.util.concurrent.atomic.*; +import java.io.*; public class AtomicIntegerArrayTest extends TestCase { @@ -144,4 +145,27 @@ public class AtomicIntegerArrayTest exte } } + public void testSerialization() { + AtomicIntegerArray l = new AtomicIntegerArray(N); + for (int i = 0; i < N; ++i) + l.set(i, -i); + + try { + 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)); + AtomicIntegerArray r = (AtomicIntegerArray) in.readObject(); + for (int i = 0; i < N; ++i) { + assertEquals(l.get(i), r.get(i)); + } + } catch(Exception e){ + e.printStackTrace(); + fail("unexpected exception"); + } + } + }