--- jsr166/src/test/tck/AtomicLongFieldUpdaterTest.java 2005/05/25 14:27:37 1.9 +++ jsr166/src/test/tck/AtomicLongFieldUpdaterTest.java 2009/11/16 05:30:07 1.12 @@ -2,8 +2,8 @@ * Written by Doug Lea with assistance from members of JCP JSR-166 * Expert Group and released to the public domain, as explained at * http://creativecommons.org/licenses/publicdomain - * Other contributors include Andrew Wright, Jeffrey Hayes, - * Pat Fisher, Mike Judd. + * Other contributors include Andrew Wright, Jeffrey Hayes, + * Pat Fisher, Mike Judd. */ import java.util.concurrent.atomic.*; @@ -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,9 +25,9 @@ public class AtomicLongFieldUpdaterTest /** * Construction with non-existent field throws RuntimeException */ - public void testConstructor(){ - try{ - AtomicLongFieldUpdater + public void testConstructor() { + try { + AtomicLongFieldUpdater a = AtomicLongFieldUpdater.newUpdater (AtomicLongFieldUpdaterTest.class, "y"); shouldThrow(); @@ -38,9 +38,9 @@ public class AtomicLongFieldUpdaterTest /** * construction with field not of given type throws RuntimeException */ - public void testConstructor2(){ - try{ - AtomicLongFieldUpdater + public void testConstructor2() { + try { + AtomicLongFieldUpdater a = AtomicLongFieldUpdater.newUpdater (AtomicLongFieldUpdaterTest.class, "z"); shouldThrow(); @@ -51,9 +51,9 @@ public class AtomicLongFieldUpdaterTest /** * construction with non-volatile field throws RuntimeException */ - public void testConstructor3(){ - try{ - AtomicLongFieldUpdater + public void testConstructor3() { + try { + AtomicLongFieldUpdater a = AtomicLongFieldUpdater.newUpdater (AtomicLongFieldUpdaterTest.class, "w"); shouldThrow(); @@ -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"); @@ -135,7 +135,7 @@ 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(); @@ -144,16 +144,16 @@ public class AtomicLongFieldUpdaterTest assertFalse(t.isAlive()); assertEquals(a.get(this), 3); } - catch(Exception e) { + catch (Exception e) { unexpectedException(); } } /** * repeated weakCompareAndSet succeeds in changing value when equal - * to expected + * to expected */ - public void testWeakCompareAndSet(){ + public void testWeakCompareAndSet() { AtomicLongFieldUpdater a; try { a = AtomicLongFieldUpdater.newUpdater(AtomicLongFieldUpdaterTest.class, "x"); @@ -161,17 +161,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 +187,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 +204,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 +220,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 +240,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 +257,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 +274,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");