--- jsr166/src/test/tck/AtomicReferenceFieldUpdaterTest.java 2013/04/02 16:14:39 1.28 +++ jsr166/src/test/tck/AtomicReferenceFieldUpdaterTest.java 2015/04/25 04:55:30 1.33 @@ -6,9 +6,11 @@ * Pat Fisher, Mike Judd. */ -import junit.framework.*; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; +import junit.framework.Test; +import junit.framework.TestSuite; + public class AtomicReferenceFieldUpdaterTest extends JSR166TestCase { volatile Integer x = null; Object z; @@ -16,7 +18,7 @@ public class AtomicReferenceFieldUpdater volatile int i; public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); + main(suite(), args); } public static Test suite() { return new TestSuite(AtomicReferenceFieldUpdaterTest.class); @@ -35,7 +37,7 @@ public class AtomicReferenceFieldUpdater updaterFor("y"); shouldThrow(); } catch (RuntimeException success) { - assertTrue(success.getCause() != null); + assertNotNull(success.getCause()); } } @@ -73,7 +75,7 @@ public class AtomicReferenceFieldUpdater * get returns the last value set or assigned */ public void testGetSet() { - AtomicReferenceFieldUpdatera; + AtomicReferenceFieldUpdater a; a = updaterFor("x"); x = one; assertSame(one, a.get(this)); @@ -87,7 +89,7 @@ public class AtomicReferenceFieldUpdater * get returns the last value lazySet by same thread */ public void testGetLazySet() { - AtomicReferenceFieldUpdatera; + AtomicReferenceFieldUpdater a; a = updaterFor("x"); x = one; assertSame(one, a.get(this)); @@ -101,7 +103,7 @@ public class AtomicReferenceFieldUpdater * compareAndSet succeeds in changing value if equal to expected else fails */ public void testCompareAndSet() { - AtomicReferenceFieldUpdatera; + AtomicReferenceFieldUpdater a; a = updaterFor("x"); x = one; assertTrue(a.compareAndSet(this, one, two)); @@ -119,7 +121,7 @@ public class AtomicReferenceFieldUpdater */ public void testCompareAndSetInMultipleThreads() throws Exception { x = one; - final AtomicReferenceFieldUpdatera; + final AtomicReferenceFieldUpdater a; a = updaterFor("x"); Thread t = new Thread(new CheckedRunnable() { @@ -140,13 +142,13 @@ public class AtomicReferenceFieldUpdater * to expected */ public void testWeakCompareAndSet() { - AtomicReferenceFieldUpdatera; + AtomicReferenceFieldUpdater a; a = updaterFor("x"); x = one; - while (!a.weakCompareAndSet(this, one, two)); - while (!a.weakCompareAndSet(this, two, m4)); + do {} while (!a.weakCompareAndSet(this, one, two)); + do {} while (!a.weakCompareAndSet(this, two, m4)); assertSame(m4, a.get(this)); - while (!a.weakCompareAndSet(this, m4, seven)); + do {} while (!a.weakCompareAndSet(this, m4, seven)); assertSame(seven, a.get(this)); } @@ -154,7 +156,7 @@ public class AtomicReferenceFieldUpdater * getAndSet returns previous value and sets to given value */ public void testGetAndSet() { - AtomicReferenceFieldUpdatera; + AtomicReferenceFieldUpdater a; a = updaterFor("x"); x = one; assertSame(one, a.getAndSet(this, zero));