--- jsr166/src/test/tck/AtomicLongFieldUpdaterTest.java 2013/04/01 20:58:58 1.24 +++ jsr166/src/test/tck/AtomicLongFieldUpdaterTest.java 2014/12/31 19:21:20 1.28 @@ -6,9 +6,11 @@ * Pat Fisher, Mike Judd. */ -import junit.framework.*; import java.util.concurrent.atomic.AtomicLongFieldUpdater; +import junit.framework.Test; +import junit.framework.TestSuite; + public class AtomicLongFieldUpdaterTest extends JSR166TestCase { volatile long x = 0; int z; @@ -33,27 +35,29 @@ public class AtomicLongFieldUpdaterTest try { updaterFor("y"); shouldThrow(); - } catch (RuntimeException success) {} + } catch (RuntimeException success) { + assertNotNull(success.getCause()); + } } /** - * construction with field not of given type throws RuntimeException + * construction with field not of given type throws IllegalArgumentException */ public void testConstructor2() { try { updaterFor("z"); shouldThrow(); - } catch (RuntimeException success) {} + } catch (IllegalArgumentException success) {} } /** - * construction with non-volatile field throws RuntimeException + * construction with non-volatile field throws IllegalArgumentException */ public void testConstructor3() { try { updaterFor("w"); shouldThrow(); - } catch (RuntimeException success) {} + } catch (IllegalArgumentException success) {} } /** @@ -130,10 +134,10 @@ public class AtomicLongFieldUpdaterTest AtomicLongFieldUpdater a; a = updaterFor("x"); x = 1; - while (!a.weakCompareAndSet(this, 1, 2)); - while (!a.weakCompareAndSet(this, 2, -4)); + do {} while (!a.weakCompareAndSet(this, 1, 2)); + do {} while (!a.weakCompareAndSet(this, 2, -4)); assertEquals(-4, a.get(this)); - while (!a.weakCompareAndSet(this, -4, 7)); + do {} while (!a.weakCompareAndSet(this, -4, 7)); assertEquals(7, a.get(this)); }