15 |
|
|
16 |
|
public class CountDownLatchTest extends JSR166TestCase { |
17 |
|
public static void main(String[] args) { |
18 |
< |
junit.textui.TestRunner.run(suite()); |
18 |
> |
main(suite(), args); |
19 |
|
} |
20 |
|
public static Test suite() { |
21 |
|
return new TestSuite(CountDownLatchTest.class); |
22 |
|
} |
23 |
|
|
24 |
|
/** |
25 |
< |
* negative constructor argument throws IAE |
25 |
> |
* negative constructor argument throws IllegalArgumentException |
26 |
|
*/ |
27 |
|
public void testConstructor() { |
28 |
|
try { |
72 |
|
assertEquals(2, l.getCount()); |
73 |
|
l.countDown(); |
74 |
|
assertEquals(1, l.getCount()); |
75 |
< |
assertThreadStaysAlive(t); |
75 |
> |
assertThreadBlocks(t, Thread.State.WAITING); |
76 |
|
l.countDown(); |
77 |
|
assertEquals(0, l.getCount()); |
78 |
|
awaitTermination(t); |
97 |
|
assertEquals(2, l.getCount()); |
98 |
|
l.countDown(); |
99 |
|
assertEquals(1, l.getCount()); |
100 |
< |
assertThreadStaysAlive(t); |
100 |
> |
assertThreadBlocks(t, Thread.State.TIMED_WAITING); |
101 |
|
l.countDown(); |
102 |
|
assertEquals(0, l.getCount()); |
103 |
|
awaitTermination(t); |
104 |
|
} |
105 |
|
|
106 |
|
/** |
107 |
< |
* await throws IE if interrupted before counted down |
107 |
> |
* await throws InterruptedException if interrupted before counted down |
108 |
|
*/ |
109 |
|
public void testAwait_Interruptible() { |
110 |
|
final CountDownLatch l = new CountDownLatch(1); |
129 |
|
}}); |
130 |
|
|
131 |
|
await(pleaseInterrupt); |
132 |
< |
assertThreadStaysAlive(t); |
132 |
> |
assertThreadBlocks(t, Thread.State.WAITING); |
133 |
|
t.interrupt(); |
134 |
|
awaitTermination(t); |
135 |
|
} |
136 |
|
|
137 |
|
/** |
138 |
< |
* timed await throws IE if interrupted before counted down |
138 |
> |
* timed await throws InterruptedException if interrupted before counted down |
139 |
|
*/ |
140 |
|
public void testTimedAwait_Interruptible() { |
141 |
|
final CountDownLatch l = new CountDownLatch(1); |
160 |
|
}}); |
161 |
|
|
162 |
|
await(pleaseInterrupt); |
163 |
< |
assertThreadStaysAlive(t); |
163 |
> |
assertThreadBlocks(t, Thread.State.TIMED_WAITING); |
164 |
|
t.interrupt(); |
165 |
|
awaitTermination(t); |
166 |
|
} |