6 |
|
* Pat Fisher, Mike Judd. |
7 |
|
*/ |
8 |
|
|
9 |
– |
import junit.framework.*; |
9 |
|
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; |
10 |
|
|
11 |
+ |
import junit.framework.Test; |
12 |
+ |
import junit.framework.TestSuite; |
13 |
+ |
|
14 |
|
public class AtomicReferenceFieldUpdaterTest extends JSR166TestCase { |
15 |
|
volatile Integer x = null; |
16 |
|
Object z; |
17 |
|
Integer w; |
18 |
+ |
volatile int i; |
19 |
|
|
20 |
|
public static void main(String[] args) { |
21 |
|
junit.textui.TestRunner.run(suite()); |
36 |
|
try { |
37 |
|
updaterFor("y"); |
38 |
|
shouldThrow(); |
39 |
< |
} catch (RuntimeException success) {} |
39 |
> |
} catch (RuntimeException success) { |
40 |
> |
assertNotNull(success.getCause()); |
41 |
> |
} |
42 |
|
} |
43 |
|
|
44 |
|
/** |
45 |
< |
* construction with field not of given type throws RuntimeException |
45 |
> |
* construction with field not of given type throws ClassCastException |
46 |
|
*/ |
47 |
|
public void testConstructor2() { |
48 |
|
try { |
49 |
|
updaterFor("z"); |
50 |
|
shouldThrow(); |
51 |
< |
} catch (RuntimeException success) {} |
51 |
> |
} catch (ClassCastException success) {} |
52 |
|
} |
53 |
|
|
54 |
|
/** |
55 |
< |
* Constructor with non-volatile field throws exception |
55 |
> |
* Constructor with non-volatile field throws IllegalArgumentException |
56 |
|
*/ |
57 |
|
public void testConstructor3() { |
58 |
|
try { |
59 |
|
updaterFor("w"); |
60 |
|
shouldThrow(); |
61 |
< |
} catch (RuntimeException success) {} |
61 |
> |
} catch (IllegalArgumentException success) {} |
62 |
> |
} |
63 |
> |
|
64 |
> |
/** |
65 |
> |
* Constructor with non-reference field throws ClassCastException |
66 |
> |
*/ |
67 |
> |
public void testConstructor4() { |
68 |
> |
try { |
69 |
> |
updaterFor("i"); |
70 |
> |
shouldThrow(); |
71 |
> |
} catch (ClassCastException success) {} |
72 |
|
} |
73 |
|
|
74 |
|
/** |