--- jsr166/src/test/tck/AtomicLongTest.java 2003/08/31 19:24:53 1.1 +++ jsr166/src/test/tck/AtomicLongTest.java 2003/09/14 20:42:40 1.3 @@ -7,8 +7,9 @@ import junit.framework.*; import java.util.concurrent.atomic.*; +import java.io.*; -public class AtomicLongTest extends TestCase { +public class AtomicLongTest extends JSR166TestCase { public static void main (String[] args) { junit.textui.TestRunner.run (suite()); } @@ -115,5 +116,24 @@ public class AtomicLongTest extends Test assertEquals(1,ai.get()); } + public void testSerialization() { + AtomicLong l = new AtomicLong(); + + try { + l.set(-22); + 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)); + AtomicLong r = (AtomicLong) in.readObject(); + assertEquals(l.get(), r.get()); + } catch(Exception e){ + e.printStackTrace(); + fail("unexpected exception"); + } + } }