23 |
|
return new TestSuite(AtomicLongFieldUpdaterTest.class); |
24 |
|
} |
25 |
|
|
26 |
+ |
/** |
27 |
+ |
* |
28 |
+ |
*/ |
29 |
|
public void testConstructor(){ |
30 |
|
try{ |
31 |
|
AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> |
32 |
|
a = AtomicLongFieldUpdater.newUpdater |
33 |
|
(getClass(), "y"); |
34 |
< |
fail("Exception not thrown"); |
34 |
> |
shouldThrow(); |
35 |
|
} |
33 |
– |
|
36 |
|
catch (RuntimeException rt) {} |
37 |
|
} |
38 |
|
|
39 |
+ |
/** |
40 |
+ |
* |
41 |
+ |
*/ |
42 |
|
public void testConstructor2(){ |
43 |
|
try{ |
44 |
|
AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> |
45 |
|
a = AtomicLongFieldUpdater.newUpdater |
46 |
|
(getClass(), "z"); |
47 |
< |
fail("Exception not thrown"); |
47 |
> |
shouldThrow(); |
48 |
|
} |
44 |
– |
|
49 |
|
catch (RuntimeException rt) {} |
50 |
|
} |
51 |
|
|
52 |
+ |
/** |
53 |
+ |
* |
54 |
+ |
*/ |
55 |
|
public void testConstructor3(){ |
56 |
|
try{ |
57 |
|
AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> |
58 |
|
a = AtomicLongFieldUpdater.newUpdater |
59 |
|
(getClass(), "w"); |
60 |
< |
fail("Exception not thrown"); |
60 |
> |
shouldThrow(); |
61 |
|
} |
62 |
|
|
63 |
|
catch (RuntimeException rt) {} |
64 |
|
} |
65 |
|
|
66 |
+ |
/** |
67 |
+ |
* |
68 |
+ |
*/ |
69 |
|
public void testGetSet(){ |
70 |
|
AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a = AtomicLongFieldUpdater.newUpdater(getClass(), "x"); |
71 |
|
x = 1; |
76 |
|
assertEquals(-3,a.get(this)); |
77 |
|
|
78 |
|
} |
79 |
+ |
/** |
80 |
+ |
* |
81 |
+ |
*/ |
82 |
|
public void testCompareAndSet(){ |
83 |
|
AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a = AtomicLongFieldUpdater.newUpdater(getClass(), "x"); |
84 |
|
x = 1; |
91 |
|
assertEquals(7,a.get(this)); |
92 |
|
} |
93 |
|
|
94 |
+ |
/** |
95 |
+ |
* |
96 |
+ |
*/ |
97 |
|
public void testWeakCompareAndSet(){ |
98 |
|
AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a = AtomicLongFieldUpdater.newUpdater(getClass(), "x"); |
99 |
|
x = 1; |
104 |
|
assertEquals(7,a.get(this)); |
105 |
|
} |
106 |
|
|
107 |
+ |
/** |
108 |
+ |
* |
109 |
+ |
*/ |
110 |
|
public void testGetAndSet(){ |
111 |
|
AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a = AtomicLongFieldUpdater.newUpdater(getClass(), "x"); |
112 |
|
x = 1; |
115 |
|
assertEquals(-10,a.getAndSet(this,1)); |
116 |
|
} |
117 |
|
|
118 |
+ |
/** |
119 |
+ |
* |
120 |
+ |
*/ |
121 |
|
public void testGetAndAdd(){ |
122 |
|
AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a = AtomicLongFieldUpdater.newUpdater(getClass(), "x"); |
123 |
|
x = 1; |
127 |
|
assertEquals(-1,a.get(this)); |
128 |
|
} |
129 |
|
|
130 |
+ |
/** |
131 |
+ |
* |
132 |
+ |
*/ |
133 |
|
public void testGetAndDecrement(){ |
134 |
|
AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a = AtomicLongFieldUpdater.newUpdater(getClass(), "x"); |
135 |
|
x = 1; |
138 |
|
assertEquals(-1,a.getAndDecrement(this)); |
139 |
|
} |
140 |
|
|
141 |
+ |
/** |
142 |
+ |
* |
143 |
+ |
*/ |
144 |
|
public void testGetAndIncrement(){ |
145 |
|
AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a = AtomicLongFieldUpdater.newUpdater(getClass(), "x"); |
146 |
|
x = 1; |
153 |
|
assertEquals(1,a.get(this)); |
154 |
|
} |
155 |
|
|
156 |
+ |
/** |
157 |
+ |
* |
158 |
+ |
*/ |
159 |
|
public void testAddAndGet(){ |
160 |
|
AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a = AtomicLongFieldUpdater.newUpdater(getClass(), "x"); |
161 |
|
x = 1; |
165 |
|
assertEquals(-1,a.get(this)); |
166 |
|
} |
167 |
|
|
168 |
+ |
/** |
169 |
+ |
* |
170 |
+ |
*/ |
171 |
|
public void testDecrementAndGet(){ |
172 |
|
AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a = AtomicLongFieldUpdater.newUpdater(getClass(), "x"); |
173 |
|
x = 1; |
177 |
|
assertEquals(-2,a.get(this)); |
178 |
|
} |
179 |
|
|
180 |
+ |
/** |
181 |
+ |
* |
182 |
+ |
*/ |
183 |
|
public void testIncrementAndGet(){ |
184 |
|
AtomicLongFieldUpdater<AtomicLongFieldUpdaterTest> a = AtomicLongFieldUpdater.newUpdater(getClass(), "x"); |
185 |
|
x = 1; |