--- jsr166/src/test/tck/AtomicLongFieldUpdaterTest.java 2009/11/02 20:28:31 1.10 +++ jsr166/src/test/tck/AtomicLongFieldUpdaterTest.java 2009/11/17 03:12:51 1.13 @@ -15,7 +15,7 @@ public class AtomicLongFieldUpdaterTest int z; long w; - public static void main(String[] args){ + public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } public static Test suite() { @@ -25,8 +25,8 @@ public class AtomicLongFieldUpdaterTest /** * Construction with non-existent field throws RuntimeException */ - public void testConstructor(){ - try{ + public void testConstructor() { + try { AtomicLongFieldUpdater a = AtomicLongFieldUpdater.newUpdater (AtomicLongFieldUpdaterTest.class, "y"); @@ -38,8 +38,8 @@ public class AtomicLongFieldUpdaterTest /** * construction with field not of given type throws RuntimeException */ - public void testConstructor2(){ - try{ + public void testConstructor2() { + try { AtomicLongFieldUpdater a = AtomicLongFieldUpdater.newUpdater (AtomicLongFieldUpdaterTest.class, "z"); @@ -51,8 +51,8 @@ public class AtomicLongFieldUpdaterTest /** * construction with non-volatile field throws RuntimeException */ - public void testConstructor3(){ - try{ + public void testConstructor3() { + try { AtomicLongFieldUpdater a = AtomicLongFieldUpdater.newUpdater (AtomicLongFieldUpdaterTest.class, "w"); @@ -65,7 +65,7 @@ public class AtomicLongFieldUpdaterTest /** * get returns the last value set or assigned */ - public void testGetSet(){ + public void testGetSet() { AtomicLongFieldUpdater a; try { a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x"); @@ -83,7 +83,7 @@ public class AtomicLongFieldUpdaterTest /** * get returns the last value lazySet by same thread */ - public void testGetLazySet(){ + public void testGetLazySet() { AtomicLongFieldUpdater a; try { a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x"); @@ -102,7 +102,7 @@ public class AtomicLongFieldUpdaterTest /** * compareAndSet succeeds in changing value if equal to expected else fails */ - public void testCompareAndSet(){ + public void testCompareAndSet() { AtomicLongFieldUpdater a; try { a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x"); @@ -124,7 +124,7 @@ public class AtomicLongFieldUpdaterTest * compareAndSet in one thread enables another waiting for value * to succeed */ - public void testCompareAndSetInMultipleThreads() { + public void testCompareAndSetInMultipleThreads() throws Exception { x = 1; final AtomicLongFieldUpdatera; try { @@ -135,25 +135,21 @@ public class AtomicLongFieldUpdaterTest Thread t = new Thread(new Runnable() { public void run() { - while(!a.compareAndSet(AtomicLongFieldUpdaterTest.this, 2, 3)) Thread.yield(); + while (!a.compareAndSet(AtomicLongFieldUpdaterTest.this, 2, 3)) Thread.yield(); }}); - try { - t.start(); - assertTrue(a.compareAndSet(this, 1, 2)); - t.join(LONG_DELAY_MS); - assertFalse(t.isAlive()); - assertEquals(a.get(this), 3); - } - catch(Exception e) { - unexpectedException(); - } + + t.start(); + assertTrue(a.compareAndSet(this, 1, 2)); + t.join(LONG_DELAY_MS); + assertFalse(t.isAlive()); + assertEquals(a.get(this), 3); } /** * repeated weakCompareAndSet succeeds in changing value when equal * to expected */ - public void testWeakCompareAndSet(){ + public void testWeakCompareAndSet() { AtomicLongFieldUpdater a; try { a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x"); @@ -161,17 +157,17 @@ public class AtomicLongFieldUpdaterTest return; } x = 1; - while(!a.weakCompareAndSet(this,1,2)); - while(!a.weakCompareAndSet(this,2,-4)); + while (!a.weakCompareAndSet(this,1,2)); + while (!a.weakCompareAndSet(this,2,-4)); assertEquals(-4,a.get(this)); - while(!a.weakCompareAndSet(this,-4,7)); + while (!a.weakCompareAndSet(this,-4,7)); assertEquals(7,a.get(this)); } /** * getAndSet returns previous value and sets to given value */ - public void testGetAndSet(){ + public void testGetAndSet() { AtomicLongFieldUpdater a; try { a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x"); @@ -187,7 +183,7 @@ public class AtomicLongFieldUpdaterTest /** * getAndAdd returns previous value and adds given value */ - public void testGetAndAdd(){ + public void testGetAndAdd() { AtomicLongFieldUpdater a; try { a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x"); @@ -204,7 +200,7 @@ public class AtomicLongFieldUpdaterTest /** * getAndDecrement returns previous value and decrements */ - public void testGetAndDecrement(){ + public void testGetAndDecrement() { AtomicLongFieldUpdater a; try { a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x"); @@ -220,7 +216,7 @@ public class AtomicLongFieldUpdaterTest /** * getAndIncrement returns previous value and increments */ - public void testGetAndIncrement(){ + public void testGetAndIncrement() { AtomicLongFieldUpdater a; try { a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x"); @@ -240,7 +236,7 @@ public class AtomicLongFieldUpdaterTest /** * addAndGet adds given value to current, and returns current value */ - public void testAddAndGet(){ + public void testAddAndGet() { AtomicLongFieldUpdater a; try { a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x"); @@ -257,7 +253,7 @@ public class AtomicLongFieldUpdaterTest /** * decrementAndGet decrements and returns current value */ - public void testDecrementAndGet(){ + public void testDecrementAndGet() { AtomicLongFieldUpdater a; try { a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x"); @@ -274,7 +270,7 @@ public class AtomicLongFieldUpdaterTest /** * incrementAndGet increments and returns current value */ - public void testIncrementAndGet(){ + public void testIncrementAndGet() { AtomicLongFieldUpdater a; try { a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x");