9 |
|
import java.util.*; |
10 |
|
import java.util.concurrent.*; |
11 |
|
|
12 |
< |
public class CyclicBarrierTest extends TestCase{ |
12 |
> |
public class CyclicBarrierTest extends JSR166TestCase{ |
13 |
|
|
14 |
|
public static void main(String[] args) { |
15 |
|
junit.textui.TestRunner.run (suite()); |
20 |
|
return new TestSuite(CyclicBarrierTest.class); |
21 |
|
} |
22 |
|
|
23 |
– |
private static long SHORT_DELAY_MS = 100; |
24 |
– |
private static long MEDIUM_DELAY_MS = 1000; |
25 |
– |
private static long LONG_DELAY_MS = 10000; |
26 |
– |
|
23 |
|
public void testConstructor1(){ |
24 |
|
try{ |
25 |
|
new CyclicBarrier(-1, (Runnable)null); |
86 |
|
b.await(); |
87 |
|
b.await(); |
88 |
|
} catch(Exception e){ |
89 |
< |
fail("unexpected exception"); |
89 |
> |
threadFail("unexpected exception"); |
90 |
|
}}}); |
91 |
|
|
92 |
|
try { |
108 |
|
public void run(){ |
109 |
|
try{ |
110 |
|
c.await(); |
111 |
< |
fail("should throw"); |
111 |
> |
threadFail("should throw"); |
112 |
|
} catch(InterruptedException success){} |
113 |
|
catch(Exception b){ |
114 |
< |
fail("should throw IE"); |
114 |
> |
threadFail("should throw IE"); |
115 |
|
} |
116 |
|
} |
117 |
|
}); |
119 |
|
public void run(){ |
120 |
|
try{ |
121 |
|
c.await(); |
122 |
< |
fail("should throw"); |
122 |
> |
threadFail("should throw"); |
123 |
|
} catch(BrokenBarrierException success){ |
124 |
|
} catch(Exception i){ |
125 |
< |
fail("should throw BBE"); |
125 |
> |
threadFail("should throw BBE"); |
126 |
|
} |
127 |
|
} |
128 |
|
}); |
144 |
|
public void run(){ |
145 |
|
try{ |
146 |
|
c.await(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
147 |
< |
fail("should throw"); |
147 |
> |
threadFail("should throw"); |
148 |
|
} catch(InterruptedException success){ |
149 |
|
} catch(Exception b){ |
150 |
< |
fail("should throw IE"); |
150 |
> |
threadFail("should throw IE"); |
151 |
|
} |
152 |
|
} |
153 |
|
}); |
155 |
|
public void run(){ |
156 |
|
try{ |
157 |
|
c.await(MEDIUM_DELAY_MS, TimeUnit.MILLISECONDS); |
158 |
< |
fail("should throw"); |
158 |
> |
threadFail("should throw"); |
159 |
|
} catch(BrokenBarrierException success){ |
160 |
|
} catch(Exception i){ |
161 |
< |
fail("should throw BBE"); |
161 |
> |
threadFail("should throw BBE"); |
162 |
|
} |
163 |
|
} |
164 |
|
}); |
180 |
|
public void run(){ |
181 |
|
try{ |
182 |
|
c.await(SHORT_DELAY_MS, TimeUnit.MILLISECONDS); |
183 |
< |
fail("should throw"); |
183 |
> |
threadFail("should throw"); |
184 |
|
} catch(TimeoutException success){ |
185 |
|
} catch(Exception b){ |
186 |
< |
fail("should throw TOE"); |
186 |
> |
threadFail("should throw TOE"); |
187 |
|
|
188 |
|
} |
189 |
|
} |