10 |
|
import junit.framework.*; |
11 |
|
import java.util.*; |
12 |
|
|
13 |
< |
public class AtomicReferenceFieldUpdaterTest extends JSR166TestCase{ |
13 |
> |
public class AtomicReferenceFieldUpdaterTest extends JSR166TestCase { |
14 |
|
volatile Integer x = null; |
15 |
|
Object z; |
16 |
|
Integer w; |
17 |
|
|
18 |
< |
public static void main(String[] args){ |
18 |
> |
public static void main(String[] args) { |
19 |
|
junit.textui.TestRunner.run(suite()); |
20 |
|
} |
21 |
|
public static Test suite() { |
25 |
|
/** |
26 |
|
* Construction with non-existent field throws RuntimeException |
27 |
|
*/ |
28 |
< |
public void testConstructor(){ |
28 |
> |
public void testConstructor() { |
29 |
|
try { |
30 |
|
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer> |
31 |
|
a = AtomicReferenceFieldUpdater.newUpdater |
39 |
|
/** |
40 |
|
* construction with field not of given type throws RuntimeException |
41 |
|
*/ |
42 |
< |
public void testConstructor2(){ |
42 |
> |
public void testConstructor2() { |
43 |
|
try { |
44 |
|
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer> |
45 |
|
a = AtomicReferenceFieldUpdater.newUpdater |
52 |
|
/** |
53 |
|
* Constructor with non-volatile field throws exception |
54 |
|
*/ |
55 |
< |
public void testConstructor3(){ |
55 |
> |
public void testConstructor3() { |
56 |
|
try { |
57 |
|
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer> |
58 |
|
a = AtomicReferenceFieldUpdater.newUpdater |
65 |
|
/** |
66 |
|
* get returns the last value set or assigned |
67 |
|
*/ |
68 |
< |
public void testGetSet(){ |
68 |
> |
public void testGetSet() { |
69 |
|
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a; |
70 |
|
try { |
71 |
|
a = AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdaterTest.class, Integer.class, "x"); |
83 |
|
/** |
84 |
|
* get returns the last value lazySet by same thread |
85 |
|
*/ |
86 |
< |
public void testGetLazySet(){ |
86 |
> |
public void testGetLazySet() { |
87 |
|
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a; |
88 |
|
try { |
89 |
|
a = AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdaterTest.class, Integer.class, "x"); |
101 |
|
/** |
102 |
|
* compareAndSet succeeds in changing value if equal to expected else fails |
103 |
|
*/ |
104 |
< |
public void testCompareAndSet(){ |
104 |
> |
public void testCompareAndSet() { |
105 |
|
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a; |
106 |
|
try { |
107 |
|
a = AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdaterTest.class, Integer.class, "x"); |
151 |
|
* repeated weakCompareAndSet succeeds in changing value when equal |
152 |
|
* to expected |
153 |
|
*/ |
154 |
< |
public void testWeakCompareAndSet(){ |
154 |
> |
public void testWeakCompareAndSet() { |
155 |
|
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a; |
156 |
|
try { |
157 |
|
a = AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdaterTest.class, Integer.class, "x"); |
169 |
|
/** |
170 |
|
* getAndSet returns previous value and sets to given value |
171 |
|
*/ |
172 |
< |
public void testGetAndSet(){ |
172 |
> |
public void testGetAndSet() { |
173 |
|
AtomicReferenceFieldUpdater<AtomicReferenceFieldUpdaterTest, Integer>a; |
174 |
|
try { |
175 |
|
a = AtomicReferenceFieldUpdater.newUpdater(AtomicReferenceFieldUpdaterTest.class, Integer.class, "x"); |