--- jsr166/src/test/tck/AtomicLongTest.java 2009/11/16 05:30:07 1.13 +++ jsr166/src/test/tck/AtomicLongTest.java 2009/11/17 03:12:51 1.14 @@ -78,22 +78,18 @@ public class AtomicLongTest extends JSR1 * compareAndSet in one thread enables another waiting for value * to succeed */ - public void testCompareAndSetInMultipleThreads() { + public void testCompareAndSetInMultipleThreads() throws Exception { final AtomicLong ai = new AtomicLong(1); Thread t = new Thread(new Runnable() { public void run() { while (!ai.compareAndSet(2, 3)) Thread.yield(); }}); - try { - t.start(); - assertTrue(ai.compareAndSet(1, 2)); - t.join(LONG_DELAY_MS); - assertFalse(t.isAlive()); - assertEquals(ai.get(), 3); - } - catch (Exception e) { - unexpectedException(); - } + + t.start(); + assertTrue(ai.compareAndSet(1, 2)); + t.join(LONG_DELAY_MS); + assertFalse(t.isAlive()); + assertEquals(ai.get(), 3); } /** @@ -193,23 +189,19 @@ public class AtomicLongTest extends JSR1 /** * a deserialized serialized atomic holds same value */ - public void testSerialization() { + public void testSerialization() throws Exception { 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) { - unexpectedException(); - } + 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()); } /**